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