From 29a47be3f0be8da1df52dde87484105fe0f4016c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Tue, 9 Nov 2021 17:13:18 +0100 Subject: [PATCH] Update main.py --- main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 2bae1a3..32f896b 100644 --- a/main.py +++ b/main.py @@ -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: