3 Commits

Author SHA1 Message Date
308f17b03f Veits tihedam rgbt lihtsalt (#8)
Reviewed-on: pvx/litsimaja#8
Co-authored-by: siinus <pearu@siinus.net>
Co-committed-by: siinus <pearu@siinus.net>
2026-05-22 16:00:45 +00:00
Eerik Abel
f2e97ed465 Strips program 2026-01-02 16:25:23 +02:00
545ff966c8 add generated christmas lights (#9)
Reviewed-on: pvx/litsimaja#9
2025-12-21 14:54:56 +00:00
2 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
from lib.Program import Program
def name():
return '2-color strips'
class Strips(Program):
def run(self, args = None) -> None:
for i in range(self._lm.count_pixels()):
if i // 5 % 2:
color = (255, 255, 255)
else:
color = args['color']
self._lm.set_pixel_color(i, (color[0] << 16) | (color[1] << 8) | color[2])
self._lm.show()

View File

@@ -0,0 +1,35 @@
from lib.Program import Program
from rpi_ws281x import Color
import time
def name():
return 'Vikermasetsus'
def wheel(pos):
"""Generate rainbow colors across 0-255 positions."""
if pos < 85:
return Color(pos * 3, 255 - pos * 3, 0)
elif pos < 170:
pos -= 85
return Color(255 - pos * 3, 0, pos * 3)
else:
pos -= 170
return Color(0, pos * 3, 255 - pos * 3)
class Vikermasetsus(Program):
def run(self, args: [] = None):
wait_ms = 20
iterations = 5
while self.get_loop().status():
"""Draw rainbow that uniformly distributes itself across all pixels."""
for j in range(256 * iterations):
if not self.get_loop().status():
break
for i in range(self._lm.count_pixels()):
self._lm.set_pixel_color(i, wheel(
(int(i * 2560 / self._lm.count_pixels()) + j) & 255))
self._lm.show()
time.sleep(wait_ms / 1000.0)