Improve relay state tracking

This commit is contained in:
IMback
2017-11-05 17:41:40 +01:00
parent 21b636aa98
commit 1a932993ba
6 changed files with 10 additions and 1 deletions

View File

@ -59,6 +59,7 @@ void WirelessRelay::on()
sendBit(false);
sync();
}
_state = true;
}
void WirelessRelay::off()
@ -70,6 +71,7 @@ void WirelessRelay::off()
sendBit(true);
sync();
}
_state = false;
}
uint16_t WirelessRelay::getId()
@ -77,6 +79,11 @@ uint16_t WirelessRelay::getId()
return _id;
}
bool WirelessRelay::getExpectedState()
{
return _state;
}
void WirelessRelay::init( volatile unsigned char *port, const unsigned char pin, const uint16_t id)
{

View File

@ -10,6 +10,7 @@
class WirelessRelay
{
private:
bool _state = false;
uint16_t _id;
volatile unsigned char *_port;
unsigned char _pin;
@ -24,5 +25,6 @@ public:
void on();
void off();
uint16_t getId();
bool getExpectedState();
};
#endif

View File

@ -99,7 +99,7 @@ void relayDispatch(WirelessRelayStore* relays, char* inBuffer, Serial* serial)
serial->write("ST");
serial->write(relays->count);
serial->putChar(',');
for(uint8_t i = 0; i < relays->count; i++) relays->states[i] ? serial->putChar('1') : serial->putChar('0');
for(uint8_t i = 0; i < relays->count; i++) relays->array[i].getExpectedState() ? serial->putChar('1') : serial->putChar('0');
serial->putChar('\n');
}
else

Binary file not shown.