Add python led programs

This commit is contained in:
siinus
2020-11-08 01:47:25 +02:00
parent 1fc4303ae2
commit 103a5c9252
11 changed files with 3586 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
from lib.Program import Program
def name():
return 'Static color'
class Static(Program):
def run(self, args: [] = None) -> None:
color_arr = args['color']
for i in range(self._lm.count_pixels()):
self._lm.set_pixel_color(i, (color_arr[0] << 16) | (color_arr[1] << 8) | color_arr[2])
self._lm.show()

View File

@@ -0,0 +1,37 @@
from lib.Program import Program
from lib.Litsimaja import Litsimaja
from rpi_ws281x import Color
def name():
return 'Wipey wipe'
def color_wipe(lm: Litsimaja, color):
for i in range(lm.count_pixels()):
lm.set_pixel_color(i, color)
if i % 4 == 0:
lm.show()
lm.show()
class Wipes(Program):
def run(self, args=None):
loop = False
if 'loop' in args and args['loop']:
loop = args['loop']
if 'color' in args:
end = Color(args['color'][0], args['color'][1], args['color'][2])
else:
end = Color(100, 100, 50)
r = Color(255, 0, 0)
g = Color(0, 255, 0)
b = Color(0, 0, 255)
while self.get_loop().status():
color_wipe(self._lm, r)
color_wipe(self._lm, g)
color_wipe(self._lm, b)
color_wipe(self._lm, end)
if not loop:
break