From f4b0e9fe5b19f8cc3bf030496e934e175b80c0e8 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Thu, 21 Nov 2019 17:28:10 +0300 Subject: [PATCH] relay: fix dummy relays overwriting real ones --- code/espurna/relay.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index bae0f3df..d8138ed0 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -44,9 +44,9 @@ typedef struct { Ticker pulseTicker; // Holds the pulse back timer } relay_t; + std::vector _relays; bool _relayRecursive = false; -Ticker _relaySaveTicker; uint8_t _relayDummy = DUMMY_RELAY_COUNT; unsigned long _relay_flood_window = (1000 * RELAY_FLOOD_WINDOW); @@ -248,7 +248,7 @@ void _relayProviderStatus(unsigned char id, bool status) { lightUpdate(true, true); return; - + } #endif @@ -1330,11 +1330,11 @@ void _relayLoop() { // 8 channels. This behaviour will be recovered with v2. void relaySetupDummy(unsigned char size, bool reconfigure) { - size = constrain(size, 0, RELAY_SAVE_MASK_MAX); + size = constrain(size + _relays.size(), _relays.size(), RELAY_SAVE_MASK_MAX); if (size == _relays.size()) return; _relayDummy = size; - _relays.assign(size, { + _relays.insert(_relays.end(), size, { GPIO_NONE, RELAY_TYPE_NORMAL, GPIO_NONE });