hey guys, i am having some trouble with my script.
the basic idea is that i have a button that locks in at either the up or down position
i have got a script going that works once but the problem is that once kodi boots my script stops responding
import RPi.GPIO as GPIO
import time
import os
def KODI():
os.system("kodi")
#Define GPIO pins
GPIO.setmode(GPIO.BCM)
GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_UP)
#how long has it been held
time_pressed = 0
while True:
input_state = GPIO.input(20)
if input_state == False:
if time_pressed > 5:
print "Button Held"
KODI()
else:
print('Button Pressed')
time.sleep(1)
time_pressed += 1
elif input_state == True:
time_pressed = 0
time.sleep(1)
i plan on making a reverse state for this that will check if the button is up and then if it is up for a certain amount of time.
i will post an example output below
Button Pressed
Button Pressed
Button Pressed
Button Pressed
Button Pressed
Button Pressed
Button Held
at this point it boots kodi but stops taking input from the button




