Brute force signal causes bulb to "pause" on red
This commit is contained in:
parent
90210c8448
commit
120b8679ff
1 changed files with 26 additions and 16 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue