Hello all,
I want to use an GPIO input to tell the code to shut down. To do this, I am using a tactile switch with a pull up - so it is normally high. When the user wants to perform a shutdown, it is pressed until another light turns on indicating that the system has seen their pressed switch desiring a a shutdown.
So how are READs performed? Are they read events, or polled or what?
I see in the sample how to set up the code to read:
Protected Function AnalogRead(pin As Integer) as Integer
// analogRead (int pin) ;
// This returns the value read on the supplied analog input pin.
// You will need to register additional analog modules to enable
// this function for devices such as the Gertboard, quick2Wire analog board, etc.
#If TargetARM And TargetLinux Then
Soft Declare Function wpAnalogRead Lib "libwiringPi.so" Alias "analogRead" (pin As Integer) As Integer
Return wpAnalogRead(pin)
#Endif
End Function
Protected Function AnalogRead(pin As Integer) as Integer
// analogRead (int pin) ;
// This returns the value read on the supplied analog input pin.
// You will need to register additional analog modules to enable
// this function for devices such as the Gertboard, quick2Wire analog board, etc.
#If TargetARM And TargetLinux Then
Soft Declare Function wpAnalogRead Lib "libwiringPi.so" Alias "analogRead" (pin As Integer) As Integer
Return wpAnalogRead(pin)
#Endif
End Function
My question(s) are:
Is this event driven?
If so, what code is necessary to set this up.
If not, how to do this? Does it require a timer to waste time? In my case, the event would happen once in a harvest moon. So setting it to once a second is just a waste.
What is the correct way to set this up?
Thank you all!
Tim