From 34c73dd9888b1920cbdc9b0debd0a8f1da3bc4a1 Mon Sep 17 00:00:00 2001 From: Zhao Xin <7176466@qq.com> Date: Mon, 5 Sep 2022 12:09:18 +0800 Subject: [PATCH] update --- server.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server.js b/server.js index 24e935c..4a89312 100644 --- a/server.js +++ b/server.js @@ -27,6 +27,7 @@ const sensehat = { sleep(n) 暂停 n 秒 clear() 清除所有 clear(rgb) or clear([r,g,b]) 填充颜色 + setPixel(x,y,r,g,b) or setPixel(x,y,rgb) 设置一个点 getPixel(x,y) 返回 [r,g,b] 获取一个点 setPixels([[r,g,b]*64]) @@ -74,15 +75,15 @@ io.on('connection', (client) => { io.emit('action', { action: 'clear' }) }, delay | 200) 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': // color = sensehat.led.getPixel(x, y) // client.emit('action', { action: 'setPixel', x, y, color }) // 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': io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels }) break