From 493e8f1f359cbc4b3e5a487f8ec69c66a2955534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Mon, 16 May 2022 21:23:10 +0200 Subject: [PATCH] test background run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- main.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 4834a89..d767e2d 100644 --- a/main.py +++ b/main.py @@ -23,9 +23,6 @@ LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest LED_INVERT = False # True to invert the signal (when using NPN transistor level shift) LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53 -mode = 0 -power = True - def debug_print(message: str): now = datetime.now() current_time = now.strftime("%H:%M:%S") @@ -118,6 +115,11 @@ if __name__ == '__main__': @app.route('/mode', methods=['GET']) def mode(): + global mode + global power + global r + global g + global b args = request.args mode = str(args.get('mode')) r = str(args.get('r')) @@ -151,12 +153,18 @@ if __name__ == '__main__': strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL) strip.begin() - app.run(host='0.0.0.0', port=80) + mode = 0 + power = True + + app.run(host='0.0.0.0', port=80, use_reloader=False, debug=True) try: while True: if power == True: - + if mode == 0: + rainbowCycle(strip) + elif mode == 1: + setColor(strip, Color(int(r), int(g), int(b))) time.sleep(1) else: setColor(strip, Color(0,0,0))