Projekt Litsimaja - Lapikute tagatoa seintele programmeeritavad ARGB ribad
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
1.2 KiB

from lib.Program import Program
from lib.Litsimaja import Litsimaja
def Color(red, green, blue):
"""Convert the provided red, green, blue color to a 24-bit color value.
Each color component should be a value 0-255 where 0 is the lowest intensity
and 255 is the highest intensity.
"""
return (red << 16) | (green << 8) | blue
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