Made LED code also a thread
parent
fda9df2e3d
commit
f9ad7f54ea
39
main.py
39
main.py
|
@ -73,23 +73,7 @@ def power_toggle(channel):
|
|||
power_button_pressed = 'True'
|
||||
print('Toggle Power executed')
|
||||
|
||||
#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()
|
||||
def led_main():
|
||||
led_power = 'True'
|
||||
idle_mode = 1
|
||||
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
|
||||
|
@ -138,4 +122,23 @@ if __name__ == '__main__':
|
|||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
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