def run_theater(): strip = get_strip() global stop_flag stop_flag = False log.info('theater started, stop_flag = ' + str(stop_flag)) for i in range(0, strip.numPixels(), 1): strip.setPixelColor(i, Color(0, 0, 0)) while not stop_flag: try: color_wipe_full(strip, Color(127, 0, 0)) # Green wipe if not stop_flag: color_wipe_full(strip, Color(0, 127, 0)) # Red wipe if not stop_flag: color_wipe_full(strip, Color(0, 0, 127)) # Blue wipe if not stop_flag: theater_chase(strip, Color(127, 127, 127)) # White theater chase if not stop_flag: theater_chase(strip, Color(0, 0, 127)) # Blue theater chase if not stop_flag: theater_chase(strip, Color(80, 0, 0)) # Green theater chase except KeyboardInterrupt: log.warn("KeyboardInterrupt") color_wipe_full(strip, Color(0, 0, 0), 0) exit() except Exception as e: log.error("Any error occurs: " + str(e)) exit() log.info('theater run stopped') reset_strip(strip) return
def run_advent(): strip = get_strip() month = datetime.now().month # month = 12 # uncomment to test global stop_flag stop_flag = False log.info('advent started, stop_flag = ' + str(stop_flag)) for i in range(0, strip.numPixels(), 1): strip.setPixelColor(i, Color(0, 0, 0)) try: if month != 12: log.warn( 'Wrong month for xmas/advent animation, it\'s {0}!'.format( time.strftime("%B"))) while not stop_flag: theater_chase(strip, Color(0, 15, 0)) else: december_cycle(month, strip) except KeyboardInterrupt: log.warn("KeyboardInterrupt") color_wipe_full(strip, Color(0, 0, 0), 0) exit() except Exception as e: log.error("Any error occurs: " + str(e)) exit() log.info('advent run stopped') reset_strip(strip) return
def run_clock(): strip = get_strip() global stop_flag stop_flag = False log.info('clock 1 started, stop_flag = ' + str(stop_flag)) for i in range(0, strip.numPixels(), 1): strip.setPixelColor(i, Color(0, 0, 0)) while not stop_flag: try: now = datetime.datetime.now() led_for_hour = int(int(now.hour) % 12 * 2) led_for_minute = int(round(now.minute / 2.5)) leds_per_2500ms = int(round(now.second / 2.5)) # Low light during given period if 8 < int(now.hour) < 18: strip.setBrightness(127) else: strip.setBrightness(50) _seconds(leds_per_2500ms, strip) _minute(led_for_minute, led_for_hour, strip) _hour(led_for_hour, led_for_minute, strip) strip.show() if leds_per_2500ms == strip.numPixels(): time.sleep(1.5) _clear(strip) except KeyboardInterrupt: log.warn("KeyboardInterrupt.") _wipe(strip, 0) exit() except Exception as e: log.error("Any error occurs: " + str(e)) exit() log.info('clock 1 run stopped') _wipe(strip, 0) reset_strip(strip) return
def run_candles(): strip = get_strip() global stop_flag stop_flag = False log.info('candles started, stop_flag = ' + str(stop_flag)) for i in range(0, strip.numPixels(), 1): strip.setPixelColor(i, Color(0, 0, 0)) try: while not stop_flag: candle(strip, strip.numPixels()) except KeyboardInterrupt: log.warn("KeyboardInterrupt") exit() except Exception as e: log.error("Any error occurs: " + str(e)) exit() log.info('candles run stopped') reset_strip(strip) return
def run_rainbow(): strip = get_strip() global stop_flag stop_flag = False log.info('rainbow started, stop_flag = ' + str(stop_flag)) for i in range(0, strip.numPixels(), 1): strip.setPixelColor(i, Color(0, 0, 0)) b = 80 while not stop_flag: try: strip.setBrightness(b) rainbow_cycle(strip) # theater_chase_rainbow(stripe) if not stop_flag: b -= 10 if b <= 30 and not stop_flag: while b <= 80 and not stop_flag: strip.setBrightness(b) rainbow_cycle(strip) # theater_chase_rainbow(stripe) if not stop_flag: b += 10 if not stop_flag: b = 80 except KeyboardInterrupt: log.warn("KeyboardInterrupt") exit() except Exception as e: log.error("Any error occurs: " + str(e)) exit() log.info('rainbow run stopped') reset_strip(strip) return