|
Hi there,
In my project, I need 3 push buttons attached to OrangePi.
Theses buttons are tied to changing the behavior of the software.
When someone press (and release) one of theses buttons, the original configuration is restaured (whatever that means).
When another button is pressed a pre-configured mode is setup.
And when a third button is pressed another configuration is activated. You got the ideia.
I am using the 3.3V GPIO pins to plug a push button.
A infinite loop on a python program detects when a specific button is pressed.
- while True:
- if (gpio.input(23) == 1 ):
- print ("button was pressed. Do something usefull")
- time.sleep (1)
- gpio.cleanup ()
Copy code It is working.
But the question is about the right way of doing things. Is the infinite loop the best approach ? Is it not a time consuming operation ?
I was looking for a event based, kernel fired approach...Is it possible ?
Related to that, how to implement a hardware reset button that works even when the OS is borked ? Kind of a watchdog reset ? Much like the reset button we have on our computers...? Is it possible ?
best regards
|
|