Last active
November 11, 2017 21:53
-
-
Save traumverloren/e809121755da2d48717b69af2d945127 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let strip = light.createNeoPixelStrip(pins.A1, 9, NeoPixelMode.RGBW); | |
let isPaused = false; | |
let needsSetup = true; | |
const setupStrip = () => { | |
strip.setPixelColor(0, Colors.Red); | |
strip.setPixelColor(1, Colors.Orange); | |
strip.setPixelColor(2, Colors.Yellow); | |
strip.setPixelColor(3, Colors.Green); | |
strip.setPixelColor(4, Colors.Blue); | |
strip.setPixelColor(5, Colors.Blue); | |
strip.setPixelColor(6, Colors.Indigo); | |
strip.setPixelColor(7, Colors.Violet); | |
strip.setPixelColor(8, Colors.Pink); | |
strip.show(); | |
needsSetup = false; | |
} | |
loops.forever(() => { | |
if (needsSetup) { | |
setupStrip(); | |
} | |
if (!isPaused) { | |
light.showAnimation(light.rainbowAnimation, 100); | |
strip.move(LightMove.Rotate, 1); | |
} | |
}) | |
input.onGesture(Gesture.Shake, () => { | |
strip.stopAllAnimations(); | |
strip.showAnimation(light.sparkleAnimation, 1000); | |
needsSetup = true; | |
}); | |
input.buttonA.onEvent(ButtonEvent.Click, () => { | |
strip.stopAllAnimations(); | |
light.stopAllAnimations(); | |
strip.clear(); | |
light.clear(); | |
isPaused = true; | |
}) | |
input.buttonB.onEvent(ButtonEvent.Click, () => { | |
isPaused = false; | |
needsSetup = true; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment