Delayed relay state saving into EEPROM

This commit is contained in:
Xose Pérez
2017-08-25 19:11:05 +02:00
parent f1f2e36177
commit 6ccd000280
2 changed files with 5 additions and 1 deletions

View File

@@ -196,6 +196,9 @@ PROGMEM const char* const custom_reset_string[] = {
// Pulse with in milliseconds for a latched relay
#define RELAY_LATCHING_PULSE 10
// Do not save relay state after these many milliseconds
#define RELAY_SAVE_DELAY 1000
//------------------------------------------------------------------------------
// I18N
//------------------------------------------------------------------------------

View File

@@ -29,6 +29,7 @@ typedef struct {
} relay_t;
std::vector<relay_t> _relays;
bool recursive = false;
Ticker _relaySaveTicker;
#if RELAY_PROVIDER == RELAY_PROVIDER_DUAL
unsigned char _dual_status = 0;
@@ -528,7 +529,7 @@ void relayLoop(void) {
if (!recursive) {
relayPulse(id);
relaySync(id);
relaySave();
_relaySaveTicker.once_ms(RELAY_SAVE_DELAY, relaySave);
#if WEB_SUPPORT
relayWS();
#endif