Browse Source

relay: fix dummy relays overwriting real ones

master
Maxim Prokhorov 5 years ago
parent
commit
f4b0e9fe5b
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      code/espurna/relay.ino

+ 4
- 4
code/espurna/relay.ino View File

@ -44,9 +44,9 @@ typedef struct {
Ticker pulseTicker; // Holds the pulse back timer Ticker pulseTicker; // Holds the pulse back timer
} relay_t; } relay_t;
std::vector<relay_t> _relays; std::vector<relay_t> _relays;
bool _relayRecursive = false; bool _relayRecursive = false;
Ticker _relaySaveTicker;
uint8_t _relayDummy = DUMMY_RELAY_COUNT; uint8_t _relayDummy = DUMMY_RELAY_COUNT;
unsigned long _relay_flood_window = (1000 * RELAY_FLOOD_WINDOW); unsigned long _relay_flood_window = (1000 * RELAY_FLOOD_WINDOW);
@ -248,7 +248,7 @@ void _relayProviderStatus(unsigned char id, bool status) {
lightUpdate(true, true); lightUpdate(true, true);
return; return;
} }
#endif #endif
@ -1330,11 +1330,11 @@ void _relayLoop() {
// 8 channels. This behaviour will be recovered with v2. // 8 channels. This behaviour will be recovered with v2.
void relaySetupDummy(unsigned char size, bool reconfigure) { 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; if (size == _relays.size()) return;
_relayDummy = size; _relayDummy = size;
_relays.assign(size, {
_relays.insert(_relays.end(), size, {
GPIO_NONE, RELAY_TYPE_NORMAL, GPIO_NONE GPIO_NONE, RELAY_TYPE_NORMAL, GPIO_NONE
}); });


Loading…
Cancel
Save