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: '*' } })
|
const io = require('socket.io')(server, { cors: { origin: '*' } })
|
||||||
io.on('connection', (client) => {
|
io.on('connection', (client) => {
|
||||||
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
|
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
|
||||||
client.on('action', ({ action, x, y, color, pixels, delay, image }) => {
|
client.on('action', ({ action, x, y, color, pixels, delay, image, character, speed, backcolor }) => {
|
||||||
x = Number(x), y = Number(y), delay = Number(delay) | 200
|
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) {
|
switch (action) {
|
||||||
case 'clear':
|
case 'clear':
|
||||||
if (color == undefined) color = [0, 0, 0]
|
if (color == undefined) color = [0, 0, 0]
|
||||||
@ -122,6 +124,10 @@ io.on('connection', (client) => {
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
case 'showLetter':
|
||||||
|
sensehat.led.showLetter(character)
|
||||||
|
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user