from christmastree import ChristmasTree from time import sleep import random tree = ChristmasTree(pwm=True) try: leds = tree.leds while True: for led in leds: led.off() sleep(random.uniform(0, 3)) led.pulse() except Exception as e: tree.close() raise e
def green_down(leds): for led in [0, 2]: leds[led].on() def green_middle(leds): for led in [5, 7]: leds[led].on() def green_up(leds): for led in [9]: leds[led].on() tree = ChristmasTree() tree.star.off() leds = tree.leds try: tree.star.off() while True: #reds down to up tree.baubles.off() sleep(.5) red_down(leds) sleep(.5) tree.baubles.off() sleep(.5) red_middle(leds) sleep(.5)
def seven(leds): for led in [7]: leds[led].on() def eight(leds): for led in [8]: leds[led].on() def nine(leds): for led in [9]: leds[led].on() tree = ChristmasTree() tree.star.off() leds = tree.leds while True: #step 1: down to up 300 ms tree.baubles.off() sleep(.3) zero(leds) sleep(.3) tree.baubles.off() sleep(.3) one(leds) sleep(.3) tree.baubles.off()
def bottom_off(leds): for led in [0, 1, 2, 3]: leds[led].off() def mid_off(leds): for led in [4, 5, 6, 7]: leds[led].off() def top_off(leds): for led in [8, 9]: leds[led].off() tree = ChristmasTree() leds = tree.leds try: tree.star.off() while True: fwd_on(leds) sleep(.5) tree.off() sleep(.5) tree.on() sleep(.5) tree.off() sleep(.5) tree.baubles.off() rev_on(leds)