From 2fdfa38107cdd71378a4db65c64a4c2b1b9e8fb4 Mon Sep 17 00:00:00 2001
From: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Date: Tue, 8 Feb 2022 16:18:46 +0100
Subject: [PATCH 1/6] rm firmware variants
since not needed anymore
---
platformio_tasmota_env32.ini | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini
index 981a518a2..5b7a7f85f 100644
--- a/platformio_tasmota_env32.ini
+++ b/platformio_tasmota_env32.ini
@@ -62,14 +62,13 @@ build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_WEBCAM
lib_extra_dirs = lib/lib_ssl, lib/libesp32
[env:tasmota32-odroidgo]
-extends = env:tasmota32_base
+extends = env:tasmota32-lvgl
board = esp32-odroid
-build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_ODROID_GO -DUSE_UNIVERSAL_DISPLAY
[env:tasmota32-core2]
-extends = env:tasmota32_base
+extends = env:tasmota32-lvgl
board = esp32-m5core2
-build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_M5STACK_CORE2 -DUSE_UNIVERSAL_DISPLAY
+build_flags = ${env:tasmota32_base.build_flags} -DUSE_I2S_SAY_TIME -DUSE_I2S_WEBRADIO -DUSE_SENDMAIL -DUSE_ESP32MAIL
lib_extra_dirs = lib/libesp32, lib/libesp32_lvgl, lib/lib_basic, lib/lib_i2c, lib/lib_rf, lib/lib_div, lib/lib_ssl, lib/lib_display, lib/lib_audio
[env:tasmota32-bluetooth]
From d1253f603b7503f05bf8fedd98301b93c683f035 Mon Sep 17 00:00:00 2001
From: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Date: Tue, 8 Feb 2022 16:41:03 +0100
Subject: [PATCH 2/6] rm firmware odroid / core2
---
tasmota/tasmota_configurations_ESP32.h | 107 -------------------------
1 file changed, 107 deletions(-)
diff --git a/tasmota/tasmota_configurations_ESP32.h b/tasmota/tasmota_configurations_ESP32.h
index 2fcc9f430..89937b875 100644
--- a/tasmota/tasmota_configurations_ESP32.h
+++ b/tasmota/tasmota_configurations_ESP32.h
@@ -55,113 +55,6 @@
#undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash)
#endif // FIRMWARE_WEBCAM
-/*********************************************************************************************\
- * [tasmota32-odroidgo.bin]
- * Provide an image with useful supported sensors enabled for Odroid Go
-\*********************************************************************************************/
-
-#ifdef FIRMWARE_ODROID_GO
-
-#undef CODE_IMAGE_STR
-#define CODE_IMAGE_STR "odroid-go"
-
-#undef MODULE
-#define MODULE ODROID_GO // [Module] Select default module from tasmota_template.h
-#undef FALLBACK_MODULE
-#define FALLBACK_MODULE ODROID_GO // [Module2] Select default module on fast reboot where USER_MODULE is user template
-
-#define USE_ODROID_GO // Add support for Odroid Go
-#define USE_SDCARD
-
-#define USE_WEBCLIENT_HTTPS
-
-#undef USE_HOME_ASSISTANT
-
-#define USE_I2C
-#define USE_SPI
- #define USE_DISPLAY
- #define SHOW_SPLASH
-#ifdef USE_UNIVERSAL_DISPLAY
- #define USE_LVGL
- #define USE_LVGL_FREETYPE
- #undef SET_ESP32_STACK_SIZE
- #define SET_ESP32_STACK_SIZE (24 * 1024)
-// #define USE_DISPLAY_LVGL_ONLY
-#else
- #define USE_DISPLAY_ILI9341 // [DisplayModel 4] Enable ILI9341 Tft 480x320 display (+19k code)
- #define USE_DISPLAY_MODES1TO5
-#endif
-//#define USE_BLE_ESP32 // Enable new BLE driver
-//#define USE_MI_ESP32 // (ESP32 only) Add support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash)
-#endif // FIRMWARE_ODROID_GO
-
-/*********************************************************************************************\
- * [tasmota32-core2.bin]
- * Provide an image with useful supported sensors enabled for M5stack core2
-\*********************************************************************************************/
-
-#ifdef FIRMWARE_M5STACK_CORE2
-
-#undef CODE_IMAGE_STR
-#define CODE_IMAGE_STR "core2"
-
-#undef MODULE
-#define MODULE M5STACK_CORE2 // [Module] Select default module from tasmota_template.h
-#undef FALLBACK_MODULE
-#define FALLBACK_MODULE M5STACK_CORE2 // [Module2] Select default module on fast reboot where USER_MODULE is user template
-
-#undef USE_HOME_ASSISTANT
-
-#define USE_M5STACK_CORE2 // Add support for M5Stack Core2
- #define USE_I2S_SAY_TIME
- #define USE_I2S_WEBRADIO
-#define USE_SDCARD
-
-#define USE_WEBCLIENT_HTTPS
-
-#define USE_I2C
- #define USE_BMA423
- #define USE_MPU_ACCEL
-#define USE_SPI
- #define USE_DISPLAY
- #define SHOW_SPLASH
-#ifdef USE_UNIVERSAL_DISPLAY
- #define USE_LVGL
- #define USE_LVGL_FREETYPE
- #undef SET_ESP32_STACK_SIZE
- #define SET_ESP32_STACK_SIZE (24 * 1024)
-// #define USE_DISPLAY_LVGL_ONLY
-#else
- #define USE_DISPLAY_ILI9341 // [DisplayModel 4] Enable ILI9341 Tft 480x320 display (+19k code)
- #define USE_DISPLAY_MODES1TO5
-#endif
- #define USE_TOUCH_BUTTONS
- #define JPEG_PICTS
- #define USE_FT5206
-
-#define USE_SENDMAIL
-#define USE_ESP32MAIL
-
-#ifndef USE_RULES
- #define USE_SCRIPT // Add support for script (+17k code)
-// Script related defines
- #define MAXVARS 75
- #define MAXSVARS 15
- #define MAXFILT 10
- #define UFSYS_SIZE 8192
- #define USE_SCRIPT_TASK
- #define LARGE_ARRAYS
- #define SCRIPT_LARGE_VNBUFF
- #define USE_SCRIPT_GLOBVARS
- #define USE_SCRIPT_SUB_COMMAND
- #define USE_ANGLE_FUNC
- #define USE_SCRIPT_WEB_DISPLAY
- #define SCRIPT_FULL_WEBPAGE
- #define SCRIPT_GET_HTTPS_JP
- #define USE_GOOGLE_CHARTS
-#endif // USE_RULES
-#endif // FIRMWARE_M5STACK_CORE2
-
/*********************************************************************************************\
* [tasmota32-bluetooth.bin]
* Provide an image with BLE support
From cc71f85483f92e11bdd4313ad8c1bb94f6958c27 Mon Sep 17 00:00:00 2001
From: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Date: Tue, 8 Feb 2022 16:43:50 +0100
Subject: [PATCH 3/6] Delete xdrv_80_esp32_odroidgo.ino
---
tasmota/xdrv_80_esp32_odroidgo.ino | 34 ------------------------------
1 file changed, 34 deletions(-)
delete mode 100644 tasmota/xdrv_80_esp32_odroidgo.ino
diff --git a/tasmota/xdrv_80_esp32_odroidgo.ino b/tasmota/xdrv_80_esp32_odroidgo.ino
deleted file mode 100644
index bd7fd8cc1..000000000
--- a/tasmota/xdrv_80_esp32_odroidgo.ino
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- xdrv_81_esp32_odroidgo.ino - ESP32 odroid go support for Tasmota
-
- Copyright (C) 2021 Theo Arends
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-
-#ifdef ESP32
-#ifdef USE_ODROID_GO
-/*********************************************************************************************\
- * Odroid Go
- *
- * Clock frequency 160MHz (board_build.f_cpu = 160000000L)
- * SPI Flash Size = 16MB (board_build.partitions = esp32_partition_app1984k_spiffs12M.csv)
- *
- * To be done:
- * - Audio on GPIO25/26
- *
-/*********************************************************************************************/
-
-#endif // USE_ODROID_GO
-#endif // ESP32
From dee69c931d3124ed1d42340663550025051f109b Mon Sep 17 00:00:00 2001
From: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Date: Tue, 8 Feb 2022 16:44:25 +0100
Subject: [PATCH 4/6] Delete xdrv_84_esp32_core2.ino
---
tasmota/xdrv_84_esp32_core2.ino | 366 --------------------------------
1 file changed, 366 deletions(-)
delete mode 100644 tasmota/xdrv_84_esp32_core2.ino
diff --git a/tasmota/xdrv_84_esp32_core2.ino b/tasmota/xdrv_84_esp32_core2.ino
deleted file mode 100644
index b2cfe5720..000000000
--- a/tasmota/xdrv_84_esp32_core2.ino
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- xdrv_84_esp32_core2.ino - ESP32 m5stack core2 support for Tasmota
-
- Copyright (C) 2021 Gerhard Mutz and Theo Arends
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-
-#ifdef ESP32
-#ifdef USE_M5STACK_CORE2
-/*********************************************************************************************\
- * M5Stack Core2 support
- *
- * Module 7
- * Template {"NAME":"M5Core2","GPIO":[1,1,1,1,6720,6368,0,0,0,1,1,6400,0,0,736,1,0,0,0,704,0,1,1,1,0,0,0,0,640,608,1,1,1,0,672,0],"FLAG":0,"BASE":7}
- *
- * Initial commands:
- * - DisplayType 2
- * - DisplayCols 27
- * - (optional) DisplayMode 2
- * - Power on
- * - Voltres 3
- * - Ampres 1
- *
- * Todo:
- * - i2s microphone as loudness sensor
- * - rtc better sync
-\*********************************************************************************************/
-
-#define XDRV_84 84
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-struct CORE2_globs {
- AXP192 Axp;
- BM8563_RTC Rtc;
- bool ready;
- bool tset;
- int32_t shutdownseconds;
- uint8_t wakeup_hour;
- uint8_t wakeup_minute;
- uint8_t shutdowndelay;
-} core2_globs;
-
-struct CORE2_ADC {
- float vbus_v;
- float batt_v;
- float vbus_c;
- float batt_c;
- float temp;
-} core2_adc;
-
-/*********************************************************************************************/
-
-void Core2DoShutdown(void) {
- SettingsSaveAll();
- RtcSettingsSave();
- core2_globs.Rtc.clearIRQ();
- if (core2_globs.shutdownseconds > 0) {
- core2_globs.Rtc.SetAlarmIRQ(core2_globs.shutdownseconds);
- } else {
- RTC_TimeTypeDef wut;
- wut.Hours = core2_globs.wakeup_hour;
- wut.Minutes = core2_globs.wakeup_minute;
- core2_globs.Rtc.SetAlarmIRQ(wut);
- }
- delay(10);
- core2_globs.Axp.PowerOff();
-}
-
-void Core2GetADC(void) {
- core2_adc.vbus_v = core2_globs.Axp.GetVBusVoltage();
- core2_adc.batt_v = core2_globs.Axp.GetBatVoltage();
- core2_adc.vbus_c = core2_globs.Axp.GetVinCurrent();
- core2_adc.batt_c = core2_globs.Axp.GetBatCurrent();
-
- core2_adc.temp = ConvertTemp(core2_globs.Axp.GetTempInAXP192());
-}
-
-void Core2GetRtc(void) {
- RTC_TimeTypeDef RTCtime;
- core2_globs.Rtc.GetTime(&RTCtime);
- RtcTime.hour = RTCtime.Hours;
- RtcTime.minute = RTCtime.Minutes;
- RtcTime.second = RTCtime.Seconds;
-
- RTC_DateTypeDef RTCdate;
- core2_globs.Rtc.GetDate(&RTCdate);
- RtcTime.day_of_week = RTCdate.WeekDay;
- RtcTime.month = RTCdate.Month;
- RtcTime.day_of_month = RTCdate.Date;
- RtcTime.year = RTCdate.Year;
-
- AddLog(LOG_LEVEL_INFO, PSTR("CR2: Set RTC %04d-%02d-%02dT%02d:%02d:%02d"),
- RTCdate.Year, RTCdate.Month, RTCdate.Date, RTCtime.Hours, RTCtime.Minutes, RTCtime.Seconds);
-}
-
-void Core2SetUtc(uint32_t epoch_time) {
- TIME_T tm;
- BreakTime(epoch_time, tm);
- RTC_TimeTypeDef RTCtime;
- RTCtime.Hours = tm.hour;
- RTCtime.Minutes = tm.minute;
- RTCtime.Seconds = tm.second;
- core2_globs.Rtc.SetTime(&RTCtime);
- RTC_DateTypeDef RTCdate;
- RTCdate.WeekDay = tm.day_of_week;
- RTCdate.Month = tm.month;
- RTCdate.Date = tm.day_of_month;
- RTCdate.Year = tm.year + 1970;
- core2_globs.Rtc.SetDate(&RTCdate);
-}
-
-uint32_t Core2GetUtc(void) {
- RTC_TimeTypeDef RTCtime;
- // 1. read has errors ???
- core2_globs.Rtc.GetTime(&RTCtime);
- core2_globs.Rtc.GetTime(&RTCtime);
- RTC_DateTypeDef RTCdate;
- core2_globs.Rtc.GetDate(&RTCdate);
- TIME_T tm;
- tm.second = RTCtime.Seconds;
- tm.minute = RTCtime.Minutes;
- tm.hour = RTCtime.Hours;
- tm.day_of_week = RTCdate.WeekDay;
- tm.day_of_month = RTCdate.Date;
- tm.month = RTCdate.Month;
- tm.year = RTCdate.Year - 1970;
- return MakeTime(tm);
-}
-
-/*********************************************************************************************\
- * Called from xdrv_10_scripter.ino
-\*********************************************************************************************/
-
-extern uint8_t tbstate[3];
-
-// c2ps(a b)
-float Core2SetAxpPin(uint32_t sel, uint32_t val) {
- switch (sel) {
- case 0:
- core2_globs.Axp.SetLed(val);
- break;
- case 1:
- core2_globs.Axp.SetLDOEnable(3, val);
- break;
- case 2:
- if (val<1 || val>3) val = 1;
- return tbstate[val - 1] & 1;
- break;
- case 3:
- switch (val) {
- case 0:
- return core2_globs.Axp.isACIN();
- break;
- case 1:
- return core2_globs.Axp.isCharging();
- break;
- case 2:
- return core2_globs.Axp.isVBUS();
- break;
- case 3:
- return core2_globs.Axp.AXPInState();
- break;
- }
- break;
- default:
- Core2GetRtc();
- break;
- }
- return 0;
-}
-
-/*********************************************************************************************\
- * Called from xdrv_42_i2s_audio.ino
-\*********************************************************************************************/
-
-void Core2AudioPower(bool power) {
- core2_globs.Axp.SetSpkEnable(power);
-}
-
-/*********************************************************************************************\
- * Called from xdsp_04_ili9341.ino and xdsp_17_universal.ino
-\*********************************************************************************************/
-
-void Core2DisplayPower(uint8_t on) {
- core2_globs.Axp.SetDCDC3(on);
-}
-
-// display dimmer ranges from 0-15
-// very little effect
-void Core2DisplayDim(uint8_t dim) {
- uint16_t voltage = 2200;
-
- voltage += ((uint32_t)dim*1200)/15;
- core2_globs.Axp.SetLcdVoltage(voltage);
-
-// core2_globs.Axp.ScreenBreath(dim);
-}
-
-/*********************************************************************************************/
-
-// cause SC card is needed by scripter
-void Core2ModuleInit(void) {
- // m5stack uses pin 38 not selectable in tasmota
- SPI.setFrequency(40000000);
- SPI.begin(18, 38, 23, -1);
- // establish power chip on wire1 SDA 21, SCL 22
- core2_globs.Axp.begin();
- I2cSetActiveFound(AXP_ADDR, "AXP192");
-
- core2_globs.Axp.SetAdcState(true);
- // motor voltage
- core2_globs.Axp.SetLDOVoltage(3,2000);
-
- core2_globs.Rtc.begin();
- I2cSetActiveFound(RTC_ADRESS, "RTC");
-
- core2_globs.ready = true;
-}
-
-void Core2Init(void) {
- if (Rtc.utc_time < START_VALID_TIME) {
- // set rtc from chip
- Rtc.utc_time = Core2GetUtc();
-
- TIME_T tmpTime;
- TasmotaGlobal.ntp_force_sync = true; // Force to sync with ntp
- BreakTime(Rtc.utc_time, tmpTime);
- Rtc.daylight_saving_time = RuleToTime(Settings->tflag[1], RtcTime.year);
- Rtc.standard_time = RuleToTime(Settings->tflag[0], RtcTime.year);
- AddLog(LOG_LEVEL_INFO, PSTR("CR2: Set time from BM8563 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
- GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str());
- if (Rtc.local_time < START_VALID_TIME) { // 2016-01-01
- TasmotaGlobal.rules_flag.time_init = 1;
- } else {
- TasmotaGlobal.rules_flag.time_set = 1;
- }
- }
-}
-
-void Core2Loop(uint32_t flg) {
-
-}
-
-void Core2EverySecond(void) {
- if (core2_globs.ready) {
- Core2GetADC();
-
- if (Rtc.utc_time > START_VALID_TIME && core2_globs.tset==false && abs((int32_t)Rtc.utc_time - (int32_t)Core2GetUtc()) > 3) {
- Core2SetUtc(Rtc.utc_time);
- AddLog(LOG_LEVEL_INFO, PSTR("CR2: Write Time TO BM8563 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
- GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str());
- core2_globs.tset = true;
- }
-
- if (core2_globs.shutdowndelay) {
- core2_globs.shutdowndelay--;
- if (!core2_globs.shutdowndelay) {
- Core2DoShutdown();
- }
- }
- }
-}
-
-void Core2Show(uint32_t json) {
- if (json) {
- ResponseAppend_P(PSTR(",\"Core2\":{\"VBV\":%*_f,\"VBC\":%*_f,\"BV\":%*_f,\"BC\":%*_f,\"" D_JSON_TEMPERATURE "\":%*_f}"),
- Settings->flag2.voltage_resolution, &core2_adc.vbus_v,
- Settings->flag2.current_resolution, &core2_adc.vbus_c,
- Settings->flag2.voltage_resolution, &core2_adc.batt_v,
- Settings->flag2.current_resolution, &core2_adc.batt_c,
- Settings->flag2.temperature_resolution, &core2_adc.temp);
- } else {
- WSContentSend_Voltage("VBus", core2_adc.vbus_v);
- WSContentSend_CurrentMA("VBus", core2_adc.vbus_c);
- WSContentSend_Voltage("Batt", core2_adc.batt_v);
- WSContentSend_CurrentMA("Batt", core2_adc.batt_c);
- WSContentSend_Temp("Core2", core2_adc.temp);
- }
-}
-
-/*********************************************************************************************\
- * Commands
-\*********************************************************************************************/
-
-const char kCore2Commands[] PROGMEM = "Core2|"
- "Shutdown";
-
-void (* const Core2Command[])(void) PROGMEM = {
- &CmndCore2Shutdown};
-
-void CmndCore2Shutdown(void) {
- char *mp = strchr(XdrvMailbox.data, ':');
- if (mp) {
- core2_globs.wakeup_hour = atoi(XdrvMailbox.data);
- core2_globs.wakeup_minute = atoi(mp+1);
- core2_globs.shutdownseconds = -1;
- core2_globs.shutdowndelay = 10;
- char tbuff[16];
- sprintf(tbuff, "%02.2d" D_HOUR_MINUTE_SEPARATOR "%02.2d", core2_globs.wakeup_hour, core2_globs.wakeup_minute );
- ResponseCmndChar(tbuff);
- } else {
- if (XdrvMailbox.payload >= 30) {
- core2_globs.shutdownseconds = XdrvMailbox.payload;
- core2_globs.shutdowndelay = 10;
- }
- ResponseCmndNumber(XdrvMailbox.payload);
- }
-}
-
-/*********************************************************************************************\
- * Interface
-\*********************************************************************************************/
-
-bool Xdrv84(uint8_t function) {
- bool result = false;
-
- switch (function) {
- case FUNC_LOOP:
- Core2Loop(1);
- break;
- case FUNC_EVERY_SECOND:
- Core2EverySecond();
- break;
- case FUNC_JSON_APPEND:
- Core2Show(1);
- break;
-#ifdef USE_WEBSERVER
- case FUNC_WEB_SENSOR:
- Core2Show(0);
- break;
-#endif
- case FUNC_COMMAND:
- result = DecodeCommand(kCore2Commands, Core2Command);
- break;
- case FUNC_INIT:
- Core2Init();
- break;
- case FUNC_MODULE_INIT:
- Core2ModuleInit();
- break;
- }
- return result;
-}
-
-#endif // USE_M5STACK_CORE2
-#endif // ESP32
From c5a57f0174aee7a82720c2b64f4893b90caa4108 Mon Sep 17 00:00:00 2001
From: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Date: Tue, 8 Feb 2022 17:02:45 +0100
Subject: [PATCH 5/6] use env:tasmota32-lvgl build flags
---
platformio_tasmota_env32.ini | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini
index 5b7a7f85f..2c0e425b2 100644
--- a/platformio_tasmota_env32.ini
+++ b/platformio_tasmota_env32.ini
@@ -68,7 +68,7 @@ board = esp32-odroid
[env:tasmota32-core2]
extends = env:tasmota32-lvgl
board = esp32-m5core2
-build_flags = ${env:tasmota32_base.build_flags} -DUSE_I2S_SAY_TIME -DUSE_I2S_WEBRADIO -DUSE_SENDMAIL -DUSE_ESP32MAIL
+build_flags = ${env:tasmota32-lvgl.build_flags} -DUSE_I2S_SAY_TIME -DUSE_I2S_WEBRADIO -DUSE_SENDMAIL -DUSE_ESP32MAIL
lib_extra_dirs = lib/libesp32, lib/libesp32_lvgl, lib/lib_basic, lib/lib_i2c, lib/lib_rf, lib/lib_div, lib/lib_ssl, lib/lib_display, lib/lib_audio
[env:tasmota32-bluetooth]
From 39a0c67d06711b8916f075adf22fbb22d5bd18f0 Mon Sep 17 00:00:00 2001
From: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Date: Tue, 8 Feb 2022 17:11:14 +0100
Subject: [PATCH 6/6] using Berry driver
---
lib/libesp32/CORE2_Library/AXP192.cpp | 614 ------------------
lib/libesp32/CORE2_Library/AXP192.h | 106 ---
lib/libesp32/CORE2_Library/BM8563_RTC.cpp | 353 ----------
lib/libesp32/CORE2_Library/BM8563_RTC.h | 76 ---
lib/libesp32/CORE2_Library/library.json | 8 -
lib/libesp32/CORE2_Library/library.properties | 9 -
6 files changed, 1166 deletions(-)
delete mode 100755 lib/libesp32/CORE2_Library/AXP192.cpp
delete mode 100755 lib/libesp32/CORE2_Library/AXP192.h
delete mode 100755 lib/libesp32/CORE2_Library/BM8563_RTC.cpp
delete mode 100755 lib/libesp32/CORE2_Library/BM8563_RTC.h
delete mode 100644 lib/libesp32/CORE2_Library/library.json
delete mode 100644 lib/libesp32/CORE2_Library/library.properties
diff --git a/lib/libesp32/CORE2_Library/AXP192.cpp b/lib/libesp32/CORE2_Library/AXP192.cpp
deleted file mode 100755
index 6e68245ab..000000000
--- a/lib/libesp32/CORE2_Library/AXP192.cpp
+++ /dev/null
@@ -1,614 +0,0 @@
-#include "AXP192.h"
-
-//#define AXP192_DEBUG
-
-AXP192::AXP192()
-{
-}
-
-void AXP192::begin(void)
-{
-
- Wire1.begin(21, 22);
- Wire1.setClock(400000);
-
- //AXP192 30H
- Write1Byte(0x30, (Read8bit(0x30) & 0x04) | 0X02);
-#ifdef AXP192_DEBUG
- Serial.printf("axp: vbus limit off\n");
-#endif
-
- //AXP192 GPIO1:OD OUTPUT
- Write1Byte(0x92, Read8bit(0x92) & 0xf8);
-#ifdef AXP192_DEBUG
- Serial.printf("axp: gpio1 init\n");
-#endif
- //AXP192 GPIO2:OD OUTPUT
- Write1Byte(0x93, Read8bit(0x93) & 0xf8);
-#ifdef AXP192_DEBUG
- Serial.printf("axp: gpio2 init\n");
-#endif
- //AXP192 RTC CHG
- Write1Byte(0x35, (Read8bit(0x35) & 0x1c) | 0xa2);
-#ifdef AXP192_DEBUG
- Serial.printf("axp: rtc battery charging enabled\n");
-#endif
- SetESPVoltage(3350);
-#ifdef AXP192_DEBUG
- Serial.printf("axp: esp32 power voltage was set to 3.35v\n");
-#endif
- SetLcdVoltage(2800);
-#ifdef AXP192_DEBUG
- Serial.printf("axp: lcd backlight voltage was set to 2.80v\n");
-#endif
- SetLDOVoltage(2, 3300); //Periph power voltage preset (LCD_logic, SD card)
-#ifdef AXP192_DEBUG
- Serial.printf("axp: lcd logic and sdcard voltage preset to 3.3v\n");
-#endif
- SetLDOVoltage(3, 2000); //Vibrator power voltage preset
-#ifdef AXP192_DEBUG
- Serial.printf("axp: vibrator voltage preset to 2v\n");
-#endif
-
- SetLDOEnable(2, true);
- SetDCDC3(true); // LCD backlight
- SetLed(true);
-
- SetCHGCurrent(kCHG_100mA);
- //SetAxpPriphPower(1);
- //Serial.printf("axp: lcd_logic and sdcard power enabled\n\n");
-
- //pinMode(39, INPUT_PULLUP);
-
- //AXP192 GPIO4
- Write1Byte(0X95, (Read8bit(0x95) & 0x72) | 0X84);
-
- Write1Byte(0X36, 0X4C);
-
- Write1Byte(0x82,0xff);
-
- SetLCDRSet(0);
- delay(100);
- SetLCDRSet(1);
- delay(100);
- // I2C_WriteByteDataAt(0X15,0XFE,0XFF);
-
- // bus power mode_output
- SetBusPowerMode(0);
-}
-
-void AXP192::Write1Byte(uint8_t Addr, uint8_t Data)
-{
- Wire1.beginTransmission(0x34);
- Wire1.write(Addr);
- Wire1.write(Data);
- Wire1.endTransmission();
-}
-
-uint8_t AXP192::Read8bit(uint8_t Addr)
-{
- Wire1.beginTransmission(0x34);
- Wire1.write(Addr);
- Wire1.endTransmission();
- Wire1.requestFrom(0x34, 1);
- return Wire1.read();
-}
-
-uint16_t AXP192::Read12Bit(uint8_t Addr)
-{
- uint16_t Data = 0;
- uint8_t buf[2];
- ReadBuff(Addr, 2, buf);
- Data = ((buf[0] << 4) + buf[1]); //
- return Data;
-}
-
-uint16_t AXP192::Read13Bit(uint8_t Addr)
-{
- uint16_t Data = 0;
- uint8_t buf[2];
- ReadBuff(Addr, 2, buf);
- Data = ((buf[0] << 5) + buf[1]); //
- return Data;
-}
-
-uint16_t AXP192::Read16bit(uint8_t Addr)
-{
- uint16_t ReData = 0;
- Wire1.beginTransmission(0x34);
- Wire1.write(Addr);
- Wire1.endTransmission();
- Wire1.requestFrom(0x34, 2);
- for (int i = 0; i < 2; i++)
- {
- ReData <<= 8;
- ReData |= Wire1.read();
- }
- return ReData;
-}
-
-uint32_t AXP192::Read24bit(uint8_t Addr)
-{
- uint32_t ReData = 0;
- Wire1.beginTransmission(0x34);
- Wire1.write(Addr);
- Wire1.endTransmission();
- Wire1.requestFrom(0x34, 3);
- for (int i = 0; i < 3; i++)
- {
- ReData <<= 8;
- ReData |= Wire1.read();
- }
- return ReData;
-}
-
-uint32_t AXP192::Read32bit(uint8_t Addr)
-{
- uint32_t ReData = 0;
- Wire1.beginTransmission(0x34);
- Wire1.write(Addr);
- Wire1.endTransmission();
- Wire1.requestFrom(0x34, 2);
- for (int i = 0; i < 4; i++)
- {
- ReData <<= 8;
- ReData |= Wire1.read();
- }
- return ReData;
-}
-
-void AXP192::ReadBuff(uint8_t Addr, uint8_t Size, uint8_t *Buff)
-{
- Wire1.beginTransmission(0x34);
- Wire1.write(Addr);
- Wire1.endTransmission();
- Wire1.requestFrom(0x34, (int)Size);
- for (int i = 0; i < Size; i++)
- {
- *(Buff + i) = Wire1.read();
- }
-}
-
-void AXP192::ScreenBreath(uint8_t brightness)
-{
- if (brightness > 12)
- {
- brightness = 12;
- }
- uint8_t buf = Read8bit(0x28);
- Write1Byte(0x28, ((buf & 0x0f) | (brightness << 4)));
-}
-
-bool AXP192::GetBatState()
-{
- if (Read8bit(0x01) | 0x20)
- return true;
- else
- return false;
-}
-//---------coulombcounter_from_here---------
-//enable: void EnableCoulombcounter(void);
-//disable: void DisableCOulombcounter(void);
-//stop: void StopCoulombcounter(void);
-//clear: void ClearCoulombcounter(void);
-//get charge data: uint32_t GetCoulombchargeData(void);
-//get discharge data: uint32_t GetCoulombdischargeData(void);
-//get coulomb val affter calculation: float GetCoulombData(void);
-//------------------------------------------
-void AXP192::EnableCoulombcounter(void)
-{
- Write1Byte(0xB8, 0x80);
-}
-
-void AXP192::DisableCoulombcounter(void)
-{
- Write1Byte(0xB8, 0x00);
-}
-
-void AXP192::StopCoulombcounter(void)
-{
- Write1Byte(0xB8, 0xC0);
-}
-
-void AXP192::ClearCoulombcounter(void)
-{
- Write1Byte(0xB8, 0xA0);
-}
-
-uint32_t AXP192::GetCoulombchargeData(void)
-{
- return Read32bit(0xB0);
-}
-
-uint32_t AXP192::GetCoulombdischargeData(void)
-{
- return Read32bit(0xB4);
-}
-
-float AXP192::GetCoulombData(void)
-{
-
- uint32_t coin = 0;
- uint32_t coout = 0;
-
- coin = GetCoulombchargeData();
- coout = GetCoulombdischargeData();
-
- //c = 65536 * current_LSB * (coin - coout) / 3600 / ADC rate
- //Adc rate can be read from 84H ,change this variable if you change the ADC reate
- float ccc = 65536 * 0.5 * (coin - coout) / 3600.0 / 25.0;
- return ccc;
-}
-
-// Cut all power, except for LDO1 (RTC)
-void AXP192::PowerOff(void)
-{
- Write1Byte(0x32, Read8bit(0x32) | 0b10000000);
-}
-
-void AXP192::SetAdcState(bool state)
-{
- // Enable / Disable all ADCs
- Write1Byte(0x82, state ? 0xff : 0x00);
-}
-
-void AXP192::PrepareToSleep(void)
-{
- // Disable ADCs
- SetAdcState(false);
-
- // Turn LED off
- SetLed(false);
-
- // Turn LCD backlight off
- SetDCDC3(false);
-}
-
-void AXP192::RestoreFromLightSleep(void)
-{
- // Turn LCD backlight on
- SetDCDC3(true);
-
- // Turn LED on
- SetLed(true);
-
- // Enable ADCs
- SetAdcState(true);
-}
-
-uint8_t AXP192::GetWarningLeve(void)
-{
- Wire1.beginTransmission(0x34);
- Wire1.write(0x47);
- Wire1.endTransmission();
- Wire1.requestFrom(0x34, 1);
- uint8_t buf = Wire1.read();
- return (buf & 0x01);
-}
-
-// -- sleep
-void AXP192::DeepSleep(uint64_t time_in_us)
-{
- PrepareToSleep();
-
- if (time_in_us > 0)
- {
- esp_sleep_enable_timer_wakeup(time_in_us);
- }
- else
- {
- esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER);
- }
- (time_in_us == 0) ? esp_deep_sleep_start() : esp_deep_sleep(time_in_us);
-
- // Never reached - after deep sleep ESP32 restarts
-}
-
-void AXP192::LightSleep(uint64_t time_in_us)
-{
- PrepareToSleep();
-
- if (time_in_us > 0)
- {
- esp_sleep_enable_timer_wakeup(time_in_us);
- }
- else
- {
- esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER);
- }
- esp_light_sleep_start();
-
- RestoreFromLightSleep();
-}
-
-uint8_t AXP192::GetWarningLevel(void)
-{
- return Read8bit(0x47) & 0x01;
-}
-
-float AXP192::GetBatVoltage()
-{
- float ADCLSB = 1.1 / 1000.0;
- uint16_t ReData = Read12Bit(0x78);
- return ReData * ADCLSB;
-}
-
-float AXP192::GetBatCurrent()
-{
- float ADCLSB = 0.5;
- uint16_t CurrentIn = Read13Bit(0x7A);
- uint16_t CurrentOut = Read13Bit(0x7C);
- return (CurrentIn - CurrentOut) * ADCLSB;
-}
-
-float AXP192::GetVinVoltage()
-{
- float ADCLSB = 1.7 / 1000.0;
- uint16_t ReData = Read12Bit(0x56);
- return ReData * ADCLSB;
-}
-
-float AXP192::GetVinCurrent()
-{
- float ADCLSB = 0.625;
- uint16_t ReData = Read12Bit(0x58);
- return ReData * ADCLSB;
-}
-
-float AXP192::GetVBusVoltage()
-{
- float ADCLSB = 1.7 / 1000.0;
- uint16_t ReData = Read12Bit(0x5A);
- return ReData * ADCLSB;
-}
-
-float AXP192::GetVBusCurrent()
-{
- float ADCLSB = 0.375;
- uint16_t ReData = Read12Bit(0x5C);
- return ReData * ADCLSB;
-}
-
-float AXP192::GetTempInAXP192()
-{
- float ADCLSB = 0.1;
- const float OFFSET_DEG_C = -144.7;
- uint16_t ReData = Read12Bit(0x5E);
- return OFFSET_DEG_C + ReData * ADCLSB;
-}
-
-float AXP192::GetBatPower()
-{
- float VoltageLSB = 1.1;
- float CurrentLCS = 0.5;
- uint32_t ReData = Read24bit(0x70);
- return VoltageLSB * CurrentLCS * ReData / 1000.0;
-}
-
-float AXP192::GetBatChargeCurrent()
-{
- float ADCLSB = 0.5;
- uint16_t ReData = Read12Bit(0x7A);
- return ReData * ADCLSB;
-}
-float AXP192::GetAPSVoltage()
-{
- float ADCLSB = 1.4 / 1000.0;
- uint16_t ReData = Read12Bit(0x7E);
- return ReData * ADCLSB;
-}
-
-float AXP192::GetBatCoulombInput()
-{
- uint32_t ReData = Read32bit(0xB0);
- return ReData * 65536 * 0.5 / 3600 / 25.0;
-}
-
-float AXP192::GetBatCoulombOut()
-{
- uint32_t ReData = Read32bit(0xB4);
- return ReData * 65536 * 0.5 / 3600 / 25.0;
-}
-
-void AXP192::SetCoulombClear()
-{
- Write1Byte(0xB8, 0x20);
-}
-
-void AXP192::SetLDO2(bool State)
-{
- uint8_t buf = Read8bit(0x12);
- if (State == true)
- buf = (1 << 2) | buf;
- else
- buf = ~(1 << 2) & buf;
- Write1Byte(0x12, buf);
-}
-
-void AXP192::SetDCDC3(bool State)
-{
- uint8_t buf = Read8bit(0x12);
- if (State == true)
- buf = (1 << 1) | buf;
- else
- buf = ~(1 << 1) & buf;
- Write1Byte(0x12, buf);
-}
-
-uint8_t AXP192::AXPInState()
-{
- return Read8bit(0x00);
-}
-bool AXP192::isACIN()
-{
- return ( Read8bit(0x00) & 0x80 ) ? true : false;
-}
-bool AXP192::isCharging()
-{
- return ( Read8bit(0x00) & 0x04 ) ? true : false;
-}
-bool AXP192::isVBUS()
-{
- return ( Read8bit(0x00) & 0x20 ) ? true : false;
-}
-
-void AXP192::SetLDOVoltage(uint8_t number, uint16_t voltage)
-{
- voltage = (voltage > 3300) ? 15 : (voltage / 100) - 18;
- switch (number)
- {
- //uint8_t reg, data;
- case 2:
- Write1Byte(0x28, (Read8bit(0x28) & 0X0F) | (voltage << 4));
- break;
- case 3:
- Write1Byte(0x28, (Read8bit(0x28) & 0XF0) | voltage);
- break;
- }
-}
-
-void AXP192::SetDCVoltage(uint8_t number, uint16_t voltage)
-{
- uint8_t addr;
- if (number > 2)
- return;
- voltage = (voltage < 700) ? 0 : (voltage - 700) / 25;
- switch (number)
- {
- case 0:
- addr = 0x26;
- break;
- case 1:
- addr = 0x25;
- break;
- case 2:
- addr = 0x27;
- break;
- }
- Write1Byte(addr, (Read8bit(addr) & 0X80) | (voltage & 0X7F));
-}
-
-void AXP192::SetESPVoltage(uint16_t voltage)
-{
- if (voltage >= 3000 && voltage <= 3400)
- {
- SetDCVoltage(0, voltage);
- }
-}
-void AXP192::SetLcdVoltage(uint16_t voltage)
-{
- if (voltage >= 2500 && voltage <= 3300)
- {
- SetDCVoltage(2, voltage);
- }
-}
-
-void AXP192::SetLDOEnable(uint8_t number, bool state)
-{
- uint8_t mark = 0x01;
- if ((number < 2) || (number > 3))
- return;
-
- mark <<= number;
- if (state)
- {
- Write1Byte(0x12, (Read8bit(0x12) | mark));
- }
- else
- {
- Write1Byte(0x12, (Read8bit(0x12) & (~mark)));
- }
-}
-
-void AXP192::SetLCDRSet(bool state)
-{
- uint8_t reg_addr = 0x96;
- uint8_t gpio_bit = 0x02;
- uint8_t data;
- data = Read8bit(reg_addr);
-
- if (state)
- {
- data |= gpio_bit;
- }
- else
- {
- data &= ~gpio_bit;
- }
-
- Write1Byte(reg_addr, data);
-}
-
-void AXP192::SetBusPowerMode(uint8_t state)
-{
- uint8_t data;
- if (state == 0)
- {
- data = Read8bit(0x91);
- Write1Byte(0x91, (data & 0X0F) | 0XF0);
-
- data = Read8bit(0x90);
- Write1Byte(0x90, (data & 0XF8) | 0X02); //set GPIO0 to LDO OUTPUT , pullup N_VBUSEN to disable supply from BUS_5V
-
- data = Read8bit(0x91);
-
- data = Read8bit(0x12); //read reg 0x12
- Write1Byte(0x12, data | 0x40); //set EXTEN to enable 5v boost
- }
- else
- {
- data = Read8bit(0x12); //read reg 0x10
- Write1Byte(0x12, data & 0XBF); //set EXTEN to disable 5v boost
-
- //delay(2000);
-
- data = Read8bit(0x90);
- Write1Byte(0x90, (data & 0xF8) | 0X01); //set GPIO0 to float , using enternal pulldown resistor to enable supply from BUS_5VS
- }
-}
-
-void AXP192::SetLed(uint8_t state)
-{
- uint8_t reg_addr=0x94;
- uint8_t data;
- data=Read8bit(reg_addr);
-
- if(state)
- {
- data=data&0XFD;
- }
- else
- {
- data|=0X02;
- }
-
- Write1Byte(reg_addr,data);
-}
-
-//set led state(GPIO high active,set 1 to enable amplifier)
-void AXP192::SetSpkEnable(uint8_t state)
-{
- uint8_t reg_addr=0x94;
- uint8_t gpio_bit=0x04;
- uint8_t data;
- data=Read8bit(reg_addr);
-
- if(state)
- {
- data|=gpio_bit;
- }
- else
- {
- data&=~gpio_bit;
- }
-
- Write1Byte(reg_addr,data);
-}
-
-void AXP192::SetCHGCurrent(uint8_t state)
-{
- uint8_t data = Read8bit(0x33);
- data &= 0xf0;
- data = data | ( state & 0x0f );
- Write1Byte(0x33,data);
-}
diff --git a/lib/libesp32/CORE2_Library/AXP192.h b/lib/libesp32/CORE2_Library/AXP192.h
deleted file mode 100755
index 662c37e8b..000000000
--- a/lib/libesp32/CORE2_Library/AXP192.h
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifndef __AXP192_H__
-#define __AXP192_H__
-
-#include
-#include
-
-#define SLEEP_MSEC(us) (((uint64_t)us) * 1000L)
-#define SLEEP_SEC(us) (((uint64_t)us) * 1000000L)
-#define SLEEP_MIN(us) (((uint64_t)us) * 60L * 1000000L)
-#define SLEEP_HR(us) (((uint64_t)us) * 60L * 60L * 1000000L)
-
-#define AXP_ADDR 0X34
-
-#define PowerOff(x) SetSleep(x)
-
-class AXP192 {
-public:
-
- enum CHGCurrent{
- kCHG_100mA = 0,
- kCHG_190mA,
- kCHG_280mA,
- kCHG_360mA,
- kCHG_450mA,
- kCHG_550mA,
- kCHG_630mA,
- kCHG_700mA,
- kCHG_780mA,
- kCHG_880mA,
- kCHG_960mA,
- kCHG_1000mA,
- kCHG_1080mA,
- kCHG_1160mA,
- kCHG_1240mA,
- kCHG_1320mA,
- };
-
- AXP192();
- void begin(void);
- void ScreenBreath(uint8_t brightness);
- bool GetBatState();
-
- void EnableCoulombcounter(void);
- void DisableCoulombcounter(void);
- void StopCoulombcounter(void);
- void ClearCoulombcounter(void);
- uint32_t GetCoulombchargeData(void);
- uint32_t GetCoulombdischargeData(void);
- float GetCoulombData(void);
- void PowerOff(void);
- void SetAdcState(bool state);
- // -- sleep
- void PrepareToSleep(void);
- void RestoreFromLightSleep(void);
- void DeepSleep(uint64_t time_in_us = 0);
- void LightSleep(uint64_t time_in_us = 0);
- uint8_t GetWarningLeve(void);
-
-public:
- // void SetChargeVoltage( uint8_t );
- // void SetChargeCurrent( uint8_t );
- float GetBatVoltage();
- float GetBatCurrent();
- float GetVinVoltage();
- float GetVinCurrent();
- float GetVBusVoltage();
- float GetVBusCurrent();
- float GetTempInAXP192();
- float GetBatPower();
- float GetBatChargeCurrent();
- float GetAPSVoltage();
- float GetBatCoulombInput();
- float GetBatCoulombOut();
- uint8_t GetWarningLevel(void);
- void SetCoulombClear();
- void SetLDO2( bool State );
- void SetDCDC3( bool State );
-
- uint8_t AXPInState();
- bool isACIN();
- bool isCharging();
- bool isVBUS();
-
- void SetLDOVoltage(uint8_t number , uint16_t voltage);
- void SetDCVoltage(uint8_t number , uint16_t voltage);
- void SetESPVoltage(uint16_t voltage);
- void SetLcdVoltage(uint16_t voltage);
- void SetLDOEnable( uint8_t number ,bool state );
- void SetLCDRSet( bool state );
- void SetBusPowerMode( uint8_t state );
- void SetLed(uint8_t state);
- void SetSpkEnable(uint8_t state);
- void SetCHGCurrent(uint8_t state);
-
-private:
- void Write1Byte( uint8_t Addr , uint8_t Data );
- uint8_t Read8bit( uint8_t Addr );
- uint16_t Read12Bit( uint8_t Addr);
- uint16_t Read13Bit( uint8_t Addr);
- uint16_t Read16bit( uint8_t Addr );
- uint32_t Read24bit( uint8_t Addr );
- uint32_t Read32bit( uint8_t Addr );
- void ReadBuff( uint8_t Addr , uint8_t Size , uint8_t *Buff );
-};
-
-#endif
diff --git a/lib/libesp32/CORE2_Library/BM8563_RTC.cpp b/lib/libesp32/CORE2_Library/BM8563_RTC.cpp
deleted file mode 100755
index f17262d29..000000000
--- a/lib/libesp32/CORE2_Library/BM8563_RTC.cpp
+++ /dev/null
@@ -1,353 +0,0 @@
-#include "BM8563_RTC.h"
-
-BM8563_RTC::BM8563_RTC()
-{
-}
-
-void BM8563_RTC::begin(void)
-{
- Wire1.begin(21, 22);
- WriteReg(0x00,0x00);
- WriteReg(0x01,0x00);
- WriteReg(0x0D,0x00);
-}
-
-void BM8563_RTC::WriteReg(uint8_t reg, uint8_t data)
-{
- Wire1.beginTransmission(RTC_ADRESS);
- Wire1.write(reg);
- Wire1.write(data);
- Wire1.endTransmission();
-}
-
-uint8_t BM8563_RTC::ReadReg(uint8_t reg)
-{
- Wire1.beginTransmission(0x51);
- Wire1.write(reg);
- Wire1.endTransmission();
- Wire1.requestFrom(0x51, 1);
- return Wire1.read();
-}
-
-void BM8563_RTC::GetBm8563Time(void)
-{
- Wire1.beginTransmission(0x51);
- Wire1.write(0x02);
- Wire1.endTransmission();
- Wire1.requestFrom(0x51, 7);
- while (Wire1.available())
- {
-
- trdata[0] = Wire1.read();
- trdata[1] = Wire1.read();
- trdata[2] = Wire1.read();
- trdata[3] = Wire1.read();
- trdata[4] = Wire1.read();
- trdata[5] = Wire1.read();
- trdata[6] = Wire1.read();
- }
-
- DataMask();
- Bcd2asc();
- Str2Time();
-}
-
-void BM8563_RTC::Str2Time(void)
-{
-
- Second = (asc[0] - 0x30) * 10 + asc[1] - 0x30;
- Minute = (asc[2] - 0x30) * 10 + asc[3] - 0x30;
- Hour = (asc[4] - 0x30) * 10 + asc[5] - 0x30;
- /*
- uint8_t Hour;
- uint8_t Week;
- uint8_t Day;
- uint8_t Month;
- uint8_t Year;
- */
-}
-
-void BM8563_RTC::DataMask()
-{
-
- trdata[0] = trdata[0] & 0x7f; //秒
- trdata[1] = trdata[1] & 0x7f; //分
- trdata[2] = trdata[2] & 0x3f; //时
-
- trdata[3] = trdata[3] & 0x3f; //日
- trdata[4] = trdata[4] & 0x07; //星期
- trdata[5] = trdata[5] & 0x1f; //月
-
- trdata[6] = trdata[6] & 0xff; //年
-}
-/********************************************************************
-函 数 名: void Bcd2asc(void)
-功 能: bcd 码转换成 asc 码,供Lcd显示用
-说 明:
-调 用:
-入口参数:
-返 回 值:无
-***********************************************************************/
-void BM8563_RTC::Bcd2asc(void)
-{
- uint8_t i, j;
- for (j = 0, i = 0; i < 7; i++)
- {
- asc[j++] = (trdata[i] & 0xf0) >> 4 | 0x30; /*格式为: 秒 分 时 日 月 星期 年 */
- asc[j++] = (trdata[i] & 0x0f) | 0x30;
- }
-}
-
-uint8_t BM8563_RTC::Bcd2ToByte(uint8_t Value)
-{
- uint8_t tmp = 0;
- tmp = ((uint8_t)(Value & (uint8_t)0xF0) >> (uint8_t)0x4) * 10;
- return (tmp + (Value & (uint8_t)0x0F));
-}
-
-uint8_t BM8563_RTC::ByteToBcd2(uint8_t Value)
-{
- uint8_t bcdhigh = 0;
-
- while (Value >= 10)
- {
- bcdhigh++;
- Value -= 10;
- }
-
- return ((uint8_t)(bcdhigh << 4) | Value);
-}
-
-void BM8563_RTC::GetTime(RTC_TimeTypeDef *RTC_TimeStruct)
-{
-
- //if()
- uint8_t buf[3] = {0};
-
- Wire1.beginTransmission(0x51);
- Wire1.write(0x02);
- Wire1.endTransmission();
- Wire1.requestFrom(0x51, 3);
-
- while (Wire1.available())
- {
-
- buf[0] = Wire1.read();
- buf[1] = Wire1.read();
- buf[2] = Wire1.read();
- }
-
- RTC_TimeStruct->Seconds = Bcd2ToByte(buf[0] & 0x7f); //秒
- RTC_TimeStruct->Minutes = Bcd2ToByte(buf[1] & 0x7f); //分
- RTC_TimeStruct->Hours = Bcd2ToByte(buf[2] & 0x3f); //时
-}
-
-void BM8563_RTC::SetTime(RTC_TimeTypeDef *RTC_TimeStruct)
-{
-
- if (RTC_TimeStruct == NULL)
- return;
-
- Wire1.beginTransmission(0x51);
- Wire1.write(0x02);
- Wire1.write(ByteToBcd2(RTC_TimeStruct->Seconds));
- Wire1.write(ByteToBcd2(RTC_TimeStruct->Minutes));
- Wire1.write(ByteToBcd2(RTC_TimeStruct->Hours));
- Wire1.endTransmission();
-}
-
-void BM8563_RTC::GetDate(RTC_DateTypeDef *RTC_DateStruct)
-{
-
- uint8_t buf[4] = {0};
-
- Wire1.beginTransmission(0x51);
- Wire1.write(0x05);
- Wire1.endTransmission();
- Wire1.requestFrom(0x51, 4);
-
- while (Wire1.available())
- {
-
- buf[0] = Wire1.read();
- buf[1] = Wire1.read();
- buf[2] = Wire1.read();
- buf[3] = Wire1.read();
- }
-
- RTC_DateStruct->Date = Bcd2ToByte(buf[0] & 0x3f);
- RTC_DateStruct->WeekDay = Bcd2ToByte(buf[1] & 0x07);
- RTC_DateStruct->Month = Bcd2ToByte(buf[2] & 0x1f);
-
- if (buf[2] & 0x80)
- {
- RTC_DateStruct->Year = 1900 + Bcd2ToByte(buf[3] & 0xff);
- }
- else
- {
- RTC_DateStruct->Year = 2000 + Bcd2ToByte(buf[3] & 0xff);
- }
-}
-
-void BM8563_RTC::SetDate(RTC_DateTypeDef *RTC_DateStruct)
-{
-
- if (RTC_DateStruct == NULL)
- return;
- Wire1.beginTransmission(0x51);
- Wire1.write(0x05);
- Wire1.write(ByteToBcd2(RTC_DateStruct->Date));
- Wire1.write(ByteToBcd2(RTC_DateStruct->WeekDay));
-
- if (RTC_DateStruct->Year < 2000)
- {
-
- Wire1.write(ByteToBcd2(RTC_DateStruct->Month) | 0x80);
- Wire1.write(ByteToBcd2((uint8_t)(RTC_DateStruct->Year % 100)));
- }
- else
- {
- /* code */
- Wire1.write(ByteToBcd2(RTC_DateStruct->Month) | 0x00);
- Wire1.write(ByteToBcd2((uint8_t)(RTC_DateStruct->Year % 100)));
- }
-
- Wire1.endTransmission();
-}
-
-int BM8563_RTC::SetAlarmIRQ(int afterSeconds)
-{
- uint8_t reg_value = 0;
- reg_value = ReadReg(0x01);
-
- if (afterSeconds < 0)
- {
- reg_value &= ~(1 << 0);
- WriteReg(0x01, reg_value);
- reg_value = 0x03;
- WriteReg(0x0E, reg_value);
- return -1;
- }
-
- uint8_t type_value = 2;
- uint8_t div = 1;
- if (afterSeconds > 255)
- {
- div = 60;
- type_value = 0x83;
- }
- else
- {
- type_value = 0x82;
- }
-
- afterSeconds = (afterSeconds / div) & 0xFF;
- WriteReg(0x0F, afterSeconds);
- WriteReg(0x0E, type_value);
-
- reg_value |= (1 << 0);
- reg_value &= ~(1 << 7);
- WriteReg(0x01, reg_value);
- return afterSeconds * div;
-}
-
-int BM8563_RTC::SetAlarmIRQ(const RTC_TimeTypeDef &RTC_TimeStruct)
-{
- uint8_t irq_enable = false;
- uint8_t out_buf[4] = {0x80, 0x80, 0x80, 0x80};
-
- if (RTC_TimeStruct.Minutes >= 0)
- {
- irq_enable = true;
- out_buf[0] = ByteToBcd2(RTC_TimeStruct.Minutes) & 0x7f;
- }
-
- if (RTC_TimeStruct.Hours >= 0)
- {
- irq_enable = true;
- out_buf[1] = ByteToBcd2(RTC_TimeStruct.Hours) & 0x3f;
- }
-
- //out_buf[2] = 0x00;
- //out_buf[3] = 0x00;
-
- uint8_t reg_value = ReadReg(0x01);
-
- if (irq_enable)
- {
- reg_value |= (1 << 1);
- }
- else
- {
- reg_value &= ~(1 << 1);
- }
-
- for (int i = 0; i < 4; i++)
- {
- WriteReg(0x09 + i, out_buf[i]);
- }
- WriteReg(0x01, reg_value);
-
- return irq_enable ? 1 : 0;
-}
-
-int BM8563_RTC::SetAlarmIRQ(const RTC_DateTypeDef &RTC_DateStruct, const RTC_TimeTypeDef &RTC_TimeStruct)
-{
- uint8_t irq_enable = false;
- uint8_t out_buf[4] = {0x80, 0x80, 0x80, 0x80};
-
- if (RTC_TimeStruct.Minutes >= 0)
- {
- irq_enable = true;
- out_buf[0] = ByteToBcd2(RTC_TimeStruct.Minutes) & 0x7f;
- }
-
- if (RTC_TimeStruct.Hours >= 0)
- {
- irq_enable = true;
- out_buf[1] = ByteToBcd2(RTC_TimeStruct.Hours) & 0x3f;
- }
-
- if (RTC_DateStruct.Date >= 0)
- {
- irq_enable = true;
- out_buf[2] = ByteToBcd2(RTC_DateStruct.Date) & 0x3f;
- }
-
- if (RTC_DateStruct.WeekDay >= 0)
- {
- irq_enable = true;
- out_buf[3] = ByteToBcd2(RTC_DateStruct.WeekDay) & 0x07;
- }
-
- uint8_t reg_value = ReadReg(0x01);
-
- if (irq_enable)
- {
- reg_value |= (1 << 1);
- }
- else
- {
- reg_value &= ~(1 << 1);
- }
-
- for (int i = 0; i < 4; i++)
- {
- WriteReg(0x09 + i, out_buf[i]);
- }
- WriteReg(0x01, reg_value);
-
- return irq_enable ? 1 : 0;
-}
-
-void BM8563_RTC::clearIRQ()
-{
- uint8_t data = ReadReg(0x01);
- WriteReg(0x01, data & 0xf3);
-}
-void BM8563_RTC::disableIRQ()
-{
- clearIRQ();
- uint8_t data = ReadReg(0x01);
- WriteReg(0x01, data & 0xfC);
-}
diff --git a/lib/libesp32/CORE2_Library/BM8563_RTC.h b/lib/libesp32/CORE2_Library/BM8563_RTC.h
deleted file mode 100755
index 84c6e0b37..000000000
--- a/lib/libesp32/CORE2_Library/BM8563_RTC.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef __RTC_H__
-#define __RTC_H__
-
-#include
-
-#define RTC_ADRESS 0x51
-
-typedef struct
-{
- uint8_t Hours;
- uint8_t Minutes;
- uint8_t Seconds;
-}RTC_TimeTypeDef;
-
-
-typedef struct
-{
- uint8_t WeekDay;
- uint8_t Month;
- uint8_t Date;
- uint16_t Year;
-}RTC_DateTypeDef;
-
-class BM8563_RTC {
-public:
- BM8563_RTC();
-
- void begin(void);
- void GetBm8563Time(void);
-
- void SetTime(RTC_TimeTypeDef* RTC_TimeStruct);
- void SetDate(RTC_DateTypeDef* RTC_DateStruct);
-
- void GetTime(RTC_TimeTypeDef* RTC_TimeStruct);
- void GetDate(RTC_DateTypeDef* RTC_DateStruct);
-
- int SetAlarmIRQ(int afterSeconds);
- int SetAlarmIRQ( const RTC_TimeTypeDef &RTC_TimeStruct);
- int SetAlarmIRQ( const RTC_DateTypeDef &RTC_DateStruct, const RTC_TimeTypeDef &RTC_TimeStruct);
-
- void clearIRQ();
- void disableIRQ();
-
-public:
- uint8_t Second;
- uint8_t Minute;
- uint8_t Hour;
- uint8_t Week;
- uint8_t Day;
- uint8_t Month;
- uint8_t Year;
- uint8_t DateString[9];
- uint8_t TimeString[9];
-
- uint8_t asc[14];
-
-
-private:
- void Bcd2asc(void);
- void DataMask();
- void Str2Time(void);
- void WriteReg(uint8_t reg, uint8_t data);
- uint8_t ReadReg(uint8_t reg);
- uint8_t Bcd2ToByte(uint8_t Value);
- uint8_t ByteToBcd2(uint8_t Value);
-
-private:
-
- /*定义数组用来存储读取的时间数据 */
- uint8_t trdata[7];
- /*定义数组用来存储转换的 asc 码时间数据*/
- //uint8_t asc[14];
-
-};
-
-#endif
diff --git a/lib/libesp32/CORE2_Library/library.json b/lib/libesp32/CORE2_Library/library.json
deleted file mode 100644
index e3ac982c5..000000000
--- a/lib/libesp32/CORE2_Library/library.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "M5 Stack Core2 library",
- "keywords": "esp32, sensor, mqtt, m2m, iot",
- "description": "M5 Stack Core2 library",
- "version": "1.0",
- "frameworks": "arduino",
- "platforms": "espressif32"
-}
diff --git a/lib/libesp32/CORE2_Library/library.properties b/lib/libesp32/CORE2_Library/library.properties
deleted file mode 100644
index e3b36fc67..000000000
--- a/lib/libesp32/CORE2_Library/library.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-name=M5 Stack Core2 library
-version=1.0
-author=Gerhard Mutz
-maintainer=Gerhard Mutz
-sentence=Allows Tasmota to use Core2
-paragraph=Allows Tasmota to Core2 for esp32
-category=ESP32
-url=
-architectures=esp32