Brute force signal causes bulb to "pause" on red

This commit is contained in:
Robert Marshall 2022-12-31 12:30:58 +00:00
parent 90210c8448
commit 120b8679ff

View file

@ -20,6 +20,7 @@ PWMOutput _red(4);
PWMOutput _green(12);
PWMOutput _blue(14);
byte _stage;
bool _partyMode;
Timer _colourTimer([] {
switch (_stage)
@ -49,26 +50,35 @@ Timer _colourTimer([] {
_stage = 0;
}, 1000);
void partyOn() {
if (_partyMode)
return;
_partyMode = true;
_colourTimer.reset();
_warmWhite.off();
_red.on();
_green.off();
_blue.off();
_stage = 1;
}
void partyOff() {
_partyMode = false;
_colourTimer.stop();
_warmWhite.on();
_red.off();
_green.off();
_blue.off();
}
void OnDataRecv(uint8_t* mac, uint8_t* incomingData, uint8_t len) {
int on;
bool on;
memcpy(&on, incomingData, sizeof(on));
Serial.print("ESP-NOW: ");
Serial.println(on);
if (on) {
_colourTimer.reset();
_warmWhite.off();
_red.on();
_green.off();
_blue.off();
_stage = 1;
} else {
_colourTimer.stop();
_warmWhite.on();
_red.off();
_green.off();
_blue.off();
}
on ? partyOn() : partyOff();
}
void setupReceiver() {
@ -86,7 +96,7 @@ void setupReceiver() {
void setup() {
Serial.begin(115200);
_warmWhite.setValue(178);
_warmWhite.setValue(128);
_warmWhite.on();
WiFi.mode(WIFI_AP_STA);