From 0a757b6bebac02b68b4200e295582d30be95c9cf Mon Sep 17 00:00:00 2001
From: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Date: Wed, 14 Apr 2021 19:42:13 +0200
Subject: [PATCH 01/19] Update platformio_override_sample.ini
---
platformio_override_sample.ini | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/platformio_override_sample.ini b/platformio_override_sample.ini
index 9821e2e97..a9bbf6e96 100644
--- a/platformio_override_sample.ini
+++ b/platformio_override_sample.ini
@@ -185,15 +185,15 @@ lib_ignore =
Micro-RTSP
ESP32 Ethernet
-; *** EXPERIMENTAL Tasmota version for Arduino ESP32 IDF4.4. Linking not working.
-[env:tasmota32idf4]
+; *** EXPERIMENTAL Tasmota version for Arduino ESP32-C3
+[env:tasmota32c3]
extends = env:tasmota32_base
platform = https://github.com/Jason2866/platform-espressif32.git#feature/arduino-idf-v4.4
-platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/arduino-esp32/releases/download/esp32-2.0.0-pre/esp32-2.0.0-pre.zip
+platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/v.2.0.0.pre/framework-arduinoespressif32-c3-1cb31e509.tar.gz
platformio/tool-mklittlefs @ ~1.203.200522
build_unflags = ${esp32_defaults.build_unflags}
build_flags = ${esp32_defaults.build_flags}
- ;-DESP32_STAGE=true
+ -DESP32_STAGE=true
; *** Debug version used for PlatformIO Home Project Inspection
[env:tasmota-debug]
From 32a15182bed658ea940b2d7b69ea3a01eba963f2 Mon Sep 17 00:00:00 2001
From: Adrian Scillato <35405447+ascillato@users.noreply.github.com>
Date: Wed, 14 Apr 2021 15:05:13 -0300
Subject: [PATCH 02/19] KNX: Fix Power and Energy missing replies
---
tasmota/xdrv_11_knx.ino | 60 ++++++++++++++++-------------------------
1 file changed, 23 insertions(+), 37 deletions(-)
diff --git a/tasmota/xdrv_11_knx.ino b/tasmota/xdrv_11_knx.ino
index 037f22b73..8ad133474 100644
--- a/tasmota/xdrv_11_knx.ino
+++ b/tasmota/xdrv_11_knx.ino
@@ -645,74 +645,60 @@ void KNX_CB_Action(message_t const &msg, void *arg)
}
}
else if (chan->type == KNX_ENERGY_VOLTAGE) // Reply KNX_ENERGY_VOLTAGE
- {
- if (Energy.data_valid[0]) {
+ {
+ knx.answer_4byte_float(msg.received_on, Energy.voltage[0]);
+ if (Settings.flag.knx_enable_enhancement) {
+ knx.answer_4byte_float(msg.received_on, Energy.voltage[0]);
knx.answer_4byte_float(msg.received_on, Energy.voltage[0]);
- if (Settings.flag.knx_enable_enhancement) {
- knx.answer_4byte_float(msg.received_on, Energy.voltage[0]);
- knx.answer_4byte_float(msg.received_on, Energy.voltage[0]);
- }
}
}
else if (chan->type == KNX_ENERGY_CURRENT) // Reply KNX_ENERGY_CURRENT
{
- if (Energy.data_valid[0]) {
+ knx.answer_4byte_float(msg.received_on, Energy.current[0]);
+ if (Settings.flag.knx_enable_enhancement) {
+ knx.answer_4byte_float(msg.received_on, Energy.current[0]);
knx.answer_4byte_float(msg.received_on, Energy.current[0]);
- if (Settings.flag.knx_enable_enhancement) {
- knx.answer_4byte_float(msg.received_on, Energy.current[0]);
- knx.answer_4byte_float(msg.received_on, Energy.current[0]);
- }
}
}
else if (chan->type == KNX_ENERGY_POWER) // Reply KNX_ENERGY_POWER
{
- if (Energy.data_valid[0]) {
+ knx.answer_4byte_float(msg.received_on, Energy.active_power[0]);
+ if (Settings.flag.knx_enable_enhancement) {
+ knx.answer_4byte_float(msg.received_on, Energy.active_power[0]);
knx.answer_4byte_float(msg.received_on, Energy.active_power[0]);
- if (Settings.flag.knx_enable_enhancement) {
- knx.answer_4byte_float(msg.received_on, Energy.active_power[0]);
- knx.answer_4byte_float(msg.received_on, Energy.active_power[0]);
- }
}
}
else if (chan->type == KNX_ENERGY_POWERFACTOR) // Reply KNX_ENERGY_POWERFACTOR
{
- if (Energy.data_valid[0]) {
+ knx.answer_4byte_float(msg.received_on, Energy.power_factor[0]);
+ if (Settings.flag.knx_enable_enhancement) {
+ knx.answer_4byte_float(msg.received_on, Energy.power_factor[0]);
knx.answer_4byte_float(msg.received_on, Energy.power_factor[0]);
- if (Settings.flag.knx_enable_enhancement) {
- knx.answer_4byte_float(msg.received_on, Energy.power_factor[0]);
- knx.answer_4byte_float(msg.received_on, Energy.power_factor[0]);
- }
}
}
else if (chan->type == KNX_ENERGY_YESTERDAY) // Reply KNX_ENERGY_YESTERDAY
{
- if (Energy.data_valid[0]) {
- float energy_kWhyesterday = (float)Settings.energy_kWhyesterday / 100000;
+ float energy_kWhyesterday = (float)Settings.energy_kWhyesterday / 100000;
+ knx.answer_4byte_float(msg.received_on, energy_kWhyesterday);
+ if (Settings.flag.knx_enable_enhancement) {
+ knx.answer_4byte_float(msg.received_on, energy_kWhyesterday);
knx.answer_4byte_float(msg.received_on, energy_kWhyesterday);
- if (Settings.flag.knx_enable_enhancement) {
- knx.answer_4byte_float(msg.received_on, energy_kWhyesterday);
- knx.answer_4byte_float(msg.received_on, energy_kWhyesterday);
- }
}
}
else if (chan->type == KNX_ENERGY_DAILY) // Reply KNX_ENERGY_DAILY
{
- if (Energy.data_valid[0]) {
+ knx.answer_4byte_float(msg.received_on, Energy.daily);
+ if (Settings.flag.knx_enable_enhancement) {
+ knx.answer_4byte_float(msg.received_on, Energy.daily);
knx.answer_4byte_float(msg.received_on, Energy.daily);
- if (Settings.flag.knx_enable_enhancement) {
- knx.answer_4byte_float(msg.received_on, Energy.daily);
- knx.answer_4byte_float(msg.received_on, Energy.daily);
- }
}
}
else if (chan->type == KNX_ENERGY_TOTAL) // Reply KNX_ENERGY_TOTAL
{
- if (Energy.data_valid[0]) {
+ knx.answer_4byte_float(msg.received_on, Energy.total);
+ if (Settings.flag.knx_enable_enhancement) {
+ knx.answer_4byte_float(msg.received_on, Energy.total);
knx.answer_4byte_float(msg.received_on, Energy.total);
- if (Settings.flag.knx_enable_enhancement) {
- knx.answer_4byte_float(msg.received_on, Energy.total);
- knx.answer_4byte_float(msg.received_on, Energy.total);
- }
}
}
#ifdef USE_RULES
From dee80134321b946b6f1d427689d89e14c90ad749 Mon Sep 17 00:00:00 2001
From: Sthope <6695214+Sthopeless@users.noreply.github.com>
Date: Thu, 15 Apr 2021 09:20:46 +0200
Subject: [PATCH 03/19] Update xdrv_79_esp32_ble.ino
Write without response
---
tasmota/xdrv_79_esp32_ble.ino | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tasmota/xdrv_79_esp32_ble.ino b/tasmota/xdrv_79_esp32_ble.ino
index 31b16ceb9..5fabfe5cc 100644
--- a/tasmota/xdrv_79_esp32_ble.ino
+++ b/tasmota/xdrv_79_esp32_ble.ino
@@ -2004,7 +2004,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
}
}
if (op->writelen){
- if(pCharacteristic->canWrite()) {
+ if(pCharacteristic->canWrite() || pCharacteristic->canWriteNoResponse() ) {
if (!pCharacteristic->writeValue(op->dataToWrite, op->writelen, true)){
newstate = GEN_STATE_FAILED_WRITE;
#ifdef BLE_ESP32_DEBUG
From e12d56914b51c6e017d0a2e38c9f00be6080b780 Mon Sep 17 00:00:00 2001
From: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Date: Thu, 15 Apr 2021 14:16:39 +0200
Subject: [PATCH 04/19] Update de_DE.h
---
tasmota/language/de_DE.h | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/tasmota/language/de_DE.h b/tasmota/language/de_DE.h
index 2625ceaf2..5e57ebff9 100644
--- a/tasmota/language/de_DE.h
+++ b/tasmota/language/de_DE.h
@@ -28,7 +28,7 @@
* Use online command StateText to translate ON, OFF, HOLD and TOGGLE.
* Use online command Prefix to translate cmnd, stat and tele.
*
- * Updated until v9.3.1.2
+ * Updated until v9.3.1.3
\*********************************************************************/
//#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English)
@@ -84,7 +84,7 @@
#define D_DISABLED "deaktiviert"
#define D_DISTANCE "Abstand"
#define D_DNS_SERVER "DNS-Server"
-#define D_DO "Disolved Oxygen"
+#define D_DO "gelöster Sauerstoff"
#define D_DONE "erledigt"
#define D_DST_TIME "DST"
#define D_EC "EC"
@@ -109,7 +109,7 @@
#define D_GATEWAY "Gateway"
#define D_GROUP "Gruppe"
#define D_HOST "Host"
-#define D_HALL_EFFECT "Hall Effect"
+#define D_HALL_EFFECT "Hall Effekt"
#define D_HOSTNAME "Hostname"
#define D_HUMIDITY "Feuchtigkeit"
#define D_ILLUMINANCE "Beleuchtungsstärke"
@@ -291,18 +291,18 @@
#define D_WPA_PSK "WPA-PSK"
#define D_WPA2_PSK "WPA2-PSK"
#define D_AP1_SSID "WLAN 1 - SSID"
-#define D_AP1_SSID_HELP "Type or Select your WiFi Network"
+#define D_AP1_SSID_HELP "WiFi Netzwerk auswählen oder eingeben"
#define D_AP2_SSID "WLAN 2 - SSID"
-#define D_AP2_SSID_HELP "Type your Alternative WiFi Network"
+#define D_AP2_SSID_HELP "alternatives WiFi Netzwerk eingeben"
#define D_AP_PASSWORD "WLAN - Passwort"
-#define D_AP_PASSWORD_HELP "Enter your WiFi Password"
-#define D_SELECT_YOUR_WIFI_NETWORK "Select your WiFi Network"
-#define D_SHOW_MORE_WIFI_NETWORKS "Scan for all WiFi Networks"
-#define D_SHOW_MORE_OPTIONS "More Options"
-#define D_CHECK_CREDENTIALS "Please, check your credentials"
-#define D_SUCCESSFUL_WIFI_CONNECTION "Successful WiFi Connection"
-#define D_NOW_YOU_CAN_CLOSE_THIS_WINDOW "Now you can close this window"
-#define D_REDIRECTING_TO_NEW_IP "Redirecting to new device's IP address"
+#define D_AP_PASSWORD_HELP "WiFi Passwort eingeben"
+#define D_SELECT_YOUR_WIFI_NETWORK "WiFi Netzwerk auswählen"
+#define D_SHOW_MORE_WIFI_NETWORKS "Suche nach WiFi Netzwerken"
+#define D_SHOW_MORE_OPTIONS "Mehr Optionen"
+#define D_CHECK_CREDENTIALS "Bitte SSID/Passwort überprüfen"
+#define D_SUCCESSFUL_WIFI_CONNECTION "mit Wifi verbunden"
+#define D_NOW_YOU_CAN_CLOSE_THIS_WINDOW "das Fenster kann geschlossen werden"
+#define D_REDIRECTING_TO_NEW_IP "Umleitung zur neuen Geräte IP-Addresse"
#define D_MQTT_PARAMETERS "MQTT-Einstellungen"
#define D_CLIENT "client"
@@ -335,14 +335,14 @@
#define D_TEMPLATE_PARAMETERS "Vorlage Parameter"
#define D_TEMPLATE_NAME "Name"
#define D_BASE_TYPE "basiert auf"
-#define D_TEMPLATE_FLAGS "Options"
+#define D_TEMPLATE_FLAGS "Optionen"
#define D_SAVE_CONFIGURATION "Konfiguration speichern"
#define D_CONFIGURATION_SAVED "Konfiguration gespeichert"
#define D_CONFIGURATION_RESET "Konfiguration zurücksetzen"
#define D_PROGRAM_VERSION "Tasmota Version"
-#define D_BUILD_DATE_AND_TIME "Build-Datum & -Uhrzeit"
+#define D_BUILD_DATE_AND_TIME "Erstellungs-Datum & -Uhrzeit"
#define D_CORE_AND_SDK_VERSION "Core-/SDK-Version"
#define D_FLASH_WRITE_COUNT "Anz. Flash-Schreibzyklen"
#define D_MAC_ADDRESS "MAC-Adresse"
@@ -521,7 +521,7 @@
#define D_SENSORS_FOUND "Sensor gefunden"
// xsns_06_dht.ino
-#define D_TIMEOUT_WAITING_FOR "Timeout während Warten auf"
+#define D_TIMEOUT_WAITING_FOR "Zeitüberschreitung während Warten auf"
#define D_START_SIGNAL_LOW "Startausschlag niedrig"
#define D_START_SIGNAL_HIGH "Startausschlag hoch"
#define D_PULSE "Puls"
From b35672c7e88b2c95f9ca77e13d5218f7a4c8ed95 Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Thu, 15 Apr 2021 15:32:39 +0200
Subject: [PATCH 05/19] Fix M5Core2 binary settings
---
tasmota/tasmota_configurations_ESP32.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tasmota/tasmota_configurations_ESP32.h b/tasmota/tasmota_configurations_ESP32.h
index 13f2ad269..f9182196d 100644
--- a/tasmota/tasmota_configurations_ESP32.h
+++ b/tasmota/tasmota_configurations_ESP32.h
@@ -104,7 +104,7 @@
#define USE_MPU6886
#define USE_SPI
#define USE_DISPLAY
- #define USE_DISPLAY_ILI9342
+ #define USE_DISPLAY_ILI9341
#define JPEG_PICTS
#define USE_FT5206
#define USE_TOUCH_BUTTONS
@@ -112,7 +112,7 @@
#define USE_SENDMAIL
#define USE_ESP32MAIL
-//#define USE_SCRIPT // Add support for script (+17k code)
+#define USE_SCRIPT // Add support for script (+17k code)
// Script related defines
#ifdef USE_SCRIPT
#undef USE_RULES
From db5edc8cb9bc5979664130d486a5e55c790e4f8a Mon Sep 17 00:00:00 2001
From: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Date: Thu, 15 Apr 2021 16:08:39 +0200
Subject: [PATCH 06/19] Add GUI_EDIT_FILE
as default for ESP32 build variants (except webcam)
---
tasmota/tasmota_configurations_ESP32.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tasmota/tasmota_configurations_ESP32.h b/tasmota/tasmota_configurations_ESP32.h
index f9182196d..20723fd69 100644
--- a/tasmota/tasmota_configurations_ESP32.h
+++ b/tasmota/tasmota_configurations_ESP32.h
@@ -60,6 +60,7 @@
#define USE_UFILESYS
#define USE_SDCARD
#define GUI_TRASH_FILE
+ #define GUI_EDIT_FILE
#ifdef USE_BERRY // Berry scripting language
#define USE_BERRY_PSRAM // Allocate Berry memory in PSRAM if PSRAM is connected - this might be slightly slower but leaves main memory intact
@@ -94,6 +95,7 @@
#define USE_UFILESYS
#define USE_SDCARD
#define GUI_TRASH_FILE
+ #define GUI_EDIT_FILE
#ifdef USE_BERRY // Berry scripting language
#define USE_BERRY_PSRAM // Allocate Berry memory in PSRAM if PSRAM is connected - this might be slightly slower but leaves main memory intact
@@ -150,6 +152,8 @@
#define USE_UFILESYS
#define USE_SDCARD
#define GUI_TRASH_FILE
+ #define GUI_EDIT_FILE
+
#define USE_ADC
#undef USE_BERRY // Disable Berry scripting language
#define USE_BLE_ESP32 // Enable new BLE driver
@@ -165,6 +169,11 @@
#define USE_ENHANCED_GUI_WIFI_SCAN
+#define USE_UFILESYS
+#define USE_SDCARD
+ #define GUI_TRASH_FILE
+ #define GUI_EDIT_FILE
+
#define ROTARY_V1 // Add support for Rotary Encoder as used in MI Desk Lamp
#define USE_TUYA_MCU // Add support for Tuya Serial MCU
From 571649a082562ba31229782a6e7821a1b2ca236e Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Thu, 15 Apr 2021 17:21:18 +0200
Subject: [PATCH 07/19] Tasmotize M5Core2 support
---
tasmota/i18n.h | 4 +-
tasmota/xdrv_01_webserver.ino | 8 +
tasmota/xdrv_10_scripter.ino | 2 +-
tasmota/xdrv_42_i2s_audio.ino | 4 +-
tasmota/xdrv_84_esp32_core2.ino | 429 ++++++++++++++++----------------
tasmota/xdsp_04_ili9341.ino | 8 +-
tasmota/xdsp_17_universal.ino | 8 +-
7 files changed, 238 insertions(+), 225 deletions(-)
diff --git a/tasmota/i18n.h b/tasmota/i18n.h
index c435348a8..e3cc2cf8a 100644
--- a/tasmota/i18n.h
+++ b/tasmota/i18n.h
@@ -814,7 +814,9 @@ const float kSpeedConversionFactor[] = {1, // none
// xdrv_02_webserver.ino
#ifdef USE_WEBSERVER
// {s} =
, {m} = | , {e} = |
-const char HTTP_SNS_F_TEMP[] PROGMEM = "{s}%s " D_TEMPERATURE "{m}%*_f " D_UNIT_DEGREE "%c{e}";
+const char HTTP_SNS_F_TEMP[] PROGMEM = "{s}%s " D_TEMPERATURE "{m}%*_f " D_UNIT_DEGREE "%c{e}";
+const char HTTP_SNS_F_VOLTAGE[] PROGMEM = "{s}%s " D_VOLTAGE "{m}%*_f " D_UNIT_VOLT "{e}";
+const char HTTP_SNS_F_CURRENT_MA[] PROGMEM = "{s}%s " D_CURRENT "{m}%*_f " D_UNIT_MILLIAMPERE "{e}";
const char HTTP_SNS_HUM[] PROGMEM = "{s}%s " D_HUMIDITY "{m}%s " D_UNIT_PERCENT "{e}";
const char HTTP_SNS_DEW[] PROGMEM = "{s}%s " D_DEWPOINT "{m}%s " D_UNIT_DEGREE "%c{e}";
const char HTTP_SNS_PRESSURE[] PROGMEM = "{s}%s " D_PRESSURE "{m}%s " "%s{e}";
diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino
index 8cac58e71..5b97d04db 100644
--- a/tasmota/xdrv_01_webserver.ino
+++ b/tasmota/xdrv_01_webserver.ino
@@ -840,6 +840,14 @@ void WSContentSend_Temp(const char *types, float f_temperature) {
WSContentSend_PD(HTTP_SNS_F_TEMP, types, Settings.flag2.temperature_resolution, &f_temperature, TempUnit());
}
+void WSContentSend_Voltage(const char *types, float f_voltage) {
+ WSContentSend_PD(HTTP_SNS_F_VOLTAGE, types, Settings.flag2.voltage_resolution, &f_voltage);
+}
+
+void WSContentSend_CurrentMA(const char *types, float f_current) {
+ WSContentSend_PD(HTTP_SNS_F_CURRENT_MA, types, Settings.flag2.current_resolution, &f_current);
+}
+
void WSContentSend_THD(const char *types, float f_temperature, float f_humidity)
{
WSContentSend_Temp(types, f_temperature);
diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino
index 5e920afba..c3097fc64 100755
--- a/tasmota/xdrv_10_scripter.ino
+++ b/tasmota/xdrv_10_scripter.ino
@@ -1845,7 +1845,7 @@ chknext:
while (*lp==' ') lp++;
float fvar1;
lp = GetNumericArgument(lp, OPER_EQU, &fvar1, gv);
- fvar = core2_setaxppin(fvar, fvar1);
+ fvar = Core2SetAxpPin(fvar, fvar1);
lp++;
len=0;
goto exit;
diff --git a/tasmota/xdrv_42_i2s_audio.ino b/tasmota/xdrv_42_i2s_audio.ino
index a63918206..1ab15e4ee 100644
--- a/tasmota/xdrv_42_i2s_audio.ino
+++ b/tasmota/xdrv_42_i2s_audio.ino
@@ -69,8 +69,8 @@
#ifdef USE_M5STACK_CORE2
#undef AUDIO_PWR_ON
#undef AUDIO_PWR_OFF
-#define AUDIO_PWR_ON CORE2_audio_power(true);
-#define AUDIO_PWR_OFF CORE2_audio_power(false);
+#define AUDIO_PWR_ON Core2AudioPower(true);
+#define AUDIO_PWR_OFF Core2AudioPower(false);
#undef DAC_IIS_BCK
#undef DAC_IIS_WS
#undef DAC_IIS_DOUT
diff --git a/tasmota/xdrv_84_esp32_core2.ino b/tasmota/xdrv_84_esp32_core2.ino
index 9f0d3cc60..fd7f4acbd 100644
--- a/tasmota/xdrv_84_esp32_core2.ino
+++ b/tasmota/xdrv_84_esp32_core2.ino
@@ -17,15 +17,28 @@
along with this program. If not, see .
*/
-/* remaining work:
-
-i2s microphone as loudness sensor
-rtc better sync
-
-*/
-
#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
@@ -36,8 +49,6 @@ rtc better sync
#include
#include
-#define XDRV_84 84
-
struct CORE2_globs {
AXP192 Axp;
BM8563_RTC Rtc;
@@ -57,116 +68,9 @@ struct CORE2_ADC {
float temp;
} core2_adc;
-// cause SC card is needed by scripter
-void CORE2_Module_Init(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 CORE2_Init(void) {
-
- if (Rtc.utc_time < START_VALID_TIME) {
- // set rtc from chip
- Rtc.utc_time = Get_utc();
-
- 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("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 CORE2_audio_power(bool power) {
- core2_globs.Axp.SetSpkEnable(power);
-}
-
-#ifdef USE_WEBSERVER
-const char HTTP_CORE2[] PROGMEM =
- "{s}VBUS Voltage" "{m}%s V" "{e}"
- "{s}VBUS Current" "{m}%s mA" "{e}"
- "{s}BATT Voltage" "{m}%s V" "{e}"
- "{s}BATT Current" "{m}%s mA" "{e}"
- "{s}Chip Temperature" "{m}%s C" "{e}";
-#endif // USE_WEBSERVER
-
-
-void CORE2_loop(uint32_t flg) {
-
-}
-
-void CORE2_WebShow(uint32_t json) {
-
- char vstring[32];
- char bvstring[32];
- char cstring[32];
- char bcstring[32];
- char tstring[32];
- dtostrfd(core2_adc.vbus_v, 3, vstring);
- dtostrfd(core2_adc.batt_v, 3, bvstring);
- dtostrfd(core2_adc.vbus_c, 1, cstring);
- dtostrfd(core2_adc.batt_c, 1, bcstring);
- dtostrfd(core2_adc.temp, 2, tstring);
-
- if (json) {
- ResponseAppend_P(PSTR(",\"CORE2\":{\"VBV\":%s,\"BV\":%s,\"VBC\":%s,\"BC\":%s,\"CT\":%s}"), vstring, cstring, bvstring, bcstring, tstring);
- } else {
- WSContentSend_PD(HTTP_CORE2, vstring, cstring, bvstring, bcstring, tstring);
- }
-}
-
-const char CORE2_Commands[] PROGMEM = "CORE2|"
- "SHUTDOWN";
-
-void (* const CORE2_Command[])(void) PROGMEM = {
- &CORE2_Shutdown};
-
-
-void CORE2_Shutdown(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:%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);
- }
-
-}
-
-void CORE2_DoShutdown(void) {
+void Core2DoShutdown(void) {
SettingsSaveAll();
RtcSettingsSave();
core2_globs.Rtc.clearIRQ();
@@ -182,11 +86,75 @@ void CORE2_DoShutdown(void) {
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 core2_setaxppin(uint32_t sel, uint32_t val) {
+float Core2SetAxpPin(uint32_t sel, uint32_t val) {
switch (sel) {
case 0:
core2_globs.Axp.SetLed(val);
@@ -215,91 +183,91 @@ float core2_setaxppin(uint32_t sel, uint32_t val) {
}
break;
default:
- GetRtc();
+ Core2GetRtc();
break;
}
return 0;
}
-void core2_disp_pwr(uint8_t on) {
+/*********************************************************************************************\
+ * 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 core2_disp_dim(uint8_t dim) {
-uint16_t voltage = 2200;
+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 GetRtc(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("RTC: %02d:%02d:%02d"), RTCtime.Hours, RTCtime.Minutes, RTCtime.Seconds);
- AddLog(LOG_LEVEL_INFO, PSTR("RTC: %02d.%02d.%04d"), RTCdate.Date, RTCdate.Month, RTCdate.Year);
-
-}
-
-void Set_utc(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 Get_utc(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);
-}
-
-void CORE2_EverySecond(void) {
+void Core2EverySecond(void) {
if (core2_globs.ready) {
- CORE2_GetADC();
+ Core2GetADC();
- if (Rtc.utc_time > START_VALID_TIME && core2_globs.tset==false && abs(Rtc.utc_time - Get_utc()) > 3) {
- Set_utc(Rtc.utc_time);
- AddLog(LOG_LEVEL_INFO, PSTR("Write Time TO BM8563 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
+ if (Rtc.utc_time > START_VALID_TIME && core2_globs.tset==false && abs(Rtc.utc_time - 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;
}
@@ -307,19 +275,56 @@ void CORE2_EverySecond(void) {
if (core2_globs.shutdowndelay) {
core2_globs.shutdowndelay--;
if (!core2_globs.shutdowndelay) {
- CORE2_DoShutdown();
+ Core2DoShutdown();
}
}
}
}
-void CORE2_GetADC(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();
+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);
+ }
+}
- core2_adc.temp = core2_globs.Axp.GetTempInAXP192();
+/*********************************************************************************************\
+ * 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);
+ }
}
/*********************************************************************************************\
@@ -330,31 +335,29 @@ bool Xdrv84(uint8_t function) {
bool result = false;
switch (function) {
-
- case FUNC_WEB_SENSOR:
-#ifdef USE_WEBSERVER
- CORE2_WebShow(0);
-#endif
- break;
- case FUNC_JSON_APPEND:
- CORE2_WebShow(1);
- break;
- case FUNC_COMMAND:
- result = DecodeCommand(CORE2_Commands, CORE2_Command);
- break;
- case FUNC_MODULE_INIT:
- CORE2_Module_Init();
- break;
- case FUNC_INIT:
- CORE2_Init();
+ case FUNC_LOOP:
+ Core2Loop(1);
break;
case FUNC_EVERY_SECOND:
- CORE2_EverySecond();
+ Core2EverySecond();
break;
- case FUNC_LOOP:
- CORE2_loop(1);
+ 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;
}
diff --git a/tasmota/xdsp_04_ili9341.ino b/tasmota/xdsp_04_ili9341.ino
index 60b2dd646..b38a18eee 100644
--- a/tasmota/xdsp_04_ili9341.ino
+++ b/tasmota/xdsp_04_ili9341.ino
@@ -136,18 +136,18 @@ void ILI9341_InitDriver()
}
-void core2_disp_pwr(uint8_t on);
-void core2_disp_dim(uint8_t dim);
+void Core2DisplayPower(uint8_t on);
+void Core2DisplayDim(uint8_t dim);
void ili9342_bpwr(uint8_t on) {
#ifdef USE_M5STACK_CORE2
- core2_disp_pwr(on);
+ Core2DisplayPower(on);
#endif
}
void ili9342_dimm(uint8_t dim) {
#ifdef USE_M5STACK_CORE2
- core2_disp_dim(dim);
+ Core2DisplayDim(dim);
#endif
}
diff --git a/tasmota/xdsp_17_universal.ino b/tasmota/xdsp_17_universal.ino
index 9ae3eeeb4..419a94d12 100644
--- a/tasmota/xdsp_17_universal.ino
+++ b/tasmota/xdsp_17_universal.ino
@@ -260,18 +260,18 @@ char *fbuff;
/*********************************************************************************************/
-void core2_disp_pwr(uint8_t on);
-void core2_disp_dim(uint8_t dim);
+void Core2DisplayPower(uint8_t on);
+void Core2DisplayDim(uint8_t dim);
void udisp_bpwr(uint8_t on) {
#ifdef USE_M5STACK_CORE2
- core2_disp_pwr(on);
+ Core2DisplayPower(on);
#endif
}
void udisp_dimm(uint8_t dim) {
#ifdef USE_M5STACK_CORE2
- core2_disp_dim(dim);
+ Core2DisplayDim(dim);
#endif
}
From 9851c26781165982d8522a520e6a8121a12ce2a5 Mon Sep 17 00:00:00 2001
From: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Date: Thu, 15 Apr 2021 20:21:51 +0200
Subject: [PATCH 08/19] Fix for #11680
Using file from https://github.com/arendst/Tasmota/issues/11680#issuecomment-818844390
---
tasmota/xsns_53_sml.ino | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/tasmota/xsns_53_sml.ino b/tasmota/xsns_53_sml.ino
index c29cd29a5..5288e2dc3 100755
--- a/tasmota/xsns_53_sml.ino
+++ b/tasmota/xsns_53_sml.ino
@@ -1915,14 +1915,14 @@ void SML_Immediate_MQTT(const char *mp,uint8_t index,uint8_t mindex) {
// web + json interface
void SML_Show(boolean json) {
- int8_t count,mindex,cindex=0;
+ int8_t count, mindex, cindex = 0;
char tpowstr[32];
char name[24];
char unit[8];
char jname[24];
int8_t index=0,mid=0;
char *mp=(char*)meter_p;
- char *cp,nojson=0;
+ char *cp, nojson = 0;
//char b_mqtt_data[MESSZ];
//b_mqtt_data[0]=0;
@@ -1937,9 +1937,9 @@ void SML_Show(boolean json) {
if (mindex<0 || mindex>=meters_used) mindex=0;
if (meter_desc_p[mindex].prefix[0]=='*' && meter_desc_p[mindex].prefix[1]==0) {
- nojson=1;
+ nojson = 1;
} else {
- nojson=0;
+ nojson = 0;
}
mp+=2;
if (*mp=='=' && *(mp+1)=='h') {
@@ -2032,27 +2032,35 @@ void SML_Show(boolean json) {
}
if (json) {
- if (!dvalid[index]) {
- nojson = 1;
+ //if (dvalid[index]) {
+
//AddLog(LOG_LEVEL_INFO, PSTR("not yet valid line %d"), index);
- }
+ //}
// json export
if (index==0) {
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s,\"%s\":{\"%s\":%s", b_mqtt_data,meter_desc_p[mindex].prefix,jname,tpowstr);
- if (!nojson) ResponseAppend_P(PSTR(",\"%s\":{\"%s\":%s"),meter_desc_p[mindex].prefix,jname,tpowstr);
+ if (!nojson) {
+ ResponseAppend_P(PSTR(",\"%s\":{\"%s\":%s"),meter_desc_p[mindex].prefix,jname,tpowstr);
+ }
}
else {
if (lastmind!=mindex) {
// meter changed, close mqtt
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s}", b_mqtt_data);
- if (!nojson) ResponseAppend_P(PSTR("}"));
+ if (!nojson) {
+ ResponseAppend_P(PSTR("}"));
+ }
// and open new
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s,\"%s\":{\"%s\":%s", b_mqtt_data,meter_desc_p[mindex].prefix,jname,tpowstr);
- if (!nojson) ResponseAppend_P(PSTR(",\"%s\":{\"%s\":%s"),meter_desc_p[mindex].prefix,jname,tpowstr);
+ if (!nojson) {
+ ResponseAppend_P(PSTR(",\"%s\":{\"%s\":%s"),meter_desc_p[mindex].prefix,jname,tpowstr);
+ }
lastmind=mindex;
} else {
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s,\"%s\":%s", b_mqtt_data,jname,tpowstr);
- if (!nojson) ResponseAppend_P(PSTR(",\"%s\":%s"),jname,tpowstr);
+ if (!nojson) {
+ ResponseAppend_P(PSTR(",\"%s\":%s"),jname,tpowstr);
+ }
}
}
@@ -2073,7 +2081,9 @@ void SML_Show(boolean json) {
if (json) {
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s}", b_mqtt_data);
//ResponseAppend_P(PSTR("%s"),b_mqtt_data);
- if (!nojson) ResponseAppend_P(PSTR("}"));
+ if (!nojson) {
+ ResponseAppend_P(PSTR("}"));
+ }
} else {
//WSContentSend_PD(PSTR("%s"),b_mqtt_data);
}
From 2ff5de0b2fba7f44a4decb20054f0e2087d61ce9 Mon Sep 17 00:00:00 2001
From: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Date: Fri, 16 Apr 2021 11:25:49 +0200
Subject: [PATCH 09/19] Change SPIFFS partions
---
esp32_partition_app1856k_spiffs320k.csv | 6 ++++++
esp32_partition_app2944k_spiffs10M.csv | 6 ++++++
platformio_tasmota32.ini | 2 +-
platformio_tasmota_env32.ini | 4 ++--
.../Odroid_go_and_core2/Core2_flash_10M.bat | 1 +
.../{Core2_flash.bat => Core2_flash_12M.bat} | 0
.../Odroid_go_and_core2/Odroid_flash_10M.bat | 1 +
.../{Odroid_flash.bat => Odroid_flash_12M.bat} | 0
.../partitions_spiffs_10M.bin | Bin 0 -> 3072 bytes
9 files changed, 17 insertions(+), 3 deletions(-)
create mode 100644 esp32_partition_app1856k_spiffs320k.csv
create mode 100644 esp32_partition_app2944k_spiffs10M.csv
create mode 100644 tools/Esptool/Odroid_go_and_core2/Core2_flash_10M.bat
rename tools/Esptool/Odroid_go_and_core2/{Core2_flash.bat => Core2_flash_12M.bat} (100%)
create mode 100644 tools/Esptool/Odroid_go_and_core2/Odroid_flash_10M.bat
rename tools/Esptool/Odroid_go_and_core2/{Odroid_flash.bat => Odroid_flash_12M.bat} (100%)
create mode 100644 tools/Esptool/Odroid_go_and_core2/partitions_spiffs_10M.bin
diff --git a/esp32_partition_app1856k_spiffs320k.csv b/esp32_partition_app1856k_spiffs320k.csv
new file mode 100644
index 000000000..09659603f
--- /dev/null
+++ b/esp32_partition_app1856k_spiffs320k.csv
@@ -0,0 +1,6 @@
+# Name, Type, SubType, Offset, Size, Flags
+nvs, data, nvs, 0x9000, 0x5000,
+otadata, data, ota, 0xe000, 0x2000,
+app0, app, ota_0, 0x10000, 0x1D0000,
+app1, app, ota_1, 0x1E0000, 0x1D0000,
+spiffs, data, spiffs, 0x3B0000,0x50000,
diff --git a/esp32_partition_app2944k_spiffs10M.csv b/esp32_partition_app2944k_spiffs10M.csv
new file mode 100644
index 000000000..f87b84a9c
--- /dev/null
+++ b/esp32_partition_app2944k_spiffs10M.csv
@@ -0,0 +1,6 @@
+# Name, Type, SubType, Offset, Size, Flags
+nvs, data, nvs, 0x9000, 0x5000,
+otadata, data, ota, 0xe000, 0x2000,
+app0, app, ota_0, 0x10000, 0x2F0000,
+app1, app, ota_1, 0x300000, 0x2F0000,
+spiffs, data, spiffs, 0x5F0000,0xA10000,
diff --git a/platformio_tasmota32.ini b/platformio_tasmota32.ini
index abf1d0199..3a8c42192 100644
--- a/platformio_tasmota32.ini
+++ b/platformio_tasmota32.ini
@@ -10,7 +10,7 @@ board = esp32dev
board_build.filesystem = ${common.board_build.filesystem}
custom_unpack_dir = ${common.custom_unpack_dir}
board_build.ldscript = esp32_out.ld
-board_build.partitions = esp32_partition_app1984k_spiffs64k.csv
+board_build.partitions = esp32_partition_app1856k_spiffs320k.csv
board_build.flash_mode = ${common.board_build.flash_mode}
board_build.f_flash = ${common.board_build.f_flash}
board_build.f_cpu = ${common.board_build.f_cpu}
diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini
index f0b85e60b..54722290c 100644
--- a/platformio_tasmota_env32.ini
+++ b/platformio_tasmota_env32.ini
@@ -50,7 +50,7 @@ board_build.f_cpu = 240000000L
board_build.flash_mode = qio
board_build.f_flash = 80000000L
upload_speed = 2000000
-board_build.partitions = esp32_partition_app1984k_spiffs12M.csv
+board_build.partitions = esp32_partition_app2944k_spiffs10M.csv
build_flags = ${common32.build_flags} -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -lc-psram-workaround -lm-psram-workaround -DFIRMWARE_ODROID_GO
lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_i2c, lib/lib_rf, lib/lib_div, lib/lib_ssl, lib/lib_display
@@ -61,7 +61,7 @@ board_build.f_cpu = 240000000L
board_build.flash_mode = qio
board_build.f_flash = 80000000L
upload_speed = 2000000
-board_build.partitions = esp32_partition_app1984k_spiffs12M.csv
+board_build.partitions = esp32_partition_app2944k_spiffs10M.csv
build_flags = ${common32.build_flags} -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -lc-psram-workaround -lm-psram-workaround -DFIRMWARE_M5STACK_CORE2
lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_i2c, lib/lib_rf, lib/lib_div, lib/lib_ssl, lib/lib_display, lib/lib_audio
diff --git a/tools/Esptool/Odroid_go_and_core2/Core2_flash_10M.bat b/tools/Esptool/Odroid_go_and_core2/Core2_flash_10M.bat
new file mode 100644
index 000000000..7f978acb2
--- /dev/null
+++ b/tools/Esptool/Odroid_go_and_core2/Core2_flash_10M.bat
@@ -0,0 +1 @@
+esptool.py --chip esp32 --baud 2000000 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0x1000 bootloader_qio_80m.bin 0x8000 partitions_spiffs_10M.bin 0xe000 boot_app0.bin 0x10000 tasmota32-core2.bin
diff --git a/tools/Esptool/Odroid_go_and_core2/Core2_flash.bat b/tools/Esptool/Odroid_go_and_core2/Core2_flash_12M.bat
similarity index 100%
rename from tools/Esptool/Odroid_go_and_core2/Core2_flash.bat
rename to tools/Esptool/Odroid_go_and_core2/Core2_flash_12M.bat
diff --git a/tools/Esptool/Odroid_go_and_core2/Odroid_flash_10M.bat b/tools/Esptool/Odroid_go_and_core2/Odroid_flash_10M.bat
new file mode 100644
index 000000000..fde9850e0
--- /dev/null
+++ b/tools/Esptool/Odroid_go_and_core2/Odroid_flash_10M.bat
@@ -0,0 +1 @@
+esptool.py --chip esp32 --baud 2000000 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0x1000 bootloader_qio_80m.bin 0x8000 partitions_spiffs_10M.bin 0xe000 boot_app0.bin 0x10000 tasmota32-odroid.bin
diff --git a/tools/Esptool/Odroid_go_and_core2/Odroid_flash.bat b/tools/Esptool/Odroid_go_and_core2/Odroid_flash_12M.bat
similarity index 100%
rename from tools/Esptool/Odroid_go_and_core2/Odroid_flash.bat
rename to tools/Esptool/Odroid_go_and_core2/Odroid_flash_12M.bat
diff --git a/tools/Esptool/Odroid_go_and_core2/partitions_spiffs_10M.bin b/tools/Esptool/Odroid_go_and_core2/partitions_spiffs_10M.bin
new file mode 100644
index 0000000000000000000000000000000000000000..08781f13a1eb77b9c5bdeea885dcbd80c2236418
GIT binary patch
literal 3072
zcmZ1#z{tcffq{V`fPo>etQg2Z1*-xW85kY_#S|DA@=Fp^5=#cs$tM)
zNGvEYK#>G;fbxP23?N~!ydkDMV-o{IJWzNcLvcZ7S{j-YUcdg20
Date: Fri, 16 Apr 2021 11:40:38 +0200
Subject: [PATCH 10/19] Redesigned GUI
Redesigned GUI by moving non-configuration buttons from ``Configuration`` to new submenu ``Consoles``
---
CHANGELOG.md | 1 +
RELEASENOTES.md | 1 +
tasmota/tasmota.h | 2 +-
tasmota/tasmota_configurations_ESP32.h | 1 +
tasmota/xdrv_01_webserver.ino | 63 +++++++++++++++++++++-----
tasmota/xdrv_10_scripter.ino | 10 ++--
tasmota/xdrv_50_filesystem.ino | 8 +++-
tasmota/xdrv_52_9_berry.ino | 12 +++--
8 files changed, 77 insertions(+), 21 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 41ec5a960..7b5b9e848 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
- In tasmota-sensors.bin enabled support for VL53L0X and disabled TSL2561 (#11711)
- Add HLW8012/BL0937 average pulse calculation by Alex Lovett (#11722)
- Redesigned initial GUI wifi configuration by Adrian Scillato (#11693)
+- Redesigned GUI by moving non-configuration buttons from ``Configuration`` to new submenu ``Consoles``
### Fixed
- Telegram chat id incorrect size (#11660)
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 921800545..4a7ba03a6 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -120,6 +120,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
- ADC range result from int to float using command ``FreqRes`` for decimal resolution selection [#11545](https://github.com/arendst/Tasmota/issues/11545)
- Removed overtemp detection on external energy monitoring devices [#11628](https://github.com/arendst/Tasmota/issues/11628)
- Redesigned initial GUI wifi configuration by Adrian Scillato [#11693](https://github.com/arendst/Tasmota/issues/11693)
+- Redesigned GUI by moving non-configuration buttons from ``Configuration`` to new submenu ``Consoles``
- In tasmota-sensors.bin enabled support for VL53L0X and disabled TSL2561 [#11711](https://github.com/arendst/Tasmota/issues/11711)
- Add HLW8012/BL0937 average pulse calculation by Alex Lovett [#11722](https://github.com/arendst/Tasmota/issues/11722)
diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h
index c9d58fd05..bd8c392ee 100644
--- a/tasmota/tasmota.h
+++ b/tasmota/tasmota.h
@@ -310,7 +310,7 @@ enum XsnsFunctions {FUNC_SETTINGS_OVERRIDE, FUNC_PIN_STATE, FUNC_MODULE_INIT, FU
FUNC_SET_POWER, FUNC_SET_DEVICE_POWER, FUNC_SHOW_SENSOR, FUNC_ANY_KEY,
FUNC_ENERGY_EVERY_SECOND, FUNC_ENERGY_RESET,
FUNC_RULES_PROCESS, FUNC_SERIAL, FUNC_FREE_MEM, FUNC_BUTTON_PRESSED,
- FUNC_WEB_ADD_BUTTON, FUNC_WEB_ADD_MANAGEMENT_BUTTON, FUNC_WEB_ADD_MAIN_BUTTON,
+ FUNC_WEB_ADD_BUTTON, FUNC_WEB_ADD_CONSOLE_BUTTON, FUNC_WEB_ADD_MANAGEMENT_BUTTON, FUNC_WEB_ADD_MAIN_BUTTON,
FUNC_WEB_ADD_HANDLER, FUNC_SET_CHANNELS, FUNC_SET_SCHEME, FUNC_HOTPLUG_SCAN,
FUNC_DEVICE_GROUP_ITEM };
diff --git a/tasmota/tasmota_configurations_ESP32.h b/tasmota/tasmota_configurations_ESP32.h
index 20723fd69..daa2b43f8 100644
--- a/tasmota/tasmota_configurations_ESP32.h
+++ b/tasmota/tasmota_configurations_ESP32.h
@@ -128,6 +128,7 @@
#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
diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino
index 5b97d04db..f18cc0b4b 100644
--- a/tasmota/xdrv_01_webserver.ino
+++ b/tasmota/xdrv_01_webserver.ino
@@ -361,16 +361,19 @@ const char HTTP_DEVICE_STATE[] PROGMEM = "" D_FILE ":
"
- ""
+ ""
+ "";
#endif // #ifdef GUI_EDIT_FILE
@@ -905,7 +905,6 @@ void UfsUploadFileClose(void) {
ufs_upload_file.close();
}
-
//******************************************************************************************
// File Editor
//******************************************************************************************
@@ -917,45 +916,44 @@ void UfsEditor(void) {
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor GET"));
- String fname;
+ char fname_input[UFS_FILENAME_SIZE];
if (Webserver->hasArg(F("file"))) {
- fname = Webserver->arg(F("file"));
+ WebGetArg(PSTR("file"), fname_input, sizeof(fname_input));
+ } else {
+ snprintf_P(fname_input, sizeof(fname_input), PSTR(D_NEW_FILE));
}
- else {
- fname = D_NEW_FILE;
- }
- if (fname[0] != '/') fname = "/" +fname;
+ char fname[UFS_FILENAME_SIZE];
+ UfsFilename(fname, fname_input); // Trim spaces and add slash
- AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file=%s, ffs_type=%d, TfsFileExist=%d"), fname.c_str(), ffs_type, TfsFileExists(fname.c_str()));
+ AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file=%s, ffs_type=%d, TfsFileExist=%d"), fname, ffs_type, TfsFileExists(fname));
WSContentStart_P(PSTR(D_EDIT_FILE));
WSContentSendStyle();
- WSContentSend_P(HTTP_EDITOR_FORM_START, fname.c_str());
+ char *bfname = fname +1;
+ WSContentSend_P(HTTP_EDITOR_FORM_START, bfname); // Skip leading slash
- if (ffs_type && TfsFileExists(fname.c_str())) {
- File fp = ffsp->open(fname.c_str(), "r");
+ if (ffs_type && TfsFileExists(fname)) {
+ File fp = ffsp->open(fname, "r");
if (!fp) {
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file open failed"));
WSContentSend_P(D_NEW_FILE);
+ } else {
+ uint8_t *buf = (uint8_t*)malloc(FILE_BUFFER_SIZE+1);
+ size_t filelen = fp.size();
+ AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file len=%d"), filelen);
+ while (filelen > 0) {
+ size_t l = fp.read(buf, FILE_BUFFER_SIZE);
+ AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UFS: UfsEditor: read=%d"), l);
+ if (l < 0) { break; }
+ buf[l] = '\0';
+ WSContentSend_P((const char*)buf);
+ filelen -= l;
+ }
+ fp.close();
+ free(buf);
+ AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: read done"));
}
- else {
- uint8_t *buf = (uint8_t*)malloc(FILE_BUFFER_SIZE+1);
- size_t filelen = fp.size();
- AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file len=%d"), filelen);
- while ( filelen > 0 ) {
- size_t l = fp.read(buf, FILE_BUFFER_SIZE);
- AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UFS: UfsEditor: read=%d"), l);
- if (l < 0) break;
- buf[l] = '\0';
- WSContentSend_P((const char*)buf);
- filelen -= l;
- }
- fp.close();
- free(buf);
- AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: read done"));
- }
- }
- else {
+ } else {
WSContentSend_P(D_NEW_FILE);
}
@@ -974,8 +972,12 @@ void UfsEditorUpload(void) {
WSSend(400, CT_PLAIN, F("400: Bad request - no filename"));
return;
}
- String name = Webserver->arg("name");
- AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file '%s'"), name.c_str());
+
+ char fname_input[UFS_FILENAME_SIZE];
+ WebGetArg(PSTR("name"), fname_input, sizeof(fname_input));
+ char fname[UFS_FILENAME_SIZE];
+ UfsFilename(fname, fname_input); // Trim spaces and add slash
+ AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file '%s'"), fname);
if (!Webserver->hasArg("content")) {
AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: file upload - no content"));
@@ -991,10 +993,10 @@ void UfsEditorUpload(void) {
return;
}
- File fp = ffsp->open(name.c_str(), "w");
- if(!fp) {
+ File fp = ffsp->open(fname, "w");
+ if (!fp) {
Web.upload_error = 1;
- AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: 400: invalid file name '%s'"), name.c_str());
+ AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: 400: invalid file name '%s'"), fname);
WSSend(400, CT_PLAIN, F("400: bad request - invalid filename"));
return;
}
@@ -1005,7 +1007,7 @@ void UfsEditorUpload(void) {
}
if (!fp.print(content)) {
- AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: write error on '%s'"), name.c_str());
+ AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: write error on '%s'"), fname);
}
fp.close();
@@ -1014,7 +1016,7 @@ void UfsEditorUpload(void) {
Webserver->send(303);
}
-#endif // #ifdef GUI_EDIT_FILE
+#endif // GUI_EDIT_FILE
#endif // USE_WEBSERVER
|