update
This commit is contained in:
parent
c02b42fae3
commit
8869e44147
21
server.js
21
server.js
@ -35,16 +35,14 @@ const sensehat = {
|
||||
flipV(redraw=true) 垂直反转
|
||||
getter and setter rotation 默认为 0
|
||||
setRotation(r, redraw=true) 设置旋转,r 初始为 0,r 只能设置为 0/90/180/270
|
||||
loadImage(filePath, redraw=true)
|
||||
showLetter(character, textColour=[255,255,255], backColour=[0,0,0])
|
||||
showMessage(textString, scrollSpeed=0.1(秒), textColour=[255,255,255], backColour=[0,0,0])
|
||||
flashMessage(textString, speed=0.1(秒), textColour=[255,255,255], backColour=[0,0,0])
|
||||
|
||||
# 未实现 # getter and setter lowLight 默认为 true
|
||||
# 未实现 # getter and setter gamma = Array of length 32 containing Integers between 0 and 31
|
||||
# 未实现 # gammaReset() 恢复默认 gamma
|
||||
|
||||
loadImage(filePath, redraw=true)
|
||||
|
||||
showLetter(character, textColour=[255,255,255], backColour=[0,0,0])
|
||||
showMessage(textString, scrollSpeed=0.1(秒), textColour=[255,255,255], backColour=[0,0,0])
|
||||
flashMessage(textString, speed=0.1(秒), textColour=[255,255,255], backColour=[0,0,0])
|
||||
*/
|
||||
get pixels() { return sensehat.led.getPixels() },
|
||||
},
|
||||
@ -56,10 +54,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, character, speed, backcolor }) => {
|
||||
client.on('action', ({ action, x, y, color, pixels, delay, image, character, speed, background, text }) => {
|
||||
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]
|
||||
if (background == undefined) background = [0, 0, 0]
|
||||
switch (action) {
|
||||
case 'clear':
|
||||
if (color == undefined) color = [0, 0, 0]
|
||||
@ -126,7 +124,12 @@ io.on('connection', (client) => {
|
||||
break
|
||||
case 'showLetter':
|
||||
if (color == undefined) color = [255, 255, 255]
|
||||
sensehat.led.showLetter(character, color, backcolor)
|
||||
sensehat.led.showLetter(character, color, background)
|
||||
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
|
||||
break
|
||||
case 'showMessage':
|
||||
if (color == undefined) color = [255, 255, 255]
|
||||
sensehat.led.showMessage(text, speed, color, background)
|
||||
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
|
||||
break
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user