Skip to content

Instantly share code, notes, and snippets.

@moredhel
Created November 3, 2019 16:59
Show Gist options
  • Save moredhel/3979224793633e1a3ad63ab264d3a6f0 to your computer and use it in GitHub Desktop.
Save moredhel/3979224793633e1a3ad63ab264d3a6f0 to your computer and use it in GitHub Desktop.
AdaFruit Fun
input.buttonB.onEvent(ButtonEvent.Click, function () {
p2 = (p2 + 1) % max
})
input.buttonA.onEvent(ButtonEvent.Click, function () {
p1 = (p1 + 1) % max
})
input.onGesture(Gesture.Shake, function () {
p1 = 0
p2 = 0
})
let max = 6
let p2 = 0
let p1 = 0
function P1Set(v: number) {
for (let i = 0; i < max; i++) {
if (v > i) {
light.setPixelColor(i, 0xbbff00)
} else {
light.setPixelColor(i, 0x000000)
}
}
}
function P2Set(v: number) {
for (let i = 5; i < max + 5; i++) {
if (v + 5 > i) {
light.setPixelColor(i, 0xff00ff)
} else {
light.setPixelColor(i, 0x000000)
}
}
}
forever(function () {
P1Set(p1)
P2Set(p2)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment