+#else
const char HTTP_FORM_CMND[] PROGMEM =
"
"
"
";
+#endif // USE_CONSOLE_CSS_FLEX
const char HTTP_TABLE100[] PROGMEM =
"
";
@@ -3117,7 +3136,11 @@ void HandleConsole(void)
WSContentStart_P(PSTR(D_CONSOLE));
WSContentSend_P(HTTP_SCRIPT_CONSOL, Settings->web_refresh);
+#ifdef USE_CONSOLE_CSS_FLEX
+ WSContentSendStyle_P(HTTP_CMND_STYLE);
+#else
WSContentSendStyle();
+#endif // USE_CONSOLE_CSS_FLEX
WSContentSend_P(HTTP_FORM_CMND);
WSContentSpaceButton((WebUseManagementSubmenu()) ? BUTTON_MANAGEMENT : BUTTON_MAIN);
WSContentStop();
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_04_light.ino b/tasmota/tasmota_xdrv_driver/xdrv_04_light.ino
index f4b27dd101c3..6599fde21d2e 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_04_light.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_04_light.ino
@@ -2080,7 +2080,7 @@ bool LightApplyFade(void) { // did the value chanegd and needs to be applied
Light.fade_duration = LightGetSpeedSetting() * 500;
Light.speed_once_enabled = false; // The once off speed value has been read, reset it
if (!Settings->flag5.fade_fixed_duration) {
- Light.fade_duration = (distance * Light.fade_duration) / 1023; // time is proportional to distance, except with SO117
+ Light.fade_duration = (distance * Light.fade_duration) / 1023 + 1 /* make sure value is not zero */; // time is proportional to distance, except with SO117
}
if (Settings->save_data) {
// Also postpone the save_data for the duration of the Fade (in seconds)
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino b/tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino
index 54922adf9695..a91c48b0fa46 100755
--- a/tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino
@@ -5379,10 +5379,10 @@ extern char *SML_GetSVal(uint32_t index);
glob_script_mem.spi.settings = SPISettings(fvar, MSBFIRST, SPI_MODE0);
if (TasmotaGlobal.spi_enabled) {
-#ifdef EPS8266
+#ifdef ESP8266
SPI.begin();
glob_script_mem.spi.spip = &SPI;
-#endif // EPS8266
+#endif // ESP8266
#ifdef ESP32
if (glob_script_mem.spi.sclk == -1) {
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_5_2_converters.ino b/tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_5_2_converters.ino
index 6c682450c1e4..67929f7582e9 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_5_2_converters.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_5_2_converters.ino
@@ -1214,6 +1214,8 @@ void ZCLFrame::syntheticAqaraSensor(Z_attribute_list &attr_list, class Z_attribu
attr_list.addAttribute(0x0001, 0x0020).setFloat(batteryvoltage);
uint8_t batterypercentage = toPercentageCR2032(uval32);
attr_list.addAttribute(0x0001, 0x0021).setUInt(batterypercentage * 2);
+ } else if (0x03 == attrid) {
+ attr_list.addAttributePMEM("AqaraTemperature").copyVal(attr); // Temperature
} else if ((nullptr != modelId) && ((0 == getManufCode()) || (0x115F == getManufCode()))) {
translated = true;
if (modelId.startsWith(F("lumi.sensor_magnet"))) { // door / window sensor
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino b/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino
index f09370ed69cf..538e11fe492f 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino
@@ -460,8 +460,6 @@ void ShutterRtc50mS(void)
int32_t ShutterPercentToRealPosition(int16_t percent, uint32_t index)
{
- // if inverted recalculate the percentposition
- percent = (ShutterSettings.shutter_options[index] & 1) ? 100 - percent : percent;
if (ShutterSettings.shutter_set50percent[index] != 50) {
return (percent <= 5) ? ShutterSettings.shuttercoeff[2][index] * percent*10 : (ShutterSettings.shuttercoeff[1][index] * percent + (ShutterSettings.shuttercoeff[0][index]*10))*10;
} else {
@@ -523,9 +521,8 @@ uint8_t ShutterRealToPercentPosition(int32_t realpos, uint32_t index)
}
}
}
- realpercent = realpercent < 0 ? 0 : realpercent;
- // if inverted recalculate the percentposition
- return (ShutterSettings.shutter_options[index] & 1) ? 100 - realpercent : realpercent;
+ realpercent = realpercent < 0 ? 0 : realpercent;
+ return realpercent;
}
void ShutterInit(void)
@@ -1268,7 +1265,8 @@ bool ShutterButtonHandler(void)
// handle on button release: start shutter on shortpress and stop running shutter after longpress.
if (NOT_PRESSED == button
&& Shutter[shutter_index].direction != 0 // only act on shutters activly moving
- && Button.hold_timer[button_index] > 0) // kick in on first release of botton. do not check for multipress
+ && Button.hold_timer[button_index] > 0 // kick in on first release of botton. do not check for multipress
+ && !ShutterSettings.shutter_button[button_index].position[3].mqtt_broadcast ) // do not stop on hold release if broadcast
{
XdrvMailbox.index = shutter_index +1;
XdrvMailbox.payload = -99; // reset any payload to invalid
@@ -1321,7 +1319,7 @@ void ShutterToggle(bool dir)
void ShutterShow(){
for (uint32_t i = 0; i < TasmotaGlobal.shutters_present; i++) {
- WSContentSend_P(HTTP_MSG_SLIDER_SHUTTER, (ShutterSettings.shutter_options[i] & 1) ? D_OPEN : D_CLOSE,(ShutterSettings.shutter_options[i] & 1) ? D_CLOSE : D_OPEN, ShutterRealToPercentPosition(-9999, i), i+1);
+ WSContentSend_P(HTTP_MSG_SLIDER_SHUTTER, (Settings->shutter_options[i] & 1) ? D_OPEN : D_CLOSE,(Settings->shutter_options[i] & 1) ? D_CLOSE : D_OPEN, (Settings->shutter_options[i] & 1) ? (100 - ShutterRealToPercentPosition(-9999, i)) : ShutterRealToPercentPosition(-9999, i), i+1);
}
}
/*********************************************************************************************\
@@ -1516,8 +1514,11 @@ void CmndShutterPosition(void)
}
int8_t target_pos_percent = (XdrvMailbox.payload < 0) ? (XdrvMailbox.payload == -99 ? ShutterRealToPercentPosition(Shutter[index].real_position, index) : 0) : ((XdrvMailbox.payload > 100) ? 100 : XdrvMailbox.payload);
- // webgui still send also on inverted shutter the native position.
- target_pos_percent = ((ShutterSettings.shutter_options[index] & 1) && (SRC_WEBGUI == TasmotaGlobal.last_source)) ? 100 - target_pos_percent : target_pos_percent;
+ target_pos_percent = ((Settings->shutter_options[index] & 1) && ((SRC_MQTT != TasmotaGlobal.last_source)
+ || (SRC_SERIAL != TasmotaGlobal.last_source)
+ || (SRC_WEBCOMMAND != TasmotaGlobal.last_source)
+ )) ? 100 - target_pos_percent : target_pos_percent;
+
if (XdrvMailbox.payload != -99) {
Shutter[index].target_position = ShutterPercentToRealPosition(target_pos_percent, index);
//Shutter[i].accelerator[index] = ShutterGlobal.open_velocity_max / ((Shutter[i].motordelay[index] > 0) ? Shutter[i].motordelay[index] : 1);
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino b/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino
index f6fe28a40807..c5255c5637fd 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino
@@ -252,8 +252,6 @@ void ShutterRtc50mS(void)
int32_t ShutterPercentToRealPosition(int16_t percent, uint32_t index)
{
- // if inverted recalculate the percentposition
- percent = (Settings->shutter_options[index] & 1) ? 100 - percent : percent;
if (Settings->shutter_set50percent[index] != 50) {
return (percent <= 5) ? Settings->shuttercoeff[2][index] * percent*10 : (Settings->shuttercoeff[1][index] * percent + (Settings->shuttercoeff[0][index]*10))*10;
} else {
@@ -315,9 +313,8 @@ uint8_t ShutterRealToPercentPosition(int32_t realpos, uint32_t index)
}
}
}
- realpercent = realpercent < 0 ? 0 : realpercent;
- // if inverted recalculate the percentposition
- return (Settings->shutter_options[index] & 1) ? 100 - realpercent : realpercent;
+ realpercent = realpercent < 0 ? 0 : realpercent;
+ return realpercent;
}
void ShutterInit(void)
@@ -950,7 +947,11 @@ bool ShutterButtonHandler(void)
if (NOT_PRESSED == button) {
//AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d, Button %d, hold %d, dir %d, index %d, payload %d"), shutter_index+1, button_index+1, Button.hold_timer[button_index],Shutter[shutter_index].direction,XdrvMailbox.index,XdrvMailbox.payload);
- if (Shutter[shutter_index].direction && (Button.hold_timer[button_index] > 0 && (!Settings->flag.button_single || Button.hold_timer[button_index] > 20))) {
+ if (Shutter[shutter_index].direction
+ && (Button.hold_timer[button_index] > 0
+ && (!Settings->flag.button_single
+ || Button.hold_timer[button_index] > 20))
+ && !(Settings->shutter_button[button_index] & (0x01<<29))) {
XdrvMailbox.index = shutter_index +1;
XdrvMailbox.payload = XdrvMailbox.index;
//AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d, Button %d, hold %d, dir %d, index %d, payload %d"), shutter_index+1, button_index+1, Button.hold_timer[button_index],Shutter[shutter_index].direction,XdrvMailbox.index,XdrvMailbox.payload);
@@ -1144,7 +1145,7 @@ void ShutterToggle(bool dir)
void ShutterShow(){
for (uint32_t i = 0; i < TasmotaGlobal.shutters_present; i++) {
- WSContentSend_P(HTTP_MSG_SLIDER_SHUTTER, (Settings->shutter_options[i] & 1) ? D_OPEN : D_CLOSE,(Settings->shutter_options[i] & 1) ? D_CLOSE : D_OPEN, ShutterRealToPercentPosition(-9999, i), i+1);
+ WSContentSend_P(HTTP_MSG_SLIDER_SHUTTER, (Settings->shutter_options[i] & 1) ? D_OPEN : D_CLOSE,(Settings->shutter_options[i] & 1) ? D_CLOSE : D_OPEN, (Settings->shutter_options[i] & 1) ? (100 - ShutterRealToPercentPosition(-9999, i)) : ShutterRealToPercentPosition(-9999, i), i+1);
}
}
@@ -1338,8 +1339,10 @@ void CmndShutterPosition(void)
}
int8_t target_pos_percent = (XdrvMailbox.payload < 0) ? (XdrvMailbox.payload == -99 ? ShutterRealToPercentPosition(Shutter[index].real_position, index) : 0) : ((XdrvMailbox.payload > 100) ? 100 : XdrvMailbox.payload);
- // webgui still send also on inverted shutter the native position.
- target_pos_percent = ((Settings->shutter_options[index] & 1) && (SRC_WEBGUI != TasmotaGlobal.last_source)) ? 100 - target_pos_percent : target_pos_percent;
+ target_pos_percent = ((Settings->shutter_options[index] & 1) && ((SRC_MQTT != TasmotaGlobal.last_source)
+ || (SRC_SERIAL != TasmotaGlobal.last_source)
+ || (SRC_WEBCOMMAND != TasmotaGlobal.last_source)
+ )) ? 100 - target_pos_percent : target_pos_percent;
if (XdrvMailbox.payload != -99) {
//target_pos_percent = (Settings->shutter_options[index] & 1) ? 100 - target_pos_percent : target_pos_percent;
Shutter[index].target_position = ShutterPercentToRealPosition(target_pos_percent, index);
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino b/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino
index ee99a4f801ff..dfc54172e0de 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino
@@ -183,9 +183,9 @@ void UfsCheckSDCardInit(void) {
if (TasmotaGlobal.spi_enabled && PinUsed(GPIO_SDCARD_CS)) {
int8_t cs = Pin(GPIO_SDCARD_CS);
-#ifdef EPS8266
+#ifdef ESP8266
SPI.begin();
-#endif // EPS8266
+#endif // ESP8266
#ifdef ESP32
SPI.begin(Pin(GPIO_SPI_CLK), Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_MOSI), -1);
#endif // ESP32
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_flash.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_flash.ino
index ca0af5319606..6609ca082966 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_flash.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_flash.ino
@@ -21,9 +21,17 @@
#ifdef USE_BERRY
#include
-#include "esp_spi_flash.h"
+
+#include "esp_idf_version.h"
+#if ESP_IDF_VERSION_MAJOR >= 5
+ // esp_spi_flash.h is deprecated, please use spi_flash_mmap.h instead
+ #include "spi_flash_mmap.h"
+#else
+ #include "esp_spi_flash.h"
+#endif
size_t FlashWriteSubSector(uint32_t address_start, const uint8_t *data, size_t size) {
+#if ESP_IDF_VERSION_MAJOR < 5
uint32_t addr = address_start;
size_t size_left = size;
size_t current_offset = 0;
@@ -59,6 +67,9 @@ size_t FlashWriteSubSector(uint32_t address_start, const uint8_t *data, size_t s
}
return current_offset;
+#else
+ // TODO ESPIDF 5
+#endif
}
/*********************************************************************************************\
@@ -73,6 +84,7 @@ extern "C" {
// If length is not specified, it is full block 4KB
int32_t p_flash_read(struct bvm *vm);
int32_t p_flash_read(struct bvm *vm) {
+#if ESP_IDF_VERSION_MAJOR < 5
int32_t argc = be_top(vm); // Get the number of arguments
if (argc >= 1 && be_isint(vm, 1) &&
(argc < 2 || be_isint(vm, 2)) ) { // optional second argument must be int
@@ -91,6 +103,7 @@ extern "C" {
be_pushbytes(vm, buf.get(), length);
be_return(vm);
}
+#endif
be_raise(vm, kTypeError, nullptr);
}
@@ -98,6 +111,7 @@ extern "C" {
// if `no_erase` is true, just call spi_flash_write
int32_t p_flash_write(struct bvm *vm);
int32_t p_flash_write(struct bvm *vm) {
+#if ESP_IDF_VERSION_MAJOR < 5
int32_t argc = be_top(vm); // Get the number of arguments
if (argc >= 2 && be_isint(vm, 1) && be_isinstance(vm, 2)) {
be_getglobal(vm, "bytes"); /* get the bytes class */ /* TODO eventually replace with be_getbuiltin */
@@ -126,6 +140,7 @@ extern "C" {
}
}
}
+#endif
be_raise(vm, kTypeError, nullptr);
}
@@ -134,6 +149,7 @@ extern "C" {
// Address and length must be 4KB aligned
int32_t p_flash_erase(struct bvm *vm);
int32_t p_flash_erase(struct bvm *vm) {
+#if ESP_IDF_VERSION_MAJOR < 5
int32_t argc = be_top(vm); // Get the number of arguments
if (argc >= 2 && be_isint(vm, 1) && be_isint(vm, 2)) {
int32_t address = be_toint(vm, 1);
@@ -147,6 +163,7 @@ extern "C" {
esp_err_t ret = spi_flash_erase_range(address, length);
be_return_nil(vm);
}
+#endif
be_raise(vm, kTypeError, nullptr);
}
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tcpclientasync.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tcpclientasync.ino
index 8c6fa9841c69..ba574920b240 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tcpclientasync.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tcpclientasync.ino
@@ -68,6 +68,7 @@ public:
state = AsyncTCPState::INPROGRESS; // reset state
}
+#ifdef USE_IPV6
if (ip.type() == IPv6) {
struct sockaddr_in6 *tmpaddr = (struct sockaddr_in6 *)&serveraddr;
sockfd = socket(AF_INET6, SOCK_STREAM, 0);
@@ -75,12 +76,15 @@ public:
memcpy(tmpaddr->sin6_addr.un.u8_addr, &ip[0], 16);
tmpaddr->sin6_port = htons(port);
} else {
+#endif
struct sockaddr_in *tmpaddr = (struct sockaddr_in *)&serveraddr;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
tmpaddr->sin_family = AF_INET;
tmpaddr->sin_addr.s_addr = ip;
tmpaddr->sin_port = htons(port);
+#ifdef USE_IPV6
}
+#endif
if (sockfd < 0) {
AddLog(LOG_LEVEL_DEBUG, "BRY: Error: socket: %d", errno);
return 0;
@@ -312,7 +316,7 @@ public:
local_addr = IPAddress((uint32_t)(s->sin_addr.s_addr));
// return IPAddress((uint32_t)(s->sin_addr.s_addr));
}
-
+#ifdef USE_IPV6
// IPv6, but it might be IPv4 mapped address
if (((struct sockaddr*)&local_address)->sa_family == AF_INET6) {
struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *)&local_address;
@@ -325,6 +329,7 @@ public:
// return IPAddress(IPv6, (uint8_t*)(saddr6->sin6_addr.s6_addr));
}
}
+#endif // USE_IPV6
}
}
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webclient.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webclient.ino
index 9dcf44ccbf3c..eb5b7feb4284 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webclient.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webclient.ino
@@ -582,6 +582,7 @@ public:
size_t write(const uint8_t *buffer, size_t size) override {
// AddLog(LOG_LEVEL_INFO, "FLASH: addr=%p hex=%*_H size=%i", addr_start + offset, 32, buffer, size);
if (size > 0) {
+#if ESP_IDF_VERSION_MAJOR < 5 // TODO later
esp_err_t ret = spi_flash_write(addr_start + offset, buffer, size);
if (ret != ESP_OK) { return 0; } // error
offset += size;
@@ -590,6 +591,7 @@ public:
if (((offset - size) / STREAM_FLASH_PROGRESS_THRESHOLD) != (offset / STREAM_FLASH_PROGRESS_THRESHOLD)) {
AddLog(LOG_LEVEL_DEBUG, D_LOG_UPLOAD "Progress %d kB", offset / 1024);
}
+#endif
}
return size;
}
@@ -611,6 +613,7 @@ protected:
extern "C" {
int32_t wc_writeflash(struct bvm *vm);
int32_t wc_writeflash(struct bvm *vm) {
+#if ESP_IDF_VERSION_MAJOR < 5
int32_t argc = be_top(vm);
if (argc >= 2 && be_isint(vm, 2)) {
HTTPClientLight * cl = wc_getclient(vm);
@@ -650,6 +653,7 @@ extern "C" {
be_pushint(vm, written);
be_return(vm); /* return code */
}
+#endif
be_raise(vm, kTypeError, nullptr);
}
}
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_zigbee.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_zigbee.ino
index 1fca11afe67f..fee50f5f71a6 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_zigbee.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_zigbee.ino
@@ -257,16 +257,17 @@ extern "C" {
sizeof(Z_attribute), /* size in bytes */
11, /* number of elements */
nullptr,
- (const be_ctypes_structure_item_t[11]) {
+ (const be_ctypes_structure_item_t[12]) {
{ "_attr_id", offsetof(Z_attribute, attr_id), 0, 0, ctypes_u16, 0 },
{ "_cluster", offsetof(Z_attribute, cluster), 0, 0, ctypes_u16, 0 },
{ "_cmd", offsetof(Z_attribute, attr_id), 0, 0, ctypes_u8, 0 }, // low 8 bits of attr_id
{ "_cmd_general", offsetof(Z_attribute, attr_id) + 1, 1, 1, ctypes_u8, 0 }, // bit #1 of byte+1
{ "_direction", offsetof(Z_attribute, attr_id) + 1, 0, 1, ctypes_u8, 0 }, // bit #0 of byte+1
{ "_iscmd", offsetof(Z_attribute, key_is_cmd), 0, 0, ctypes_u8, 0 },
- { "attr_multiplier", offsetof(Z_attribute, attr_multiplier), 0, 0, ctypes_u32, 0 },
+ { "attr_base", offsetof(Z_attribute, attr_base), 0, 0, ctypes_u32, 0 },
{ "attr_divider", offsetof(Z_attribute, attr_divider), 0, 0, ctypes_u32, 0 },
- { "attr_type", offsetof(Z_attribute, attr_type), 0, 0, ctypes_i32, 0 },
+ { "attr_multiplier", offsetof(Z_attribute, attr_multiplier), 0, 0, ctypes_u32, 0 },
+ { "attr_type", offsetof(Z_attribute, attr_type), 0, 0, ctypes_u8, 0 },
// { "key", offsetof(Z_attribute, key), 0, 0, ctypes_ptr32, 0 },
// { "key_is_pmem", offsetof(Z_attribute, key_is_pmem), 0, 0, ctypes_u8, 0 },
// { "key_is_str", offsetof(Z_attribute, key_is_str), 0, 0, ctypes_u8, 0 },
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino
index 49255b436619..d63e8728c042 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino
@@ -64,10 +64,10 @@ void checkBeTop(void) {
* Use PSRAM if available
\*********************************************************************************************/
extern "C" {
- void *berry_malloc(uint32_t size);
+ void *berry_malloc(size_t size);
void *berry_realloc(void *ptr, size_t size);
#ifdef USE_BERRY_PSRAM
- void *berry_malloc(uint32_t size) {
+ void *berry_malloc(size_t size) {
return special_malloc(size);
}
void *berry_realloc(void *ptr, size_t size) {
@@ -77,7 +77,7 @@ extern "C" {
return special_calloc(num, size);
}
#else
- void *berry_malloc(uint32_t size) {
+ void *berry_malloc(size_t size) {
return malloc(size);
}
void *berry_realloc(void *ptr, size_t size) {
@@ -89,7 +89,7 @@ extern "C" {
#endif // USE_BERRY_PSRAM
- void *berry_malloc32(uint32_t size) {
+ void *berry_malloc32(size_t size) {
#ifdef USE_BERRY_IRAM
return special_malloc32(size);
#else
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_68_zerocrossDimmer.ino b/tasmota/tasmota_xdrv_driver/xdrv_68_zerocrossDimmer.ino
index f0199b78360e..e1856b5e3b4c 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_68_zerocrossDimmer.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_68_zerocrossDimmer.ino
@@ -24,6 +24,9 @@
#define XDRV_68 68
+
+#if !defined(ESP32) || (ESP_IDF_VERSION_MAJOR < 5) // temporarily disable for IDF 5.0
+
static const uint8_t TRIGGER_PERIOD = 75;
#define ZCDIMMERSET_SHOW 1
@@ -139,21 +142,21 @@ void IRAM_ATTR ACDimmerTimer_intr() {
for (uint8_t i = 0 ; i < MAX_PWMS; i++ ) {
if (Pin(GPIO_PWM1, i) == -1) continue;
- if (time_since_zc + TRIGGER_PERIOD >= ac_zero_cross_dimmer.enable_time_us[i]){
+ if (time_since_zc + TRIGGER_PERIOD + 30 >= ac_zero_cross_dimmer.enable_time_us[i]){
// Very close to the fire event. Loop the last µseconds to wait.
#ifdef ESP8266
- // on ESP8266 we can change dynamically the trigger interval
- ac_zero_cross_dimmer.actual_tigger_Period = tmin(ac_zero_cross_dimmer.actual_tigger_Period,tmax(5,ac_zero_cross_dimmer.enable_time_us[i] - time_since_zc));
+ // on ESP8266 we can change dynamically the trigger interval.
+ ac_zero_cross_dimmer.actual_tigger_Period = tmin(ac_zero_cross_dimmer.actual_tigger_Period*2,ac_zero_cross_dimmer.enable_time_us[i] - time_since_zc);
#endif
#ifdef ESP32
while (time_since_zc < ac_zero_cross_dimmer.enable_time_us[i]) {
time_since_zc = micros() - ac_zero_cross_dimmer.crossed_zero_at;
}
#endif
- if (time_since_zc >= ac_zero_cross_dimmer.enable_time_us[i] && !ac_zero_cross_dimmer.triggered[i] ) {
+ if (time_since_zc+5 >= ac_zero_cross_dimmer.enable_time_us[i] && !ac_zero_cross_dimmer.triggered[i] ) {
digitalWrite(Pin(GPIO_PWM1, i), HIGH ^ ac_zero_cross_dimmer.fallingEdgeDimmer );
ac_zero_cross_dimmer.triggered[i] = true;
- ac_zero_cross_dimmer.accurracy[i] = tmax(ac_zero_cross_dimmer.accurracy[i],time_since_zc-ac_zero_cross_dimmer.enable_time_us[i]);
+ ac_zero_cross_dimmer.accurracy[i] = time_since_zc-ac_zero_cross_dimmer.enable_time_us[i];
}
if (time_since_zc >= ac_zero_cross_dimmer.disable_time_us[i]) {
digitalWrite(Pin(GPIO_PWM1, i), LOW ^ ac_zero_cross_dimmer.fallingEdgeDimmer );
@@ -214,12 +217,13 @@ void ACDimmerLogging(void)
);
for (uint8_t i = 0; i < MAX_PWMS; i++){
if (Pin(GPIO_PWM1, i) == -1) continue;
- if (ac_zero_cross_dimmer.accurracy[i]) ac_zero_cross_dimmer.accurracy[i]--;
+
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZCD: PWM[%d] en: %ld µs, dis: %ld µs, fade: %d, cur: %d, end: %d, lastlight: %d, acc: %ld"),
i+1, ac_zero_cross_dimmer.enable_time_us[i], ac_zero_cross_dimmer.disable_time_us[i],
Light.fade_cur_10[i], Light.fade_start_10[i], Light.fade_end_10[i], ac_zero_cross_dimmer.lastlight[i],
ac_zero_cross_dimmer.accurracy[i]
);
+ if (ac_zero_cross_dimmer.accurracy[i]) ac_zero_cross_dimmer.accurracy[i]=0;
}
}
@@ -297,4 +301,7 @@ bool Xdrv68(uint32_t function)
}
return result;
}
+
+#endif // !enabled(ESP32) || (ESP_IDF_VERSION_MAJOR < 5)
+
#endif // USE_AC_ZERO_CROSS_DIMMER
diff --git a/tasmota/tasmota_xnrg_energy/xnrg_15_teleinfo.ino b/tasmota/tasmota_xnrg_energy/xnrg_15_teleinfo.ino
index bc40715b4fac..34c3993bd9c2 100644
--- a/tasmota/tasmota_xnrg_energy/xnrg_15_teleinfo.ino
+++ b/tasmota/tasmota_xnrg_energy/xnrg_15_teleinfo.ino
@@ -406,7 +406,7 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: HC:%ld HP:%ld Total:%ld"), hc, hp, total_wh);
}
- AddLog (LOG_LEVEL_INFO, PSTR ("TIC: Total counter updated to %ld Wh"), total_wh);
+ AddLog (LOG_LEVEL_DEBUG_MORE, PSTR ("TIC: Total counter updated to %ld Wh"), total_wh);
if (total_wh>0) {
Energy->total[0] = (float) total_wh / 1000.0f;
Energy->import_active[0] = Energy->total[0];
@@ -422,17 +422,17 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
total_wh = atol(me->value);
Energy->total[0] = (float) total_wh / 1000.0f;
Energy->import_active[0] = Energy->total[0];
- AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Total:%ldWh"), total_wh);
+ AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TIC: Total:%ldWh"), total_wh);
}
// Wh indexes (standard)
else if ( ilabel == LABEL_EASF01)
{
- AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: HC:%ld"), atol(me->value));
+ AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TIC: HC:%ld"), atol(me->value));
}
else if ( ilabel == LABEL_EASF02)
{
- AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: HP:%ld"), atol(me->value));
+ AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TIC: HP:%ld"), atol(me->value));
}
// Contract subscribed (legacy)
@@ -468,7 +468,7 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
else if (ilabel == LABEL_ISOUSC)
{
isousc = atoi( me->value);
- AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: ISousc set to %d"), isousc);
+ AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TIC: ISousc set to %d"), isousc);
}
// Contract subscribed (Power in KVA)
@@ -477,20 +477,20 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
// Convert KVA to A
isousc = atoi( me->value) * 5 ;
- AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: ISousc set to %d"), isousc);
+ AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TIC: ISousc set to %d"), isousc);
}
// Serial Number of device
else if (ilabel == LABEL_ADCO || ilabel == LABEL_ADSC)
{
strcpy(serialNumber, me->value);
- AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: %s set to %s"), me->name, serialNumber);
+ AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TIC: %s set to %s"), me->name, serialNumber);
}
// Status
else if (ilabel == LABEL_STGE)
{
status_register = strtol(me->value, nullptr, 16);
- AddLog(LOG_LEVEL_DEBUG, PSTR("Status Resister : %s set to %08X"), me->name, status_register);
+ AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("Status Resister : %s set to %08X"), me->name, status_register);
}
}
@@ -786,7 +786,7 @@ bool TInfoCmd(void) {
// At least "EnergyConfig"
if (CMND_ENERGYCONFIG == Energy->command_code) {
- AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: len %d, data '%s'"), XdrvMailbox.data_len, XdrvMailbox.data ? XdrvMailbox.data : "null" );
+ AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TIC: len %d, data '%s'"), XdrvMailbox.data_len, XdrvMailbox.data ? XdrvMailbox.data : "null" );
// Just "EnergyConfig" no more parameter
// Show Teleinfo configuration
@@ -838,7 +838,7 @@ bool TInfoCmd(void) {
int command_code = GetCommandCode(command, sizeof(command), pParam, kTInfo_Commands);
- AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: param '%s' cmnd %d"), pParam, command_code);
+ AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TIC: param '%s' cmnd %d"), pParam, command_code);
switch (command_code) {
case CMND_TELEINFO_STANDARD:
@@ -1002,7 +1002,7 @@ void TInfoProcess(void)
// if needed, update energy total every hour
if (tick_update++ > 3600 * 4) {
EnergyUpdateTotal();
- AddLog (LOG_LEVEL_INFO, PSTR ("TIC: Total counter updated to %lu Wh"), total_wh);
+ AddLog (LOG_LEVEL_DEBUG, PSTR ("TIC: Total counter updated to %lu Wh"), total_wh);
tick_update = 0;
}
diff --git a/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino b/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino
index 59c469d12fc0..0be99724e9bc 100644
--- a/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino
+++ b/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino
@@ -24,6 +24,12 @@
#define XSNS_02 2
+#ifdef ESP32
+ #if ESP_IDF_VERSION_MAJOR >= 5
+ #include "esp32-hal-adc.h"
+ #endif
+#endif
+
#ifdef ESP8266
#define ANALOG_RESOLUTION 10 // 12 = 4095, 11 = 2047, 10 = 1023
#define ANALOG_RANGE 1023 // 4095 = 12, 2047 = 11, 1023 = 10
@@ -176,6 +182,11 @@ bool adcAttachPin(uint8_t pin) {
return (ADC0_PIN == pin);
}
#endif
+#if defined(ESP32) && (ESP_IDF_VERSION_MAJOR >= 5)
+ bool adcAttachPin(uint8_t pin) {
+ return true; // TODO - no more needed?
+ }
+#endif
void AdcSaveSettings(uint32_t idx) {
char parameters[32];
@@ -297,7 +308,9 @@ void AdcInit(void) {
if (Adcs.present) {
#ifdef ESP32
+#if ESP_IDF_VERSION_MAJOR < 5
analogSetClockDiv(1); // Default 1
+#endif
#if CONFIG_IDF_TARGET_ESP32
analogSetWidth(ANALOG_RESOLUTION); // Default 12 bits (0 - 4095)
#endif // CONFIG_IDF_TARGET_ESP32
diff --git a/tasmota/tasmota_xsns_sensor/xsns_110_max17043.ino b/tasmota/tasmota_xsns_sensor/xsns_110_max17043.ino
index 4a90f0b13fc6..7c97be17e0e3 100644
--- a/tasmota/tasmota_xsns_sensor/xsns_110_max17043.ino
+++ b/tasmota/tasmota_xsns_sensor/xsns_110_max17043.ino
@@ -27,10 +27,6 @@
* The alert flag and alert threshold are not required for MQTT, the alert pin is not used
* by this sensor driver.
*
- * Wiring and other information:
- *
- * \lib\lib_i2c\DFRobot_MAX17043\resources
- *
* Tested module(s):
*
* https://www.dfrobot.com/product-1734.html
@@ -45,16 +41,6 @@
#define XI2C_83 83 // See I2CDEVICES.md
#define MAX17043_ADDRESS 0x36
-
-//#define MAX17043_USE_LIB
-
-#ifdef MAX17043_USE_LIB
-
-#include "DFRobot_MAX17043.h"
-DFRobot_MAX17043 max17043_gauge; // Class to read from MAX17043
-
-#else
-
#define MAX17043_VCELL 0x02
#define MAX17043_SOC 0x04
#define MAX17043_MODE 0x06
@@ -62,30 +48,18 @@ DFRobot_MAX17043 max17043_gauge; // Class to read from MAX17043
#define MAX17043_CONFIG 0x0c
#define MAX17043_COMMAND 0xfe
-#endif // MAX17043_USE_LIB
-
bool max17043 = false;
/*********************************************************************************************/
void Max17043Init(void) {
if (I2cSetDevice(MAX17043_ADDRESS)) {
-
-#ifdef MAX17043_USE_LIB
-
- if (max17043_gauge.begin() == 0) {
-
-#else
-
I2cWrite16(MAX17043_ADDRESS, MAX17043_COMMAND, 0x5400); // Power on reset
delay(10);
if (I2cRead16(MAX17043_ADDRESS, MAX17043_CONFIG) == 0x971c) { // Default 0x971c
I2cWrite16(MAX17043_ADDRESS, MAX17043_MODE, 0x4000); // Quick start
I2cWrite16(MAX17043_ADDRESS, MAX17043_CONFIG, 0x9700);
delay(10);
-
-#endif // MAX17043_USE_LIB
-
max17043 = true;
I2cSetActiveFound(MAX17043_ADDRESS, "MAX17043");
}
@@ -93,20 +67,10 @@ void Max17043Init(void) {
}
void Max17043Show(bool json) {
-
-#ifdef MAX17043_USE_LIB
-
- float voltage = max17043_gauge.readVoltage() / 1000.0; // Battery voltage in Volt
- float percentage = max17043_gauge.readPercentage(); // Battery remaining charge in percent
-
-#else
-
float voltage = (1.25f * (float)(I2cRead16(MAX17043_ADDRESS, MAX17043_VCELL) >> 4)) / 1000.0; // Battery voltage in Volt
uint16_t per = I2cRead16(MAX17043_ADDRESS, MAX17043_SOC);
float percentage = (float)((per >> 8) + 0.003906f * (per & 0x00ff)); // Battery remaining charge in percent
-#endif // MAX17043_USE_LIB
-
// During charging the percentage might be (slightly) above 100%. To avoid strange numbers
// in the statistics the percentage provided by this driver will not go above 100%
if (percentage > 100.0) { percentage = 100.0; }
diff --git a/tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino b/tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino
index c50d9a82d24b..53b643557425 100644
--- a/tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino
+++ b/tasmota/tasmota_xsns_sensor/xsns_127_esp32_sensors.ino
@@ -33,7 +33,7 @@
#define XSNS_127 127
-#if CONFIG_IDF_TARGET_ESP32
+#if CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5) // Hall sensor is no more supported in esp-idf 5
#define HALLEFFECT_SAMPLE_COUNT 32 // 32 takes about 12 mS at 80MHz CPU frequency
@@ -51,7 +51,7 @@ void Esp32SensorInit(void) {
}
}
-#endif // CONFIG_IDF_TARGET_ESP32
+#endif // CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5)
void Esp32SensorShow(bool json) {
bool json_end = false;
@@ -84,7 +84,7 @@ void Esp32SensorShow(bool json) {
}
}
-#if CONFIG_IDF_TARGET_ESP32
+#if CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5) // Hall sensor is no more supported in esp-idf 5
if (HEData.present) {
int value = 0;
for (uint32_t i = 0; i < HALLEFFECT_SAMPLE_COUNT; i++) {
@@ -115,7 +115,7 @@ void Esp32SensorShow(bool json) {
#endif // USE_WEBSERVER
}
}
-#endif // CONFIG_IDF_TARGET_ESP32
+#endif // CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5)
if (json_end) {
ResponseJsonEnd();
@@ -138,11 +138,11 @@ bool Xsns127(uint32_t function) {
Esp32SensorShow(0);
break;
#endif // USE_WEBSERVER
-#if CONFIG_IDF_TARGET_ESP32
+#if CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5) // Hall sensor is no more supported in esp-idf 5
case FUNC_INIT:
Esp32SensorInit();
break;
-#endif // CONFIG_IDF_TARGET_ESP32
+#endif // CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5)
}
return result;
}
diff --git a/tasmota/tasmota_xsns_sensor/xsns_80_mfrc522.ino b/tasmota/tasmota_xsns_sensor/xsns_80_mfrc522.ino
index 037ded6da257..7ceeed9aed4b 100644
--- a/tasmota/tasmota_xsns_sensor/xsns_80_mfrc522.ino
+++ b/tasmota/tasmota_xsns_sensor/xsns_80_mfrc522.ino
@@ -100,9 +100,9 @@ void RC522ScanForTag(void) {
void RC522Init(void) {
if (PinUsed(GPIO_RC522_CS) && PinUsed(GPIO_RC522_RST) && (SPI_MOSI_MISO == TasmotaGlobal.spi_enabled)) {
Mfrc522 = new MFRC522(Pin(GPIO_RC522_CS), Pin(GPIO_RC522_RST));
-#ifdef EPS8266
+#ifdef ESP8266
SPI.begin();
-#endif // EPS8266
+#endif // ESP8266
#ifdef ESP32
SPI.begin(Pin(GPIO_SPI_CLK), Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_MOSI), -1);
#endif // ESP32