Commit a414056d authored by Federico Meloda's avatar Federico Meloda Committed by Aljaž Srebrnič
Browse files

Fixed LED test

parent bba8f920
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -2,25 +2,26 @@

from time import sleep
from random import randint
import configparser

import zmq
import spidev
import ws2812

c = 0
rand = 1


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)
    global c
    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)


def light_flame():
@@ -29,10 +30,12 @@ def light_flame():

    while True:
        ws2812.write2812(spi, [get_color() * 4])
        sleep(0.2)
        sleep(0.001)


def main():
    light_flame()


if __name__ == "__main__":
    main()