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 })
|
client.emit('action', { action: 'setPixel', x, y, color })
|
||||||
break
|
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':
|
case 'setPixels':
|
||||||
for (let i = 0; i < pixels.length; i++) {
|
pixels.forEach((color, i) = {
|
||||||
var color = pixels[i]
|
let x = i % 8
|
||||||
var x = i % 8
|
let y = Math.floor(i / 8)
|
||||||
var y = Math.floor(i / 8)
|
|
||||||
sensehat.led.setPixel(x, y, color)
|
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 })
|
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -160,6 +155,16 @@ io.on('connection', (client) => {
|
|||||||
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
|
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
|
||||||
break
|
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:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user