Added idle mode saver

master
Ebbe Baß 2022-03-11 11:38:02 +01:00
parent bd41fa8393
commit fc31141394
1 changed files with 8 additions and 1 deletions

View File

@ -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: