Compare commits
1 Commits
master
...
feature/vi
| Author | SHA1 | Date | |
|---|---|---|---|
|
364ea9971b
|
@@ -1,14 +0,0 @@
|
|||||||
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()
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
from lib.Program import Program
|
|
||||||
from rpi_ws281x import Color
|
|
||||||
import time
|
|
||||||
|
|
||||||
def name():
|
|
||||||
return 'Christmas Lights'
|
|
||||||
|
|
||||||
class ChristmasLights(Program):
|
|
||||||
def run(self, args: [] = None):
|
|
||||||
# Configuration
|
|
||||||
wait_ms = 0 # 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)
|
|
||||||
self._lm.get_tempo().wait()
|
|
||||||
time.sleep(wait_ms / 1000.0)
|
|
||||||
Reference in New Issue
Block a user