From db51756bf512ab8e6a59c8c9eb9e6fa3ce18273b Mon Sep 17 00:00:00 2001 From: Ly Minh Phuong Date: Sat, 21 Jan 2017 21:03:47 +0700 Subject: [PATCH 1/2] Enable revert state mode --- code/espurna/config/general.h | 1 + code/espurna/data/index.html.gz | Bin 3547 -> 3557 bytes code/espurna/relay.ino | 10 +++++++--- code/html/index.html | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) 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 0f4ed80475d5713134ac395ef4e32060d9b5a39c..c5969b9bdd31fa6272404cc236d941fcfa469a0d 100644 GIT binary patch literal 3557 zcmVP#AMcml%#e~L*-qkDx+ofp6giw1=S6Cd|8{XOzv4Gq7zStDl>j= znDkZRF*8lYi6>(|7M;hI?F%z8I`KyQ0h?|3<2kSik74kG6q6Kycnn?}k-#z&8JO@S z5HLfusIe~-X(W$Y+UJotIjrMgrjgL05T;m+dfL9$Fs@^X9I9a2I}YRnlfj7>@u|uU zyyb4jH?c@^kKW87Q5CR(l=$Itb*5Hp#K zy(aH1^gNoM5lL-`_W4)Rh`36Sw`ev}6>!6$mnQ<)X}HOOOLv3Q!KXVSs1wO8E-)5} z$av)Se!952xIO*2gC(@^^Gup4P;qhg>9#-kZ3l}?e+&lC z181=c@<_O!R^WeGdAUHv%1E4eetmg8=%4+*^0KL#th_AD5t-M!x&C}{J6o`mN3~rO zbD6Y;xiKoi-D{s};9ZyfY2_)bA-vuv`aSO0?jC!7W+uSkB*F*Q-xiOn%?F!^bK$3) zciaJ5>VGT5ISbdY6UZHFdTN`Jkr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zL8CYsu#CI*P(42rEw~CS&TXzaRv4!8v1GL85==DGg?d34XUq(8 zIizCjat2T|Kg?5yCr)t@13U(=2rO-q&&(($4rVE6Br()N7?x-wvjC!M1dOxR63*tv z$DD*1Wby+R(|BFcCpYz_Llq0EVu2LIx)ARlRZ>g{b&?1|gHT2wt23{(_U4C1bCliT zy&_8&K5j~t0keRn?<*v=Ya|_i_;9jATE3`4M)c(=Zp zS@b@`fSnwnccDhwQP|_6B7DzlqG%b}z z_^eEIw2FENQMaI-+2W@Z7LU(YmwB)>=1-888QKnW4xE^mSt<~_A@v`zjX@1K(SZAy zEiU8(f?byjIOnxI;K_^u^%w~hOQyO;I*PA%w+bW#7O5UWaTVT+;+1&P)04_OoII zn7v+IJ=f#G^WsyzSL&daqnGc!YnVBAM_VrA4`%WJ1f#4^4^rEw&WUf91H7 z-_W=q_t$+=zJ;=m3X&4U(m`@{kp+>?hq7|MukX5}JqA8KK^~|ED}3-^T^Oc|XpA$3 z&TX-hMf?%6b zaPoES9g4QN0`V6UF5;!|nn#mdVO`r=mGZ_0mbguCOoMqJN{|?0i2Hp+eI9W=J;Vk| z@=p+8aSg`_(6x6cz~V;EUrd1KcvVs1wWBS!rwQWG+QLTF69(H9d-Ozt;Rd%NGbcfH zNO%(*fb~4BnMbJP5q3xCo&#u!6TnMm;6gCs9ofL!!kBPCa1&Kov!q^<=6&fShq9yD zacO;i#XZ-KucdLGcq7E7dcf7&8{@e_ib@gBeo*4!ixdNR6LF8sC8p^*mEi?fmTL7> zyhR(CwH)R;?|A*jH_Z4xCv~>#GwTd6EnJly8D#XVbgM^}A$(_OJa15|p3vL=%Dd4{x@qfO{VjWLH006^OvMm4r 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 @@