update
This commit is contained in:
parent
96e35d2ac4
commit
eb7272697f
@ -19,8 +19,10 @@ const leds = [
|
||||
[0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0],
|
||||
]
|
||||
read_all_leds()
|
||||
|
||||
io.on('connection', (client) => {
|
||||
read_all_leds()
|
||||
client.on('action', ({ action, x, y }) => {
|
||||
console.log({ action, x, y })
|
||||
switch (action) {
|
||||
@ -49,13 +51,10 @@ io.on('connection', (client) => {
|
||||
default:
|
||||
break
|
||||
}
|
||||
read_all_leds()
|
||||
})
|
||||
})
|
||||
|
||||
function read_led(x, y) {
|
||||
sense.getPixel(x, y)
|
||||
}
|
||||
|
||||
function read_all_leds() {
|
||||
const pixels = sense.getPixels()
|
||||
for (let y = 0; y < 8; y++) {
|
||||
@ -63,6 +62,5 @@ function read_all_leds() {
|
||||
leds[y][x] = sense.getPixel(x, y)[2] == 0 ? 0 : 1
|
||||
}
|
||||
}
|
||||
console.log(leds)
|
||||
io.emit('leds', leds)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user