diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 01aa3e24..1ae81029 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -277,6 +277,7 @@ PROGMEM const char* const custom_reset_string[] = { #define RELAY_PROVIDER_DUAL 1 #define RELAY_PROVIDER_LIGHT 2 #define RELAY_PROVIDER_RFBRIDGE 3 +#define RELAY_PROVIDER_STM 4 // Default boot mode: 0 means OFF, 1 ON and 2 whatever was before #define RELAY_BOOT_MODE RELAY_BOOT_OFF diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index edbefa8c..68113df1 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -1394,6 +1394,20 @@ // ----------------------------------------------------------------------------- +#elif defined(STM_RELAY) + + // Info + #define MANUFACTURER "STM_RELAY" + #define DEVICE "2CH" + + // Relays + #define DUMMY_RELAY_COUNT 2 + #define RELAY_PROVIDER RELAY_PROVIDER_STM + + // Remove UART noise on serial line + #define TERMINAL_SUPPORT 0 + #define DEBUG_SERIAL_SUPPORT 0 + #endif // ----------------------------------------------------------------------------- diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index 65544f91..11ced058 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -77,6 +77,15 @@ void _relayProviderStatus(unsigned char id, bool status) { #endif + #if RELAY_PROVIDER == RELAY_PROVIDER_STM + Serial.flush(); + Serial.write(0xA0); + Serial.write(id + 1); + Serial.write(status); + Serial.write(0xA1 + status + id); + Serial.flush(); + #endif + #if RELAY_PROVIDER == RELAY_PROVIDER_LIGHT // If the number of relays matches the number of light channels @@ -453,7 +462,11 @@ void _relayBoot() { } _relays[i].current_status = !status; _relays[i].target_status = status; - _relays[i].change_time = millis(); + #ifdef RELAY_PROVIDER_STM + _relays[i].change_time = millis() + 3000 + 1000 * i; + #else + _relays[i].change_time = millis(); + #endif bit <<= 1; } diff --git a/code/platformio.ini b/code/platformio.ini index c85eedf8..de624ad3 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -1399,6 +1399,31 @@ upload_speed = 460800 monitor_baud = 115200 extra_scripts = ${common.extra_scripts} +[env:stm-relay-ota] +platform = ${common.platform} +framework = arduino +board = esp01_1m +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m} -DSTM_RELAY +monitor_baud = 115200 +extra_scripts = ${common.extra_scripts} + +[env:stm-relay-ota] +platform = ${common.platform} +framework = arduino +board = esp01_1m +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m} -DSTM_RELAY +upload_speed = 115200 +upload_port = "192.168.4.1" +upload_flags = --auth=fibonacci --port 8266 +monitor_baud = 115200 +extra_scripts = ${common.extra_scripts} + # ------------------------------------------------------------------------------ # GENERIC OTA ENVIRONMENTS # ------------------------------------------------------------------------------