...
 
Commits (2)
...@@ -25,6 +25,7 @@ class Color: ...@@ -25,6 +25,7 @@ class Color:
class ColorManager(Thread): class ColorManager(Thread):
pow_time = 10000
current_rand = 1 current_rand = 1
current_color = Color(0, 0, 0) current_color = Color(0, 0, 0)
stato = 0 stato = 0
...@@ -54,8 +55,8 @@ class ColorManager(Thread): ...@@ -54,8 +55,8 @@ class ColorManager(Thread):
def power(self): def power(self):
if self.current_color.green + self.current_rand > 20: if self.current_color.green + self.current_rand > 40:
self.current_rand = -randint(1, 4) self.current_rand = -randint(1, 8)
self.current_color = Color(30, 255, 0) self.current_color = Color(30, 255, 0)
elif self.current_color.green + self.current_rand < 0: elif self.current_color.green + self.current_rand < 0:
self.current_rand = randint(1, 8) self.current_rand = randint(1, 8)
...@@ -63,7 +64,10 @@ class ColorManager(Thread): ...@@ -63,7 +64,10 @@ class ColorManager(Thread):
else: else:
self.current_color.green += self.current_rand self.current_color.green += self.current_rand
self.current_color.red = 255 self.current_color.red = 255
if self.pow_time < 0 : self.stato = 0 if self.pow_time < 0:
self.stato = 0
else:
self.pow_time -= 1
def fade(self): def fade(self):
...@@ -83,16 +87,14 @@ class ColorManager(Thread): ...@@ -83,16 +87,14 @@ class ColorManager(Thread):
def start_pow(self): def start_pow(self):
self.stato = 1 self.stato = 1
self.pow_time = 10000
def run(self): def run(self):
self.running: while self.running:
if self.stato == 0: self.get_color() if self.stato == 0: self.get_color()
elif self.stato == 1: self.power() elif self.stato == 1: self.power()
elif self.stato == 2: self.fade() elif self.stato == 2: self.fade()
}
switch[self.stato]()
ws2812.write2812(self.spi, [self.current_color.as_tuple() * 4]) ws2812.write2812(self.spi, [self.current_color.as_tuple() * 4])
sleep(0.001) sleep(0.001)
...@@ -127,10 +129,8 @@ def main(): ...@@ -127,10 +129,8 @@ def main():
cm.start() cm.start()
cm.start_pow() cm.start_pow()
elif messagedata == b"stage_1_separation": elif messagedata == b"stage_1_separation":
cm.burn()
cm.start_pow() cm.start_pow()
elif messagedata == b"stage_2_separation": elif messagedata == b"stage_2_separation":
cm.burn()
cm.start_fade() cm.start_fade()
elif messagedata == b"abort": elif messagedata == b"abort":
cm.lights_off() cm.lights_off()
......