diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 3d78446c..4d0e3b5a 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 ef0a84a5..4e3c56dc 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 68a5c760..433e3610 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -212,14 +212,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; } @@ -454,7 +457,8 @@ void relaySetup() { if (relayMode == RELAY_MODE_OFF) relayStatus(i, false); 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); relaySetupAPI(); relaySetupMQTT(); diff --git a/code/html/index.html b/code/html/index.html index 51556ae8..9e2448f7 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -201,6 +201,7 @@