test background run

Signed-off-by: Ebbe Baß <ebbe@ping-mee.de>
master
Ebbe Baß 2022-05-16 21:23:10 +02:00
parent 7783c634ea
commit 493e8f1f35
1 changed files with 13 additions and 5 deletions

18
main.py
View File

@ -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))