Beat-Handler eingebaut, Vorbereitung für Strobo-Effekt

This commit is contained in:
starcalc 2017-11-25 13:43:59 +01:00
parent a214c0d776
commit 862c2179c0
1 changed files with 58 additions and 0 deletions

View File

@ -20,6 +20,7 @@ int w1;
int w2;
int w3;
int step = 0;
int strobo = 1;
bool disco = false;
int lastEvent = 0;
@ -36,6 +37,62 @@ bool speedHandler(const HomieRange& range, const String& value) {
return true;
}
bool stroboToggleHandler(const HomieRange& range, const String& value) {
Homie.getLogger() << "stroboToggle " << ": " << value << endl;
lightNode.setProperty("stroboToggle").send(value);
strobo *= -1;
if (strobo == 1)
{
w0 = w1 = w2 = w3 = FULL;
}
else
{
w0 = w1 = w2 = w3 = OFF;
}
output();
}
bool beatHandler(const HomieRange& range, const String& value) {
Homie.getLogger() << "beat " << ": " << value << endl;
lightNode.setProperty("beat").send(value);
if (step >= 4) {
step = 0;
}
// Cycle each light from 255 to 50 to 1 to off
switch (step)
{
case 0:
w0 = FULL;
w1 = OFF;
w2 = MINIMUM;
w3 = LOWER;
break;
case 1:
w1 = FULL;
w2 = OFF;
w3 = MINIMUM;
w0 = LOWER;
break;
case 2:
w2 = FULL;
w3 = OFF;
w0 = MINIMUM;
w1 = LOWER;
break;
case 3:
w3 = FULL;
w0 = OFF;
w1 = MINIMUM;
w2 = LOWER;
break;
default:
w0 = w1 = w2 = w3 = 0;
break;
}
output();
step++;
}
bool discoHandler(const HomieRange& range, const String& value) {
Homie.getLogger() << "disco " << ": " << value << endl;
lightNode.setProperty("disco").send(value);
@ -177,6 +234,7 @@ void setup() {
lightNode.advertise("speed").settable(speedHandler);
lightNode.advertise("disco").settable(discoHandler);
lightNode.advertise("beat").settable(beatHandler);
lightNode.advertise("light").settable(lightHandler);
lightNode.advertise("light0").settable(light0Handler);
lightNode.advertise("light1").settable(light1Handler);