Please let me know if anyone on this forum can spare some C# code for monitoring inputs using event instead of timers? FezHat and FezUtility drivers and sample code all use a timer to check when an input has been fired.
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(500);
timer.Tick += Timer_Tick;
timer.Start();
I will like to use events the same way as used on Windows IOT Core and I have not idea how to do that. A sample to get me started will be nice.
private GpioPin buttonPin;
buttonPin = gpio.OpenPin(BUTTON_PIN);
// Check if input pull-up resistors are supported
if (buttonPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
buttonPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
else
buttonPin.SetDriveMode(GpioPinDriveMode.Input);
// Set a debounce timeout to filter out switch bounce noise from a button press
buttonPin.DebounceTimeout = TimeSpan.FromMilliseconds(50);
// Register for the ValueChanged event so our buttonPin_ValueChanged
// function is called when the button is pressed
buttonPin.ValueChanged += buttonPin_ValueChanged;