diff --git a/server.js b/server.js index 8c7f4f8..5e93752 100644 --- a/server.js +++ b/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 }