From 6a6aaf21673a7235d597bd29a404294f7e327435 Mon Sep 17 00:00:00 2001 From: Zhao Xin <7176466@qq.com> Date: Mon, 5 Sep 2022 14:19:37 +0800 Subject: [PATCH] update --- server.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 4859900..e2202d1 100644 --- a/server.js +++ b/server.js @@ -31,10 +31,10 @@ const sensehat = { getPixel(x,y) 返回 [r,g,b] 获取一个点 setPixels([[r,g,b]*64]) getPixels() -> [[r,g,b]*64] - flipH(redraw=true) 水平反转 flipV(redraw=true) 垂直反转 + setRotation(r, redraw=true) 设置旋转,r 初始为 0,r 只能设置为 0/90/180/270 getter and setter rotation 默认为 0 @@ -104,6 +104,14 @@ io.on('connection', (client) => { sensehat.led.flipV() io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels }) break + case 'turnLeft': + sensehat.led.rotation = ((sensehat.led.rotation - 90) + 360) % 360 + io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels }) + break + case 'turnRight': + sensehat.led.rotation = (sensehat.led.rotation + 90) % 360 + io.emit('action', { action: 'setPixels', pixels: sensehat.led.pixels }) + break // case 'on': // sense.setPixel(Number(x), Number(y), color_blue) // leds[y][x] = 1