diff --git a/main.py b/main.py index 3618a80..cac07f4 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ from rpi_ws281x import * import RPi.GPIO as GPIO import os from datetime import datetime +current_path = os.path.dirname(os.path.abspath(__file__)) led_power = 'True' idle_mode = 1 @@ -74,6 +75,10 @@ def change_idle_mode(channel): if idle_mode == 8: idle_mode = 1 debug_print('Change Idlemode executed') + with open(current_path+'/settings.txt', 'w') as f: + f.write(str(idle_mode)) + debug_print('Saved idle mode') + def power_toggle(channel): global power_button_pressed @@ -87,7 +92,9 @@ 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.RISING, callback=power_toggle, bouncetime=300) - GPIO.add_event_detect(19, GPIO.RISING, callback=change_idle_mode, bouncetime=300) + GPIO.add_event_detect(19, GPIO.RISING, callback=change_idle_mode, bouncetime=300) + with open(current_path+'/settings.txt', 'r') as f: + idle_mode = int(f.readlines()) try: while True: