From 5561de02fa3f2254a1654181a559351a501d77d2 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 20 Jan 2021 17:03:53 +0100 Subject: [PATCH] Add support for Sugar Valley NeoPool Controller Add support for Sugar Valley NeoPool Controller by Norbert Richter (#10637) --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + tasmota/tasmota.ino | 4 +- tasmota/xdrv_50_filesystem.ino | 2 - tasmota/xsns_83_neopool.ino | 67 +++++++++++++++------------------- 5 files changed, 33 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbef14ad3..5c447626d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. - Compile time option ``USE_MQTT_TLS_DROP_OLD_FINGERPRINT`` to drop old (less secure) TLS fingerprint - Command ``SetOption40 0..250`` to disable button functionality if activated for over 0.1 second re-introduced - Support for SM2135 current selection using GPIO ``SM2135 DAT`` index (#10634) +- Support for Sugar Valley NeoPool Controller by Norbert Richter (#10637) ### Breaking Changed - ESP32 switch from default SPIFFS to default LittleFS file system loosing current (zigbee) files diff --git a/RELEASENOTES.md b/RELEASENOTES.md index feee3d709..ee4096131 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -81,6 +81,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Support for time proportioned (``#define USE_TIMEPROP``) and optional PID (``#define USE_PID``) relay control [#10412](https://github.com/arendst/Tasmota/issues/10412) - Support for 24/26/32/34 bit RFID Wiegand interface (D0/D1) by Sigurd Leuther [#3647](https://github.com/arendst/Tasmota/issues/3647) - Support for SM2135 current selection using GPIO ``SM2135 DAT`` index [#10634](https://github.com/arendst/Tasmota/issues/10634) +- Support for Sugar Valley NeoPool Controller by Norbert Richter [#10637](https://github.com/arendst/Tasmota/issues/10637) - Support rotary encoder on Shelly Dimmer [#10407](https://github.com/arendst/Tasmota/issues/10407#issuecomment-756240920) - Support character `#` to be replaced by `space`-character in command ``Publish`` topic [#10258](https://github.com/arendst/Tasmota/issues/10258) - Basic support for ESP32 Odroid Go 16MB binary tasmota32-odroidgo.bin [#8630](https://github.com/arendst/Tasmota/issues/8630) diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index e0577afbd..9772b0fbe 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -67,7 +67,7 @@ #include // I2C support library //#endif // USE_I2C #ifdef USE_SPI - #include // SPI support, TFT + #include // SPI support, TFT, SDcard #endif // USE_SPI #ifdef USE_UFILESYS @@ -79,9 +79,7 @@ #include #endif // USE_SDCARD #endif // ESP8266 - #ifdef ESP32 -#define FFS_2 #include #ifdef USE_SDCARD #include diff --git a/tasmota/xdrv_50_filesystem.ino b/tasmota/xdrv_50_filesystem.ino index c20fcceac..d2729bd7c 100644 --- a/tasmota/xdrv_50_filesystem.ino +++ b/tasmota/xdrv_50_filesystem.ino @@ -60,9 +60,7 @@ ufsfree free size in kB #include #endif // USE_SDCARD #endif // ESP8266 - #ifdef ESP32 -#define FFS_2 #include #ifdef USE_SDCARD #include diff --git a/tasmota/xsns_83_neopool.ino b/tasmota/xsns_83_neopool.ino index 70524618d..c0902699c 100644 --- a/tasmota/xsns_83_neopool.ino +++ b/tasmota/xsns_83_neopool.ino @@ -656,23 +656,20 @@ void NeoPool250ms(void) // Every 250 mSec /*********************************************************************************************/ -void NeoPoolInit(void) -{ - if (NeoPoolInitData()) { - if (PinUsed(GPIO_NEOPOOL_RX) && PinUsed(GPIO_NEOPOOL_TX)) { - NeoPoolModbus = new TasmotaModbus(Pin(GPIO_NEOPOOL_RX), Pin(GPIO_NEOPOOL_TX)); - uint8_t result = NeoPoolModbus->Begin(NEOPOOL_MODBUS_SPEED); - if (result) { - if (2 == result) { - ClaimSerial(); - } -#ifdef NEOPOOL_OPTIMIZE_READINGS - neopool_first_read = true; -#endif // NEOPOOL_OPTIMIZE_READINGS - neopool_active = true; +void NeoPoolInit(void) { + neopool_active = false; + if (PinUsed(GPIO_NEOPOOL_RX) && PinUsed(GPIO_NEOPOOL_TX)) { + NeoPoolModbus = new TasmotaModbus(Pin(GPIO_NEOPOOL_RX), Pin(GPIO_NEOPOOL_TX)); + uint8_t result = NeoPoolModbus->Begin(NEOPOOL_MODBUS_SPEED); + if (result) { + if (2 == result) { + ClaimSerial(); } - else { - neopool_active = false; +#ifdef NEOPOOL_OPTIMIZE_READINGS + neopool_first_read = true; +#endif // NEOPOOL_OPTIMIZE_READINGS + if (NeoPoolInitData()) { // Claims heap space + neopool_active = true; } } } @@ -1314,32 +1311,28 @@ bool Xsns83(uint8_t function) { bool result = false; - switch (function) { - case FUNC_INIT: - NeoPoolInit(); - break; - case FUNC_EVERY_250_MSECOND: - if (neopool_active) { + if (FUNC_INIT == function) { + NeoPoolInit(); + } + else if (neopool_active) { + switch (function) { + case FUNC_EVERY_250_MSECOND: NeoPool250ms(); - } - break; - case FUNC_COMMAND_SENSOR: - if (XSNS_83 == XdrvMailbox.index) { - result = NeoPoolCmnd(); - } - break; - case FUNC_JSON_APPEND: - if (neopool_active) { + break; + case FUNC_COMMAND_SENSOR: + if (XSNS_83 == XdrvMailbox.index) { + result = NeoPoolCmnd(); + } + break; + case FUNC_JSON_APPEND: NeoPoolShow(1); - } - break; + break; #ifdef USE_WEBSERVER - case FUNC_WEB_SENSOR: - if (neopool_active) { + case FUNC_WEB_SENSOR: NeoPoolShow(0); - } - break; + break; #endif // USE_WEBSERVER + } } return result; }