gitpush
This commit is contained in:
parent
abcbb8ee6b
commit
71aac88c7f
35
server.js
35
server.js
@ -84,23 +84,18 @@ io.on('connection', (client) => {
|
||||
client.emit('action', { action: 'setPixel', x, y, color })
|
||||
break
|
||||
|
||||
case 'flash':
|
||||
if (color == undefined) color = [255, 255, 255]
|
||||
sensehat.led.clear(color)
|
||||
io.emit('action', { action: 'clear', color })
|
||||
setTimeout(() => {
|
||||
sensehat.led.clear()
|
||||
io.emit('action', { action: 'clear' })
|
||||
}, delay)
|
||||
break
|
||||
|
||||
case 'setPixels':
|
||||
for (let i = 0; i < pixels.length; i++) {
|
||||
var color = pixels[i]
|
||||
var x = i % 8
|
||||
var y = Math.floor(i / 8)
|
||||
pixels.forEach((color, i) = {
|
||||
let x = i % 8
|
||||
let y = Math.floor(i / 8)
|
||||
sensehat.led.setPixel(x, y, color)
|
||||
}
|
||||
})
|
||||
|
||||
// for (let i = 0; i < pixels.length; i++) {
|
||||
// var color = pixels[i]
|
||||
// var x = i % 8
|
||||
// var y = Math.floor(i / 8)
|
||||
// }
|
||||
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
|
||||
break
|
||||
|
||||
@ -160,6 +155,16 @@ io.on('connection', (client) => {
|
||||
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
|
||||
break
|
||||
|
||||
case 'flash':
|
||||
if (color == undefined) color = [255, 255, 255]
|
||||
sensehat.led.clear(color)
|
||||
io.emit('action', { action: 'clear', color })
|
||||
setTimeout(() => {
|
||||
sensehat.led.clear()
|
||||
io.emit('action', { action: 'clear' })
|
||||
}, delay)
|
||||
break
|
||||
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user