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

added fade to leds

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