working version, simplified demo mode only
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user