From 8bcbd2b024d8a64e4b2e9c57c28edad4c618027a Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Tue, 18 Dec 2018 21:35:29 +0000 Subject: [PATCH 1/8] Dallas: perform 1wire reset before issue copy to eeprom command it is small fix for resolution change after sensor reset #2143 --- src/_P004_Dallas.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_P004_Dallas.ino b/src/_P004_Dallas.ino index bbf4ae57c..4e63909bb 100644 --- a/src/_P004_Dallas.ino +++ b/src/_P004_Dallas.ino @@ -387,6 +387,7 @@ boolean Plugin_004_DS_setResolution(uint8_t ROM[8], byte res) Plugin_004_DS_write(ScratchPad[3]); // low alarm temp Plugin_004_DS_write(ScratchPad[4]); // configuration register + Plugin_004_DS_reset(); Plugin_004_DS_write(0x55); // Choose ROM for (byte i = 0; i < 8; i++) Plugin_004_DS_write(ROM[i]); From ea98eb516bcfaf9726cfedbddde4eac87f0733f9 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zimon Date: Tue, 18 Dec 2018 22:10:32 +0000 Subject: [PATCH 2/8] Dallas: do not perform eeprom write if configuration does not change --- src/_P004_Dallas.ino | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/_P004_Dallas.ino b/src/_P004_Dallas.ino index 4e63909bb..6d57eece3 100644 --- a/src/_P004_Dallas.ino +++ b/src/_P004_Dallas.ino @@ -360,6 +360,8 @@ boolean Plugin_004_DS_setResolution(uint8_t ROM[8], byte res) return false; else { + byte old_configuration = ScratchPad[4]; + switch (res) { case 12: @@ -377,6 +379,9 @@ boolean Plugin_004_DS_setResolution(uint8_t ROM[8], byte res) break; } + if (ScratchPad[4] == old_configuration) + return true; + Plugin_004_DS_reset(); Plugin_004_DS_write(0x55); // Choose ROM for (byte i = 0; i < 8; i++) From 1a55b991b935266e283130a4336551808bb1dfa3 Mon Sep 17 00:00:00 2001 From: stefan Date: Sun, 6 Jan 2019 11:58:06 +0100 Subject: [PATCH 3/8] [deepSleep] Make deepSleep work again with 2.5.0 and refactor delay var Make deepSleep work again with Core 2.5.0. Changed ESP.deepSleep() to ESP.deepSleepInstant(). Refactor delay variable to dsdelay to avoid conflicts with the delay() function. Added a delay(100) before going to sleep to give the node time to send the last log messages. --- src/Misc.ino | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Misc.ino b/src/Misc.ino index da6fc063e..4ca3659c7 100644 --- a/src/Misc.ino +++ b/src/Misc.ino @@ -130,7 +130,7 @@ bool readyForSleep() return timeOutReached(timerAwakeFromDeepSleep + 1000 * Settings.deepSleep); } -void deepSleep(int delay) +void deepSleep(int dsdelay) { checkRAM(F("deepSleep")); @@ -158,10 +158,10 @@ void deepSleep(int delay) } } saveUserVarToRTC(); - deepSleepStart(delay); // Call deepSleepStart function after these checks + deepSleepStart(dsdelay); // Call deepSleepStart function after these checks } -void deepSleepStart(int delay) +void deepSleepStart(int dsdelay) { // separate function that is called from above function or directly from rules, usign deepSleep as a one-shot String event = F("System#Sleep"); @@ -171,15 +171,16 @@ void deepSleepStart(int delay) RTC.deepSleepState = 1; saveToRTC(); - if (delay > 4294 || delay < 0) - delay = 4294; //max sleep time ~1.2h + if (dsdelay > 4294 || dsdelay < 0) + dsdelay = 4294; //max sleep time ~1.2h addLog(LOG_LEVEL_INFO, F("SLEEP: Powering down to deepsleep...")); + delay(100); // give the node time to send above log message before going to sleep #if defined(ESP8266) - ESP.deepSleep((uint32_t)delay * 1000000, WAKE_RF_DEFAULT); + ESP.deepSleepInstant((uint32_t)dsdelay * 1000000, WAKE_RF_DEFAULT); #endif #if defined(ESP32) - esp_sleep_enable_timer_wakeup((uint32_t)delay * 1000000); + esp_sleep_enable_timer_wakeup((uint32_t)dsdelay * 1000000); esp_deep_sleep_start(); #endif } @@ -515,9 +516,9 @@ void statusLED(boolean traffic) /********************************************************************************************\ delay in milliseconds with background processing \*********************************************************************************************/ -void delayBackground(unsigned long delay) +void delayBackground(unsigned long dsdelay) { - unsigned long timer = millis() + delay; + unsigned long timer = millis() + dsdelay; while (!timeOutReached(timer)) backgroundtasks(); } From c2c311eb78b7eb50293b6a7a05663833fdcc8bb2 Mon Sep 17 00:00:00 2001 From: stefan Date: Sun, 6 Jan 2019 13:10:28 +0100 Subject: [PATCH 4/8] [deepSleep] only use deepSleepInstant for 2.5.0 added #ifdefs to make build happy also for versions <2.5.0 --- src/Misc.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Misc.ino b/src/Misc.ino index 4ca3659c7..3a9ac22d6 100644 --- a/src/Misc.ino +++ b/src/Misc.ino @@ -177,7 +177,11 @@ void deepSleepStart(int dsdelay) addLog(LOG_LEVEL_INFO, F("SLEEP: Powering down to deepsleep...")); delay(100); // give the node time to send above log message before going to sleep #if defined(ESP8266) - ESP.deepSleepInstant((uint32_t)dsdelay * 1000000, WAKE_RF_DEFAULT); + #if defined(CORE_2_5_0) + ESP.deepSleepInstant((uint32_t)dsdelay * 1000000, WAKE_RF_DEFAULT); + #else + ESP.deepSleep((uint32_t)dsdelay * 1000000, WAKE_RF_DEFAULT); + #endif #endif #if defined(ESP32) esp_sleep_enable_timer_wakeup((uint32_t)dsdelay * 1000000); From 999e43a834f5abf8f15c2027b4b30d998d6b3424 Mon Sep 17 00:00:00 2001 From: stefan Date: Sun, 6 Jan 2019 20:50:13 +0100 Subject: [PATCH 5/8] [deepSleep] Allow for sleeptimes up to deepSleepMax() Allow to specify sleep times up deepSleepMax() on core 2.5.0 --- src/Misc.ino | 10 +++++----- src/WebServer.ino | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Misc.ino b/src/Misc.ino index 3a9ac22d6..3d2404401 100644 --- a/src/Misc.ino +++ b/src/Misc.ino @@ -167,19 +167,19 @@ void deepSleepStart(int dsdelay) String event = F("System#Sleep"); rulesProcessing(event); - RTC.deepSleepState = 1; saveToRTC(); - if (dsdelay > 4294 || dsdelay < 0) - dsdelay = 4294; //max sleep time ~1.2h - addLog(LOG_LEVEL_INFO, F("SLEEP: Powering down to deepsleep...")); delay(100); // give the node time to send above log message before going to sleep #if defined(ESP8266) #if defined(CORE_2_5_0) - ESP.deepSleepInstant((uint32_t)dsdelay * 1000000, WAKE_RF_DEFAULT); + if (dsdelay > ESP.deepSleepMax() || dsdelay < 0) + dsdelay = ESP.deepSleepMax(); //max sleep time + ESP.deepSleepInstant((uint32_t)dsdelay * 1000000, WAKE_RF_DEFAULT); #else + if (dsdelay > 4294 || dsdelay < 0) + dsdelay = 4294; //max sleep time ~1.2h ESP.deepSleep((uint32_t)dsdelay * 1000000, WAKE_RF_DEFAULT); #endif #endif diff --git a/src/WebServer.ino b/src/WebServer.ino index 0dca669c1..3f14f04ac 100644 --- a/src/WebServer.ino +++ b/src/WebServer.ino @@ -1271,8 +1271,12 @@ void handle_config() { addHelpButton(F("SleepMode")); addFormNote(F("0 = Sleep Disabled, else time awake from sleep")); - addFormNumericBox( F("Sleep time"), F("delay"), Settings.Delay, 0, 4294); //limited by hardware to ~1.2h - addUnit(F("sec")); + #if defined(CORE_2_5_0) + addFormNumericBox( F("Sleep time"), F("delay"), Settings.Delay, 0, ESP.deepSleepMax()); //limited by hardware + #else + addFormNumericBox( F("Sleep time"), F("delay"), Settings.Delay, 0, 4294); //limited by hardware to ~1.2h + #endif + addUnit(F("sec")); addFormCheckBox(F("Sleep on connection failure"), F("deepsleeponfail"), Settings.deepSleepOnFail); From 1ac0a96b41c0f6988ffe7e58f164f7d2aba8b5a5 Mon Sep 17 00:00:00 2001 From: stefan Date: Mon, 7 Jan 2019 08:29:00 +0100 Subject: [PATCH 6/8] [deepSleep] fix type errors of #999e43a Fix type errors of #999e43a and (hopefully) cast all types correctly now.... Keep deep sleep delay below INT_MAX for parameter storage compatibility. --- src/Misc.ino | 8 ++++++-- src/WebServer.ino | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Misc.ino b/src/Misc.ino index 3d2404401..c906b4f00 100644 --- a/src/Misc.ino +++ b/src/Misc.ino @@ -174,8 +174,12 @@ void deepSleepStart(int dsdelay) delay(100); // give the node time to send above log message before going to sleep #if defined(ESP8266) #if defined(CORE_2_5_0) - if (dsdelay > ESP.deepSleepMax() || dsdelay < 0) - dsdelay = ESP.deepSleepMax(); //max sleep time + if ((uint64_t)dsdelay > (ESP.deepSleepMax()/1000000ULL) || dsdelay < 0) { + if ((ESP.deepSleepMax()/1000000ULL) > (uint64_t)INT_MAX) + dsdelay = INT_MAX; + else + dsdelay = (int)(ESP.deepSleepMax()/1000000ULL); + } ESP.deepSleepInstant((uint32_t)dsdelay * 1000000, WAKE_RF_DEFAULT); #else if (dsdelay > 4294 || dsdelay < 0) diff --git a/src/WebServer.ino b/src/WebServer.ino index 3f14f04ac..08b704e13 100644 --- a/src/WebServer.ino +++ b/src/WebServer.ino @@ -1272,7 +1272,10 @@ void handle_config() { addFormNote(F("0 = Sleep Disabled, else time awake from sleep")); #if defined(CORE_2_5_0) - addFormNumericBox( F("Sleep time"), F("delay"), Settings.Delay, 0, ESP.deepSleepMax()); //limited by hardware + int dsmax = INT_MAX; + if ((ESP.deepSleepMax()/1000000ULL) <= (uint64_t)INT_MAX) + dsmax = (int)(ESP.deepSleepMax()/1000000ULL); + addFormNumericBox( F("Sleep time"), F("delay"), Settings.Delay, 0, dsmax); //limited by hardware #else addFormNumericBox( F("Sleep time"), F("delay"), Settings.Delay, 0, 4294); //limited by hardware to ~1.2h #endif From cf95d0ca37726f1c3e188987960ac99b08a5d7f0 Mon Sep 17 00:00:00 2001 From: TD-er Date: Mon, 7 Jan 2019 11:47:24 +0100 Subject: [PATCH 7/8] [deepSleep] Prevent overflow issues The 'old' limit of 4294 seconds was 2^32 usec. By casting it to an uint32, you may get unexpected results when multiplying it by 10^6 again. So better to use uint64 as variable and work on that one, now the deepsleep functions support uint64. --- src/Misc.ino | 12 +++++------- src/WebServer.ino | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/Misc.ino b/src/Misc.ino index c906b4f00..4b11dd1a7 100644 --- a/src/Misc.ino +++ b/src/Misc.ino @@ -174,16 +174,14 @@ void deepSleepStart(int dsdelay) delay(100); // give the node time to send above log message before going to sleep #if defined(ESP8266) #if defined(CORE_2_5_0) - if ((uint64_t)dsdelay > (ESP.deepSleepMax()/1000000ULL) || dsdelay < 0) { - if ((ESP.deepSleepMax()/1000000ULL) > (uint64_t)INT_MAX) - dsdelay = INT_MAX; - else - dsdelay = (int)(ESP.deepSleepMax()/1000000ULL); + uint64_t deepSleep_usec = dsdelay * 1000000ULL; + if ((deepSleep_usec > ESP.deepSleepMax()) || dsdelay < 0) { + deepSleep_usec = ESP.deepSleepMax(); } - ESP.deepSleepInstant((uint32_t)dsdelay * 1000000, WAKE_RF_DEFAULT); + ESP.deepSleepInstant(deepSleep_usec, WAKE_RF_DEFAULT); #else if (dsdelay > 4294 || dsdelay < 0) - dsdelay = 4294; //max sleep time ~1.2h + dsdelay = 4294; //max sleep time ~71 minutes ESP.deepSleep((uint32_t)dsdelay * 1000000, WAKE_RF_DEFAULT); #endif #endif diff --git a/src/WebServer.ino b/src/WebServer.ino index 08b704e13..484c8a34a 100644 --- a/src/WebServer.ino +++ b/src/WebServer.ino @@ -1271,15 +1271,19 @@ void handle_config() { addHelpButton(F("SleepMode")); addFormNote(F("0 = Sleep Disabled, else time awake from sleep")); - #if defined(CORE_2_5_0) - int dsmax = INT_MAX; - if ((ESP.deepSleepMax()/1000000ULL) <= (uint64_t)INT_MAX) - dsmax = (int)(ESP.deepSleepMax()/1000000ULL); - addFormNumericBox( F("Sleep time"), F("delay"), Settings.Delay, 0, dsmax); //limited by hardware - #else - addFormNumericBox( F("Sleep time"), F("delay"), Settings.Delay, 0, 4294); //limited by hardware to ~1.2h - #endif - addUnit(F("sec")); + int dsmax = 4294; // About 71 minutes +#if defined(CORE_2_5_0) + dsmax = INT_MAX; + if ((ESP.deepSleepMax()/1000000ULL) <= (uint64_t)INT_MAX) + dsmax = (int)(ESP.deepSleepMax()/1000000ULL); +#endif + addFormNumericBox( F("Sleep time"), F("delay"), Settings.Delay, 0, dsmax); //limited by hardware + { + String maxSleeptimeUnit = F("sec (max: "); + maxSleeptimeUnit += String(dsmax); + maxSleeptimeUnit += ')'; + addUnit(maxSleeptimeUnit); + } addFormCheckBox(F("Sleep on connection failure"), F("deepsleeponfail"), Settings.deepSleepOnFail); From fa9efcdb2baea1369df571bf63c7d8e2c31a1c68 Mon Sep 17 00:00:00 2001 From: ESPEasy release bot Date: Tue, 8 Jan 2019 04:00:08 +0100 Subject: [PATCH 8/8] automatically updated release notes for mega-20190108 --- dist/Release_notes.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/dist/Release_notes.txt b/dist/Release_notes.txt index 6f48d29f2..b74565938 100644 --- a/dist/Release_notes.txt +++ b/dist/Release_notes.txt @@ -1,3 +1,33 @@ +------------------------------------------------- +Changes in release mega-20190108 (since mega-20190107) +------------------------------------------------- + +Release date: Tue Jan 8 04:00:08 CET 2019 + +Bartlomiej Zimon (2): + Dallas: perform 1wire reset before issue copy to eeprom command it is small fix for resolution change after sensor reset #2143 + Dallas: do not perform eeprom write if configuration does not change + +Grovkillen (8): + [docs] fixed used libraries + [docs] added events to all plugin pages + [docs] added "used libraries" to all plugin pages + [docs] moved events to repl file (same as commands) + [docs] added an event reference page (similar to the command ref. page) + [docs] added P082 (GPS) pages + [docs] P082 (GPS) added "where to buy" links + [docs] fixed some syntax + +TD-er (1): + [deepSleep] Prevent overflow issues + +stefan (4): + [deepSleep] Make deepSleep work again with 2.5.0 and refactor delay var + [deepSleep] only use deepSleepInstant for 2.5.0 + [deepSleep] Allow for sleeptimes up to deepSleepMax() + [deepSleep] fix type errors of #999e43a + + ------------------------------------------------- Changes in release mega-20190107 (since mega-20190106) -------------------------------------------------