I haven't written a full script yet since I was just at the point of making sure the 'plumbing' worked before I head down this road.
Inputs would be four parameters:
red, green, blue (int: 0-255)
and brightness (float: 0-1)
Then, the various animation scripts I have written for NeoPixel (for example) could just add a call to the RGB bulb.. and example is this..
Here is a NeoPixel animation I wrote:
- Code: Select all
class Rain(ColorCycle):
"""
:param pixel_object: The initialised LED object.
:param sky_color: The current color of the sky
:param is_stopping: If the animation is stopping we gently fade to sky color
"""
def __init__(self, pixel_object, current_sky_color: Tuple, is_stopping=False):
self.is_stopping = is_stopping
self.rain_sky_color = current_sky_color
self.splash_color = (
current_sky_color[0]*2,
current_sky_color[1]*2,
current_sky_color[2]*2
)
self.num_rain_drops = len(pixel_object) // 4
super().__init__(pixel_object, 0.2, self.rain_sky_color)
self.fill(self.rain_sky_color)
self.show()
def draw(self):
# generate random raindrops
if self.is_stopping:
while self.num_rain_drops > 2:
self.num_rain_drops = self.num_rain_drops - 5
self.do_rain_effect()
self.show()
time.sleep(0.1)
return
self.do_rain_effect()
def do_rain_effect(self):
self.fill(self.rain_sky_color)
for i in range(self.num_rain_drops):
self.pixel_object[
random.randrange(0, len(self.pixel_object))
] = self.splash_color
def reset(self):
self.fill(self.rain_sky_color)
You could imagine that on each animation loop I could set the LED bulb to the current animated color to sync with the LED Pixels I have.