working version, simplified demo mode only

This commit is contained in:
Dirk Jahnke 2017-11-15 20:54:45 +01:00
parent a8206eb465
commit f6a3f4a5f3
1 changed files with 11 additions and 4 deletions

View File

@ -17,10 +17,11 @@ let colors = {
let LightAnimation = {
numberOfBulbs: 3,
ledPin: 4,
numberOfBulbs: 11,
ledPin: 2,
running: false,
mode: "demo",
generalBrightnessDivider: 3,
colorSequence: [
colors.dimmedWhite,
colors.red,
@ -42,11 +43,13 @@ let LightAnimation = {
RPC.addHandler('HouseLightning.Start', function(args) {
LightAnimation.running = true;
LightAnimation.mode = "run";
return {result: 'ok'};
}, null);
RPC.addHandler('HouseLightning.Stop', function(args) {
LightAnimation.running = false;
LightAnimation.running = true; // first we want to turn off LEDs, thus needs stop-mode
LightAnimation.mode = "stop";
return {result: 'ok'};
}, null);
@ -111,7 +114,7 @@ function runNeopixel(strip, shiftBy) {
for (i=0; i<LightAnimation.numberOfBulbs; ++i) {
colorIndex = shiftBy % LightAnimation.colorSequence.length;
color = LightAnimation.colorSequence[colorIndex];
strip.setPixel(i, color.r, color.g, color.b);
strip.setPixel(i, color.r/LightAnimation.generalBrightnessDivider, color.g/LightAnimation.generalBrightnessDivider, color.b/LightAnimation.generalBrightnessDivider);
// print("runNeo shift =", shiftBy, ", colorIndex =", colorIndex, ", r =", color.r, ", g =", color.g, ", b =", color.b);
shiftBy++;
}
@ -150,6 +153,10 @@ Timer.set(1990 /* msec */, true /* repeat */, function() {
runNeopixel(strip, shiftAnimation);
shiftAnimation++;
print("*** demo-mode, next shift=", shiftAnimation);
} else if (LightAnimation.mode === "stop") {
strip.clear();
strip.show();
LightAnimation.running = false;
} else print("*** no-ack, mode =", LightAnimation.mode);
} else print("*** stopped");
}, null);