Update main.py

master
Ebbe Baß 2021-11-09 17:13:18 +01:00
parent db726ebe51
commit 29a47be3f0
1 changed files with 4 additions and 3 deletions

View File

@ -15,16 +15,17 @@ LED_INVERT = False # True to invert the signal (when using NPN transistor
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53
global led_power
global idle_mode
led_power = True
try:
with open('./idle.txt', 'r') as f:
global idle_mode
idle_mode = f.readline()
except:
with open('./idle.txt', 'w') as f:
f.write('1')
with open('./idle.txt', 'r') as f:
global idle_mode
idle_mode = f.readline()
def check_internet(url='http://www.google.com/', timeout=5):
@ -69,7 +70,7 @@ def blink(strip, color1, color2, iterations=10, wait_ms=10):
strip.show()
time.sleep(1)
def led_power_toggle(led_power):
def led_power_toggle():
if led_power == True:
led_power = False
else:
@ -91,7 +92,7 @@ if __name__ == '__main__':
GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(19, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(13, GPIO.BOTH, callback=led_power_toggle(), bouncetime=300)
GPIO.add_event_detect(13, GPIO.BOTH, callback=led_power_toggled(), bouncetime=300)
GPIO.add_event_detect(19, GPIO.BOTH, callback=change_idle_mode(), bouncetime=300)
try: