From 96cb3061e5020f51d7bc52d829b6a41afec68332 Mon Sep 17 00:00:00 2001 From: L3D Date: Sun, 24 Mar 2024 23:30:32 +0100 Subject: [PATCH] fasten up animation --- rgb_rainbow.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rgb_rainbow.py b/rgb_rainbow.py index f7dc7eb..57cda22 100755 --- a/rgb_rainbow.py +++ b/rgb_rainbow.py @@ -9,7 +9,7 @@ from rpi_ws281x import Adafruit_NeoPixel, Color # NeoPixel configuration PIN_NEO_PIXEL = 18 NUM_PIXELS = 24 -DELAY_INTERVAL = 0.01 +DELAY_INTERVAL = 0.001 # Create NeoPixel object NeoPixel = Adafruit_NeoPixel(NUM_PIXELS, PIN_NEO_PIXEL) @@ -19,11 +19,12 @@ def wheel(pos): """Generate rainbow colors across 0-255 positions.""" pos = pos % 256 # Ensure pos stays within 0-255 range if pos < 85: - return Color(int(pos * 3), int(255 - pos * 3), 0) - if pos < 170: - pos -= 85 - return Color(int(255 - pos * 3), 0, int(pos * 3)) - return Color(0, int(pos * 3), int(255 - pos * 3)) + return Color(pos * 3, 255 - pos * 3, 0) + pos -= 85 + if pos < 85: + return Color(255 - pos * 3, 0, pos * 3) + pos -= 85 + return Color(0, pos * 3, 255 - pos * 3) try: while True: