From 78e94ad8e0c36fd094da377ac8e52c56d35d7127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Tue, 9 Nov 2021 17:25:34 +0100 Subject: [PATCH] Update main.py --- main.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 32f896b..3a7cb52 100644 --- a/main.py +++ b/main.py @@ -19,14 +19,11 @@ 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() + idle_mode = 1 def check_internet(url='http://www.google.com/', timeout=5): try: @@ -92,7 +89,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_toggled(), bouncetime=300) + GPIO.add_event_detect(13, GPIO.BOTH, callback=led_power_toggle(), bouncetime=300) GPIO.add_event_detect(19, GPIO.BOTH, callback=change_idle_mode(), bouncetime=300) try: