def action(selection): if (selection == 1): system("echo Shutdown selected!") LED.ON(10, 0, 0) system("shutdown now") elif (selection == 2): system("echo Restart selected!") LED.ON(10, 8, 0) system("reboot now")
def mainLogic(): LED.Blink(5, 5, 5, 1, 2, 3, 1100) while (True): GPIO.wait_for_edge(pin, GPIO.FALLING) sleep(softDebounce) # Software button debounce count = 0 while (True): LED.ON(ledMatrix[count][0], ledMatrix[count][1], ledMatrix[count][2]) isPressed = GPIO.wait_for_edge(pin, GPIO.FALLING, timeout=confirmTimeout) sleep(softDebounce) # Software button debounce if (isPressed): count = (count + 1) % 3 # Makes sure the selection is 0-2 if ( count == 0 ): # Goes back to start if all options got scrolled through LED.OFF() break else: # Acts when a timeout occurs on non-zero selection LED.OFF() action(count) break