master
Ebbe Baß 2022-01-04 11:05:11 +01:00
parent f9ad7f54ea
commit 7b119249e9
1 changed files with 19 additions and 21 deletions

40
main.py
View File

@ -73,7 +73,24 @@ def power_toggle(channel):
power_button_pressed = 'True'
print('Toggle Power executed')
def led_main():
#Web API
app = Flask(__name__)
@app.route('/')
def index():
command = str(request.args.get('command'))
if command == "switch-ilde-mode":
print('Switched Idlemode via API')
change_idle_mode
elif command == "switch-toggle-on-off":
print('Toggled Power via API')
power_toggle
return command
if __name__ == '__main__':
threading.Thread(target=app.run(host="0.0.0.0", port=80, debug=True, use_reloader=False)).start()
led_power = 'True'
idle_mode = 1
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
@ -122,23 +139,4 @@ def led_main():
time.sleep(1)
except KeyboardInterrupt:
setColor(strip, Color(0,0,0))
GPIO.cleanup()
#Web API
app = Flask(__name__)
@app.route('/')
def index():
command = str(request.args.get('command'))
if command == "switch-ilde-mode":
print('Switched Idlemode via API')
change_idle_mode
elif command == "switch-toggle-on-off":
print('Toggled Power via API')
power_toggle
return command
if __name__ == '__main__':
threading.Thread(target=lambda: app.run(host="0.0.0.0", port=80, debug=True, use_reloader=False)).start()
threading.Thread(target=lambda: led_main).start()
GPIO.cleanup()