update
This commit is contained in:
parent
06c7bc32a4
commit
6ec7b80b3e
10
server.js
10
server.js
@ -56,8 +56,10 @@ sensehat.led.loadImage('images/heart.png')
|
||||
const io = require('socket.io')(server, { cors: { origin: '*' } })
|
||||
io.on('connection', (client) => {
|
||||
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
|
||||
client.on('action', ({ action, x, y, color, pixels, delay, image }) => {
|
||||
x = Number(x), y = Number(y), delay = Number(delay) | 200
|
||||
client.on('action', ({ action, x, y, color, pixels, delay, image, character, speed, backcolor }) => {
|
||||
x = Number(x), y = Number(y), delay = Number(delay) | 200, speed = Number(speed) | 0.2
|
||||
if (character == undefined) character = ' '
|
||||
if (backcolor == undefined) backcolor = [0, 0, 0]
|
||||
switch (action) {
|
||||
case 'clear':
|
||||
if (color == undefined) color = [0, 0, 0]
|
||||
@ -122,6 +124,10 @@ io.on('connection', (client) => {
|
||||
console.error(error)
|
||||
}
|
||||
break
|
||||
case 'showLetter':
|
||||
sensehat.led.showLetter(character)
|
||||
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user