From a75b2e15d905e14d301b3a64bfe69a9e0f5bbc42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Sat, 2 Jul 2022 10:22:04 +0200 Subject: [PATCH] removed animation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- main.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 894aa80..ff58a91 100644 --- a/main.py +++ b/main.py @@ -29,7 +29,7 @@ def debug_print(message: str): current_time = now.strftime("%H:%M:%S") print('[DEBUG]['+current_time+'] '+message) -def wheel(pos): +def wheel(client, pos): if pos < 85: return Color(pos * 3, 255 - pos * 3, 0) elif pos < 170: @@ -39,14 +39,14 @@ def wheel(pos): pos -= 170 return Color(0, pos * 3, 255 - pos * 3) -def rainbowCycle(strip, wait_ms=5, iterations=10): +def rainbowCycle(client, strip, wait_ms=5, iterations=10): for j in range(256*iterations): if mode > 0: break elif power == "False": break for i in range(strip.numPixels()): - strip.setPixelColor(i, wheel((int(i * 256 / strip.numPixels()) + j) & 255)) + strip.setPixelColor(i, wheel(client, (int(i * 256 / strip.numPixels()) + j) & 255)) strip.show() time.sleep(wait_ms/1000.0) @@ -117,11 +117,7 @@ if __name__ == '__main__': while True: if power == "True": if mode == 0: - rainbowCycle(strip) - animation_r = 255 - animation_g = 0 - animation_b = 0 - client.publish("server-rack-led/rgb", str(animation_r)+","+str(animation_g)+","+str(animation_b)) + rainbowCycle(client, strip) elif mode == 1: setColor(strip, Color(int(r), int(g), int(b))) time.sleep(1)