Closed BigBadPhysicist closed 5 years ago
Hi @BigBadPhysicist,
By the moment we don't support for any bounce time. Maybe we could add that feature, but I need to run some tests first.
I'll be updating this issue to let you know if we have some advance in that feature.
Greetings.
Hi @BigBadPhysicist,
I did some tests about interrupt callbacks using RaspberryIO and WiringPi. The current behavior you found in our library is actually the behavior of the underlying WiringPi library. However, this can be handled easily in your code:
class Program
{
private static DateTime _lastInterrupt;
private static int _count;
static void Main(string[] args)
{
_lastInterrupt = DateTime.Now;
Pi.Init<BootstrapWiringPi>();
var pin = Pi.Gpio[17];
pin.PinMode = GpioPinDriveMode.Input;
pin.InputPullMode = GpioPinResistorPullMode.PullUp;
pin.RegisterInterruptCallback(EdgeDetection.FallingEdge, Callback);
Console.ReadKey();
}
static void Callback()
{
var now = DateTime.Now;
if (now.Subtract(_lastInterrupt).TotalMilliseconds > 200)
{
$"Button Press {++_count}".Info();
_lastInterrupt = now;
}
}
}
@BigBadPhysicist can we close this issue?
Thanks for the help.
Closed!
I am porting some code from python to c#.
I have a simple setup using a RP3 with a SenseHat and an external Button (wired between pin 16 and GND ).
In python I used the following code to achive a bounce free function call after a button press:
with your libary i tried:
this works for detecting the button press, but since the button is quiet cheap I get up to 10 function calls each time i press the button.
Would it be possible / or is it allready possible to add a bouncetime to RegisterInterruptCallback() to drop incomming interrupts in a given time window to remove bounce from the button?