Commit 96ba3bb7 authored by Federico Meloda's avatar Federico Meloda

added fade to leds

parent b769ea29
...@@ -8,19 +8,27 @@ import zmq ...@@ -8,19 +8,27 @@ import zmq
import spidev import spidev
import ws2812 import ws2812
activeFlag = True
c = 0
rand = 1
r = 255
def get_color(): def get_color():
rand = randint(0, 10) if activeFlag == True :
if rand < 5: global c
return (248, 255, 255) global r
elif rand == 6: global rand
return (111, 255, 0) if c+rand > 80:
elif rand == 7: rand = randint(1, 8)*(-1)
return (234, 255, 0) return(80, 255, 0)
elif rand == 8: elif c+rand < 0:
return (87, 255, 34) rand = randint(1, 8)
return(0, 255, 0)
else:
c = c + rand
return (c, 255, 0)
else: else:
return (0, 213, 0) fade()
def light_flame(): def light_flame():
...@@ -29,7 +37,14 @@ def light_flame(): ...@@ -29,7 +37,14 @@ def light_flame():
while True: while True:
ws2812.write2812(spi, [get_color() * 4]) ws2812.write2812(spi, [get_color() * 4])
sleep(0.2) sleep(0.001)
def fade():
if r > 0:
r--
if c > 0:
c--
return (c, r, 0)
def main(): def main():
...@@ -58,6 +73,9 @@ def main(): ...@@ -58,6 +73,9 @@ def main():
light_flame() light_flame()
elif messagedata == b"stage_1_separation": elif messagedata == b"stage_1_separation":
light_flame() light_flame()
elif messagedata == b"stage_2_separation":
light_flame()
activeFlag = False
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