...
 
Commits (3)
...@@ -15,6 +15,11 @@ class Color: ...@@ -15,6 +15,11 @@ class Color:
red: int red: int
blue: int blue: int
def __init__(self, green, red, blue):
self.green = green
self.red = red
self.blue = blue
def as_tuple(self): def as_tuple(self):
return self.green, self.red, self.blue return self.green, self.red, self.blue
...@@ -29,20 +34,21 @@ class ColorManager(Thread): ...@@ -29,20 +34,21 @@ class ColorManager(Thread):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.spi.open(1, 0) self.spi.open(1, 0)
ws2812.write2812(self.spi, [(0,0,0) * 4])
def get_color(self): def get_color(self):
if self.current_color.green + self.current_rand > 80: if self.current_color.green + self.current_rand > 80:
self.current_rand = -randint(1, 8) self.current_rand = -randint(1, 8)
self.current_color = Color(80, 255, self.current_color.blue) self.current_color = Color(80, 255, self.current_color.blue)
elif self.current_color.green + self.current_rand < 0: elif self.current_color.green + self.current_rand < 0:
rand = randint(1, 8) self.current_rand = randint(1, 8)
self.current_color = Color(0, 255, self.current_color.blue) self.current_color = Color(0, 255, self.current_color.blue)
else: else:
self.current_color.green += rand self.current_color.green += self.current_rand
self.current_color.red = 255 self.current_color.red = 255
self.current_color.blue = self.unscaled_blue * self.current_color.green//255 self.current_color.blue = self.unscaled_blue * self.current_color.green//255
if self.unscaled_blue < 100 : if self.unscaled_blue < 100 :
self.unscaled_blue++ self.unscaled_blue += 1
def fade(self): def fade(self):
if self.current_color.red > 0: if self.current_color.red > 0:
......