From 6d9c4b2f3387627f7582497d33672ab93b465450 Mon Sep 17 00:00:00 2001 From: topsinoty Date: Fri, 19 Dec 2025 15:42:39 +0200 Subject: [PATCH 1/4] add generated christmas lights --- pyleds/program/promise/christmas_lights.py | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 pyleds/program/promise/christmas_lights.py diff --git a/pyleds/program/promise/christmas_lights.py b/pyleds/program/promise/christmas_lights.py new file mode 100644 index 0000000..af021ae --- /dev/null +++ b/pyleds/program/promise/christmas_lights.py @@ -0,0 +1,38 @@ +from pyleds.lib.Program import Program +from rpi_ws281x import Color +import time + +def name(): + return 'Christmas Lights' + +class Christmas(Program): + def run(self, args: [] = None): + # Configuration + wait_ms = 100 # Speed of the animation + + # Define classic festive colors + RED = Color(255, 0, 0) + GREEN = Color(0, 255, 0) + WARM_WHITE = Color(200, 180, 60) # A golden-ish warm white + + colors = [RED, GREEN, WARM_WHITE] + + # This determines how many pixels of the same color are next to each other + group_size = 2 + + offset = 0 + while self.get_loop().status(): + num_pixels = self._lm.count_pixels() + + for i in range(num_pixels): + # Calculate which color index to use based on pixel position and current offset + # This creates the "moving" effect + color_index = ((i + offset) // group_size) % len(colors) + self._lm.set_pixel_color(i, colors[color_index]) + + self._lm.show() + + # Increment offset to move the lights + offset = (offset + 1) % (len(colors) * group_size) + + time.sleep(wait_ms / 1000.0) -- 2.47.2 From d811b853a19944f0cb7cec792587f295d5d09790 Mon Sep 17 00:00:00 2001 From: topsinoty Date: Sun, 21 Dec 2025 15:54:53 +0200 Subject: [PATCH 2/4] change lib source to module --- pyleds/program/promise/christmas_lights.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyleds/program/promise/christmas_lights.py b/pyleds/program/promise/christmas_lights.py index af021ae..8129b1e 100644 --- a/pyleds/program/promise/christmas_lights.py +++ b/pyleds/program/promise/christmas_lights.py @@ -1,4 +1,4 @@ -from pyleds.lib.Program import Program +from lib.Program import Program from rpi_ws281x import Color import time -- 2.47.2 From a71201d90a609d701c789d5223c59c1c8a190d29 Mon Sep 17 00:00:00 2001 From: topsinoty Date: Sun, 21 Dec 2025 16:01:37 +0200 Subject: [PATCH 3/4] change to pascal case. --- .../program/promise/{christmas_lights.py => ChristmasLights.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename pyleds/program/promise/{christmas_lights.py => ChristmasLights.py} (97%) diff --git a/pyleds/program/promise/christmas_lights.py b/pyleds/program/promise/ChristmasLights.py similarity index 97% rename from pyleds/program/promise/christmas_lights.py rename to pyleds/program/promise/ChristmasLights.py index 8129b1e..925d96b 100644 --- a/pyleds/program/promise/christmas_lights.py +++ b/pyleds/program/promise/ChristmasLights.py @@ -5,7 +5,7 @@ import time def name(): return 'Christmas Lights' -class Christmas(Program): +class ChristmasLights(Program): def run(self, args: [] = None): # Configuration wait_ms = 100 # Speed of the animation -- 2.47.2 From ffa77db05770c1818de2c4a64b0634f62e722dc4 Mon Sep 17 00:00:00 2001 From: topsinoty Date: Sun, 21 Dec 2025 16:10:41 +0200 Subject: [PATCH 4/4] use _lm.tempo and set sleep to 0 --- pyleds/program/promise/ChristmasLights.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyleds/program/promise/ChristmasLights.py b/pyleds/program/promise/ChristmasLights.py index 925d96b..e0b44f6 100644 --- a/pyleds/program/promise/ChristmasLights.py +++ b/pyleds/program/promise/ChristmasLights.py @@ -8,7 +8,7 @@ def name(): class ChristmasLights(Program): def run(self, args: [] = None): # Configuration - wait_ms = 100 # Speed of the animation + wait_ms = 0 # Speed of the animation # Define classic festive colors RED = Color(255, 0, 0) @@ -34,5 +34,5 @@ class ChristmasLights(Program): # Increment offset to move the lights offset = (offset + 1) % (len(colors) * group_size) - + self._lm.get_tempo().wait() time.sleep(wait_ms / 1000.0) -- 2.47.2