This commit is contained in:
赵鑫 2022-09-05 12:09:18 +08:00
parent 4885029570
commit 34c73dd988

View File

@ -27,6 +27,7 @@ const sensehat = {
sleep(n) 暂停 n sleep(n) 暂停 n
clear() 清除所有 clear() 清除所有
clear(rgb) or clear([r,g,b]) 填充颜色 clear(rgb) or clear([r,g,b]) 填充颜色
setPixel(x,y,r,g,b) or setPixel(x,y,rgb) 设置一个点 setPixel(x,y,r,g,b) or setPixel(x,y,rgb) 设置一个点
getPixel(x,y) 返回 [r,g,b] 获取一个点 getPixel(x,y) 返回 [r,g,b] 获取一个点
setPixels([[r,g,b]*64]) setPixels([[r,g,b]*64])
@ -74,15 +75,15 @@ io.on('connection', (client) => {
io.emit('action', { action: 'clear' }) io.emit('action', { action: 'clear' })
}, delay | 200) }, delay | 200)
break break
case 'setPixel':
if (color == undefined) color = [255, 255, 255]
sensehat.led.setPixel(x, y, color)
io.emit('action', { action: 'setPixel', x, y, color })
break
// case 'getPixel': // case 'getPixel':
// color = sensehat.led.getPixel(x, y) // color = sensehat.led.getPixel(x, y)
// client.emit('action', { action: 'setPixel', x, y, color }) // client.emit('action', { action: 'setPixel', x, y, color })
// break // break
// case 'setPixel':
// if (color == undefined) color = [255, 255, 255]
// sensehat.led.setPixel(x, y, color)
// io.emit('action', { action: 'setPixel', x, y, color })
// break
case 'getPixels': case 'getPixels':
io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels }) io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels })
break break