Browse Source

Merge pull request #6 from phuonglm/espurna/revert-state

* revert-state:
  Enable revert state mode
  Enable revert state mode
fastled
Xose Pérez 8 years ago
parent
commit
f7ca11b0ee
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_ON 1
#define RELAY_MODE_SAME 2
#define RELAY_MODE_TOOGLE 3
#define RELAY_SYNC_ANY 0
#define RELAY_SYNC_NONE_OR_ONE 1


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


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

@ -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();


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

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


Loading…
Cancel
Save