Main Site Documentation

Change the DebounceTimeout on button events


#1

General question only. Not a complaint.

I hope it makes some sense.

Because a System.NotImplementedException is not specific as to the cause.

Is this exception caused by my coding error or because it has not been implemented at this revision level?

I want to change the DebounceTimeout on button events.
(I am receiving multiple button press events causing multiple executions of the event handling method)

// The following test is to see if the timespan is changing as expected

Debug.WriteLineIf(true, “\nUsing a new System.TimeSpan(0, 0, 0, 0, 22);”);
System.TimeSpan tsx = new System.TimeSpan(0, 0, 0, 0, 22);
Debug.WriteLineIf(true, "TimeSpan tsx was = " + tsx);

tsx = tsx.Add(System.TimeSpan.FromMilliseconds(50));
Debug.WriteLineIf(true, "TimeSpan tsx Add(50) is now = " + tsx);

tsx = tsx.Subtract(System.TimeSpan.FromMilliseconds(20));
Debug.WriteLineIf(true, "TimeSpan tsx Subtract(20) is now = " + tsx);
//

Debug Output window shows timespan changes as expected
Using new System.TimeSpan(0, 0, 0, 0, 22);
TimeSpan tsx was = 00:00:00.0220000
TimeSpan tsx Add(50) is now = 00:00:00.0720000
TimeSpan tsx Subtract(20) is now = 00:00:00.0520000

If I use

// GHIElectronics.TinyCLR.Devices.Gpio
// public TimeSpan DebounceTimeout { get; set; }

System.TimeSpan ts1 = buttonUp.DebounceTimeout; // Get current timeout value
Debug.WriteLineIf(true, "Current buttonUp.DebounceTimeout = " + ts1);

ts1 = ts1.Add(System.TimeSpan.FromMilliseconds(50));

//System.NotImplementedException’ occurred in GHIElectronics.TinyCLR.Devices.dll
buttonUp.DebounceTimeout = ts1;

Or Use

buttonUp.DebounceTimeout = buttonUp.DebounceTimeout.Add(System.TimeSpan.FromMilliseconds(50));

Debug Output window
Current buttonUp.DebounceTimeout = 00:00:00.0200000
#### Exception System.NotImplementedException - 0xca000000 (1) ####
#### Message:
#### GHIElectronics.TinyCLR.Devices.Gpio.Provider.DefaultGpioPinProvider::set_DebounceTimeout [IP: 0000] ####
#### GHIElectronics.TinyCLR.Devices.Gpio.GpioPin::set_DebounceTimeout [IP: 0016] ####
#### TinyCLRApplicationTest.Program::Main [IP: 0320] ####
Exception thrown: ‘System.NotImplementedException’ in GHIElectronics.TinyCLR.Devices.dll
An unhandled exception of type ‘System.NotImplementedException’ occurred in GHIElectronics.TinyCLR.Devices.dll

Can DebounceTimeout be set with the current version of TinyCLR?

Thank you.


#2

Looks like it’s a bug on our end. The debounce is actually properly set, but we still throw not implemented by mistake. You should be able to catch that exception and continue on.


#3

Thanks for the reply…