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

added burn effect, to be tested

parent 36b53bde
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ class Color:

class ColorManager(Thread):
    current_rand = 1
    unscaled_blue = 0
    current_color = Color(0, 0, 0)
    activeFlag = True
    spi = spidev.SpiDev()
@@ -32,14 +33,16 @@ class ColorManager(Thread):
    def get_color(self):
        if self.current_color.green + self.current_rand > 80:
            self.current_rand = -randint(1, 8)
            self.current_color = Color(80, 255, 0)
        elif self.current_colorgreen + self.current_rand < 0:
            self.current_color = Color(80, 255, self.current_color.blue)
        elif self.current_color.green + self.current_rand < 0:
            rand = randint(1, 8)
            self.current_color = Color(0, 255, 0)
            self.current_color = Color(0, 255, self.current_color.blue)
        else:
            self.current_color.green += rand
            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):
        if self.current_color.red > 0:
@@ -50,6 +53,9 @@ class ColorManager(Thread):
    def start_fade(self):
        self.activeFlag = False

    def burn(self):
        self.unscaled_blue = 255

    def run(self):
        while self.is_alive():
            if self.activeFlag:
@@ -88,9 +94,11 @@ def main():
        if messagedata == b"liftoff":
            cm = ColorManager()
            cm.start()
            burn()
        elif messagedata == b"stage_1_separation":
            pass
            burn()
        elif messagedata == b"stage_2_separation":
            burn()
            cm.start_fade()
        else:
            print("Unhandled message")