next try
parent
f9ad7f54ea
commit
7b119249e9
38
main.py
38
main.py
|
@ -73,7 +73,24 @@ def power_toggle(channel):
|
||||||
power_button_pressed = 'True'
|
power_button_pressed = 'True'
|
||||||
print('Toggle Power executed')
|
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'
|
led_power = 'True'
|
||||||
idle_mode = 1
|
idle_mode = 1
|
||||||
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
|
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
|
||||||
|
@ -123,22 +140,3 @@ def led_main():
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
setColor(strip, Color(0,0,0))
|
setColor(strip, Color(0,0,0))
|
||||||
GPIO.cleanup()
|
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()
|
|
Loading…
Reference in New Issue