From 4405b419e12d8a713fcf886ab364680db045cc53 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Fri, 8 Mar 2019 14:20:29 +0300 Subject: [PATCH 1/5] Pin ArduinoJson version (#1613) --- code/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/platformio.ini b/code/platformio.ini index faedc82e..36543b20 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -74,7 +74,7 @@ extra_scripts = extra_scripts.py # Please note that we don't always use the latest version of a library. # ------------------------------------------------------------------------------ lib_deps = - ArduinoJson + ArduinoJson@5.13.4 https://github.com/marvinroger/async-mqtt-client#v0.8.1 Brzo I2C https://github.com/xoseperez/debounceevent.git#2.0.5 From 8de61598f61c141469f015ef6c8ddab093db9392 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Sat, 9 Mar 2019 16:57:52 +0300 Subject: [PATCH 2/5] Fix ESP.eraseConfig() when using Core 2.3.0 (#1595, #1616) --- code/espurna/config/prototypes.h | 1 + code/espurna/terminal.ino | 2 +- code/espurna/utils.ino | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/code/espurna/config/prototypes.h b/code/espurna/config/prototypes.h index d9b5d435..e173626e 100644 --- a/code/espurna/config/prototypes.h +++ b/code/espurna/config/prototypes.h @@ -157,6 +157,7 @@ bool settingsRestoreJson(JsonObject& data); // ----------------------------------------------------------------------------- char * ltrim(char * s); void nice_delay(unsigned long ms); +bool inline eraseSDKConfig(); #define ARRAYINIT(type, name, ...) type name[] = {__VA_ARGS__}; diff --git a/code/espurna/terminal.ino b/code/espurna/terminal.ino index b87918eb..7ffa7710 100644 --- a/code/espurna/terminal.ino +++ b/code/espurna/terminal.ino @@ -96,7 +96,7 @@ void _terminalInitCommand() { terminalOK(); resetReason(CUSTOM_RESET_TERMINAL); _eepromCommit(); - ESP.eraseConfig(); + eraseSDKConfig(); *((int*) 0) = 0; // see https://github.com/esp8266/Arduino/issues/1494 }); diff --git a/code/espurna/utils.ino b/code/espurna/utils.ino index 09e09e1b..d70eb606 100644 --- a/code/espurna/utils.ino +++ b/code/espurna/utils.ino @@ -578,6 +578,25 @@ bool checkNeedsReset() { return _reset_reason > 0; } +// Use fixed method for Core 2.3.0, because it erases only 2 out of 4 SDK-reserved sectors +// Fixed since 2.4.0, see: esp8266/core/esp8266/Esp.cpp: ESP::eraseConfig() +bool eraseSDKConfig() { + #if defined(ARDUINO_ESP8266_RELEASE_2_3_0) + const size_t cfgsize = 0x4000; + size_t cfgaddr = ESP.getFlashChipSize() - cfgsize; + + for (size_t offset = 0; offset < cfgsize; offset += SPI_FLASH_SEC_SIZE) { + if (!ESP.flashEraseSector((cfgaddr + offset) / SPI_FLASH_SEC_SIZE)) { + return false; + } + } + + return true; + #else + return ESP.eraseConfig(); + #endif +} + // ----------------------------------------------------------------------------- char * ltrim(char * s) { From 1507c9e5d52031045a6e53f85e5f5816e371ba5f Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Sat, 9 Mar 2019 16:59:49 +0300 Subject: [PATCH 3/5] relay: mqttGroupSync is no longer bool --- code/espurna/relay.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index c88880a8..9fb78dc1 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -660,7 +660,7 @@ void _relayWebSocketSendRelays() { #if MQTT_SUPPORT group.add(getSetting("mqttGroup", i, "")); - group_sync.add(getSetting("mqttGroupSync", i, 0).toInt() == 1); + group_sync.add(getSetting("mqttGroupSync", i, 0).toInt()); on_disconnect.add(getSetting("relayOnDisc", i, 0).toInt()); #endif } From 33945e4ca892737a8d2624628684c0ea7d131bfb Mon Sep 17 00:00:00 2001 From: brmo Date: Sat, 9 Mar 2019 16:06:38 -0800 Subject: [PATCH 4/5] Added Teckin SP20 Power Plug. (#1611) * Added Teckin SP20 Power Plug * Added Teckin SP20 to hardware --- code/espurna/config/hardware.h | 42 ++++++++++++++++++++++++++++++++++ code/platformio.ini | 26 +++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index b51461af..be02dd63 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -3459,6 +3459,48 @@ #define BUTTON3_RELAY 2 #define BUTTON4_RELAY 1 +// ----------------------------------------------------------------------------- +// Teckin SP20 +// ----------------------------------------------------------------------------- + + #elif defined(TECKIN_SP20) + + // Info + #define MANUFACTURER "TECKIN" + #define DEVICE "SP20" + + // Buttons + #define BUTTON1_PIN 13 + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + + // Relays + #define RELAY1_PIN 4 + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 2 + #define LED1_PIN_INVERSE 1 + #define LED2_PIN 0 + #define LED2_PIN_INVERSE 1 + #define LED2_MODE LED_MODE_FINDME + #define LED2_RELAY 0 + + // HJL01 / BL0937 + #ifndef HLW8012_SUPPORT + #define HLW8012_SUPPORT 1 + #endif + #define HLW8012_SEL_PIN 12 + #define HLW8012_CF1_PIN 14 + #define HLW8012_CF_PIN 5 + + #define HLW8012_SEL_CURRENT LOW + #define HLW8012_CURRENT_RATIO 25740 + #define HLW8012_VOLTAGE_RATIO 313400 + #define HLW8012_POWER_RATIO 3414290 + #define HLW8012_INTERRUPT_ON FALLING + + // ----------------------------------------------------------------------------- // TEST boards (do not use!!) // ----------------------------------------------------------------------------- diff --git a/code/platformio.ini b/code/platformio.ini index 36543b20..1d9cd97b 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -3251,3 +3251,29 @@ upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} monitor_speed = ${common.monitor_speed} extra_scripts = ${common.extra_scripts} + +[env:teckin-sp20] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board_1m} +board_build.flash_mode = ${common.flash_mode} +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m0m} -DTECKIN_SP20 +upload_speed = ${common.upload_speed} +monitor_speed = ${common.monitor_speed} +extra_scripts = ${common.extra_scripts} + +[env:teckin-sp20-ota] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board_1m} +board_build.flash_mode = ${common.flash_mode} +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m0m} -DTECKIN_SP20 +upload_speed = ${common.upload_speed} +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_flags = ${common.upload_flags} +extra_scripts = ${common.extra_scripts} From ea5bd90cc76811a7351d77bf52dba7c5ce86de4d Mon Sep 17 00:00:00 2001 From: Zebble Date: Sat, 9 Mar 2019 20:56:45 -0500 Subject: [PATCH 5/5] Added LITESUN LA-WF3 support. (#1618) * Added LITESUN LA-WF3 support. Support for LITESUN LA-WF3 / Costco Charging Essentials wall socket. * Added LITESUN LA-WF3 support. Support for LITESUN LA-WF3 / Costco Charging Essentials wall socket. * LITESUN_LA_WF3 hardware.h * LITESUN_LA_WF3 platformio.ini --- code/espurna/config/hardware.h | 27 +++++++++++++++++++++++++++ code/platformio.ini | 26 ++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index be02dd63..5fcdcbe9 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -3500,6 +3500,33 @@ #define HLW8012_POWER_RATIO 3414290 #define HLW8012_INTERRUPT_ON FALLING +// ----------------------------------------------------------------------------- +// Charging Essentials / LITESUN LA-WF3 +// ----------------------------------------------------------------------------- + +#elif defined(LITESUN_LA_WF3) + + // Info + #define MANUFACTURER "LITESUN" + #define DEVICE "LA_WF3" + + // Buttons + #define BUTTON1_PIN 13 + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + + // Relays + #define RELAY1_PIN 12 + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 4 // 4 blue led + #define LED1_MODE LED_MODE_WIFI + #define LED1_PIN_INVERSE 1 + + #define LED2_PIN 5 // 5 red led + #define LED2_MODE LED_MODE_RELAY + #define LED2_PIN_INVERSE 1 // ----------------------------------------------------------------------------- // TEST boards (do not use!!) diff --git a/code/platformio.ini b/code/platformio.ini index 1d9cd97b..b9805c7b 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -3277,3 +3277,29 @@ monitor_speed = ${common.monitor_speed} upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} extra_scripts = ${common.extra_scripts} + +[env:litesun-la-wf3] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board_1m} +board_build.flash_mode = ${common.flash_mode} +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m0m} -DLITESUN_LA_WF3 +upload_speed = ${common.upload_speed} +monitor_speed = ${common.monitor_speed} +extra_scripts = ${common.extra_scripts} + +[env:litesun-la-wf3-ota] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board_1m} +board_build.flash_mode = ${common.flash_mode} +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m0m} -DLITESUN_LA_WF3 +upload_speed = ${common.upload_speed} +monitor_speed = ${common.monitor_speed} +upload_port = ${common.upload_port} +upload_flags = ${common.upload_flags} +extra_scripts = ${common.extra_scripts} \ No newline at end of file