From 4134a4f0a3a74b8838fbfe9ed8bf2e03a600fdde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Mon, 25 Jul 2022 19:41:33 +0200 Subject: [PATCH] added strope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- main.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index f994fce..d8e3c23 100644 --- a/main.py +++ b/main.py @@ -41,7 +41,7 @@ def wheel(pos): pos -= 170 return Color(0, pos * 3, 255 - pos * 3) -def rainbowCycle( strip, wait_ms=5, iterations=10): +def rainbowCycle(strip, wait_ms=5, iterations=10): for j in range(256*iterations): if mode > 0: break @@ -58,6 +58,15 @@ def setColor(strip, color, wait_ms=10): strip.show() time.sleep(wait_ms/1000.0) +def strobe(strip, color): + for i in range(strip.numPixels()): + strip.setPixelColor(i, color) + strip.show() + time.sleep(float(0.01)) + for i in range(strip.numPixels()): + strip.setPixelColor(i, Color(0, 0, 0)) + strip.show() + def mqtt_on_connect(client, userdata, flags, rc): client.subscribe("server-rack-led/power") client.subscribe("server-rack-led/mode") @@ -121,6 +130,8 @@ if __name__ == '__main__': rainbowCycle(strip) elif mode == 1: setColor(strip, Color(int(r), int(g), int(b))) + elif mode == 2: + strobe(strip, Color(int(r), int(g), int(b))) else: setColor(strip, Color(0,0,0))