diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 3032f5d8..a616b959 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -14,6 +14,7 @@ #define RELAY_MODE_OFF 0 #define RELAY_MODE_ON 1 #define RELAY_MODE_SAME 2 +#define RELAY_MODE_TOOGLE 3 #define RELAY_SYNC_ANY 0 #define RELAY_SYNC_NONE_OR_ONE 1 diff --git a/code/espurna/data/index.html.gz b/code/espurna/data/index.html.gz index 0f4ed804..c5969b9b 100644 Binary files a/code/espurna/data/index.html.gz and b/code/espurna/data/index.html.gz differ diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index 3a2c6b5f..d3ffab62 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -161,14 +161,17 @@ void relaySave() { EEPROM.commit(); } -void relayRetrieve() { +void relayRetrieve(bool invert) { recursive = true; unsigned char bit = 1; - unsigned char mask = EEPROM.read(0); + unsigned char mask = invert ? ~EEPROM.read(0) : EEPROM.read(0); for (unsigned int i=0; i < _relays.size(); i++) { relayStatus(i, ((mask & bit) == bit)); bit += bit; } + if (invert) { + relaySave(); + } recursive = false; } @@ -254,7 +257,8 @@ void relaySetup() { if (relayMode == RELAY_MODE_ON) relayStatus(i, true); } - if (relayMode == RELAY_MODE_SAME) relayRetrieve(); + if (relayMode == RELAY_MODE_SAME) relayRetrieve(false); + if (relayMode == RELAY_MODE_TOOGLE) relayRetrieve(true); mqttRegister(relayMQTTCallback); diff --git a/code/html/index.html b/code/html/index.html index 7c0736d4..f798147b 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -201,6 +201,7 @@