Added idle mode saver
parent
bd41fa8393
commit
fc31141394
7
main.py
7
main.py
|
@ -4,6 +4,7 @@ from rpi_ws281x import *
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
current_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
led_power = 'True'
|
led_power = 'True'
|
||||||
idle_mode = 1
|
idle_mode = 1
|
||||||
|
@ -74,6 +75,10 @@ def change_idle_mode(channel):
|
||||||
if idle_mode == 8:
|
if idle_mode == 8:
|
||||||
idle_mode = 1
|
idle_mode = 1
|
||||||
debug_print('Change Idlemode executed')
|
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):
|
def power_toggle(channel):
|
||||||
global power_button_pressed
|
global power_button_pressed
|
||||||
|
@ -88,6 +93,8 @@ if __name__ == '__main__':
|
||||||
GPIO.setup(19, 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(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:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in New Issue