Browse Source

Enable revert state mode

fastled
Ly Minh Phuong 7 years ago
parent
commit
db51756bf5
4 changed files with 9 additions and 3 deletions
  1. +1
    -0
      code/espurna/config/general.h
  2. BIN
      code/espurna/data/index.html.gz
  3. +7
    -3
      code/espurna/relay.ino
  4. +1
    -0
      code/html/index.html

+ 1
- 0
code/espurna/config/general.h View File

@ -14,6 +14,7 @@
#define RELAY_MODE_OFF 0 #define RELAY_MODE_OFF 0
#define RELAY_MODE_ON 1 #define RELAY_MODE_ON 1
#define RELAY_MODE_SAME 2 #define RELAY_MODE_SAME 2
#define RELAY_MODE_TOOGLE 3
#define RELAY_SYNC_ANY 0 #define RELAY_SYNC_ANY 0
#define RELAY_SYNC_NONE_OR_ONE 1 #define RELAY_SYNC_NONE_OR_ONE 1


BIN
code/espurna/data/index.html.gz View File


+ 7
- 3
code/espurna/relay.ino View File

@ -161,14 +161,17 @@ void relaySave() {
EEPROM.commit(); EEPROM.commit();
} }
void relayRetrieve() {
void relayRetrieve(bool invert) {
recursive = true; recursive = true;
unsigned char bit = 1; 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++) { for (unsigned int i=0; i < _relays.size(); i++) {
relayStatus(i, ((mask & bit) == bit)); relayStatus(i, ((mask & bit) == bit));
bit += bit; bit += bit;
} }
if (invert) {
relaySave();
}
recursive = false; recursive = false;
} }
@ -254,7 +257,8 @@ void relaySetup() {
if (relayMode == RELAY_MODE_ON) relayStatus(i, true); 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); mqttRegister(relayMQTTCallback);


+ 1
- 0
code/html/index.html View File

@ -201,6 +201,7 @@
<option value="0">Always OFF</a> <option value="0">Always OFF</a>
<option value="1">Always ON</a> <option value="1">Always ON</a>
<option value="2">Same as before</a> <option value="2">Same as before</a>
<option value="3">Toogle before</a>
</select> </select>
</div> </div>
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div> <div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>


Loading…
Cancel
Save