parent
7783c634ea
commit
493e8f1f35
18
main.py
18
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_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
|
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53
|
||||||
|
|
||||||
mode = 0
|
|
||||||
power = True
|
|
||||||
|
|
||||||
def debug_print(message: str):
|
def debug_print(message: str):
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
current_time = now.strftime("%H:%M:%S")
|
current_time = now.strftime("%H:%M:%S")
|
||||||
|
@ -118,6 +115,11 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
@app.route('/mode', methods=['GET'])
|
@app.route('/mode', methods=['GET'])
|
||||||
def mode():
|
def mode():
|
||||||
|
global mode
|
||||||
|
global power
|
||||||
|
global r
|
||||||
|
global g
|
||||||
|
global b
|
||||||
args = request.args
|
args = request.args
|
||||||
mode = str(args.get('mode'))
|
mode = str(args.get('mode'))
|
||||||
r = str(args.get('r'))
|
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 = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
|
||||||
strip.begin()
|
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:
|
try:
|
||||||
while True:
|
while True:
|
||||||
if power == True:
|
if power == True:
|
||||||
|
if mode == 0:
|
||||||
|
rainbowCycle(strip)
|
||||||
|
elif mode == 1:
|
||||||
|
setColor(strip, Color(int(r), int(g), int(b)))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
else:
|
else:
|
||||||
setColor(strip, Color(0,0,0))
|
setColor(strip, Color(0,0,0))
|
||||||
|
|
Loading…
Reference in New Issue