Commit 2490ee62 authored by Federico Meloda's avatar Federico Meloda

added burn effect, to be tested

parent 36b53bde
...@@ -21,6 +21,7 @@ class Color: ...@@ -21,6 +21,7 @@ class Color:
class ColorManager(Thread): class ColorManager(Thread):
current_rand = 1 current_rand = 1
unscaled_blue = 0
current_color = Color(0, 0, 0) current_color = Color(0, 0, 0)
activeFlag = True activeFlag = True
spi = spidev.SpiDev() spi = spidev.SpiDev()
...@@ -32,14 +33,16 @@ class ColorManager(Thread): ...@@ -32,14 +33,16 @@ class ColorManager(Thread):
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, 0) self.current_color = Color(80, 255, self.current_color.blue)
elif self.current_colorgreen + self.current_rand < 0: elif self.current_color.green + self.current_rand < 0:
rand = randint(1, 8) rand = randint(1, 8)
self.current_color = Color(0, 255, 0) self.current_color = Color(0, 255, self.current_color.blue)
else: else:
self.current_color.green += rand self.current_color.green += rand
self.current_color.red = 255 self.current_color.red = 255
self.current_color.blue = 0 self.current_color.blue = self.unscaled_blue * self.current_color.green//255
if self.unscaled_blue > 0 :
self.unscaled_blue--
def fade(self): def fade(self):
if self.current_color.red > 0: if self.current_color.red > 0:
...@@ -50,6 +53,9 @@ class ColorManager(Thread): ...@@ -50,6 +53,9 @@ class ColorManager(Thread):
def start_fade(self): def start_fade(self):
self.activeFlag = False self.activeFlag = False
def burn(self):
self.unscaled_blue = 255
def run(self): def run(self):
while self.is_alive(): while self.is_alive():
if self.activeFlag: if self.activeFlag:
...@@ -88,9 +94,11 @@ def main(): ...@@ -88,9 +94,11 @@ def main():
if messagedata == b"liftoff": if messagedata == b"liftoff":
cm = ColorManager() cm = ColorManager()
cm.start() cm.start()
burn()
elif messagedata == b"stage_1_separation": elif messagedata == b"stage_1_separation":
pass burn()
elif messagedata == b"stage_2_separation": elif messagedata == b"stage_2_separation":
burn()
cm.start_fade() cm.start_fade()
else: else:
print("Unhandled message") print("Unhandled message")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment