Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: D7A_Demo-Get-started CVtoOSCConverter EE3501keypad D7A_Localisation ... more
Fork of DebouncedInterrupt by
Revision 14:da09706b92f5, committed 2014-02-18
- Comitter:
- kandangath
- Date:
- Tue Feb 18 17:26:42 2014 +0000
- Parent:
- 13:09b53a088a9c
- Child:
- 15:948e85b22efe
- Commit message:
- Also poll pin value at the end of the debounce period
Changed in this revision
| DebouncedInterrupt.cpp | Show annotated file Show diff for this revision Revisions of this file |
| DebouncedInterrupt.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/DebouncedInterrupt.cpp Tue Feb 18 16:51:44 2014 +0000
+++ b/DebouncedInterrupt.cpp Tue Feb 18 17:26:42 2014 +0000
@@ -8,10 +8,13 @@
DebouncedInterrupt::DebouncedInterrupt(PinName pin)
{
_in = new InterruptIn(pin);
+ _din = new DigitalIn(pin);
}
DebouncedInterrupt::~DebouncedInterrupt()
{
+ delete _in;
+ delete _din;
}
void DebouncedInterrupt::attach(void (*fptr)(void),
@@ -51,7 +54,9 @@
{
_last_bounce_count = _bounce_count;
_bounce_count = 0;
- fCallback();
+ if(_din) {
+ fCallback();
+ }
}
void DebouncedInterrupt::_onInterrupt()
--- a/DebouncedInterrupt.h Tue Feb 18 16:51:44 2014 +0000
+++ b/DebouncedInterrupt.h Tue Feb 18 17:26:42 2014 +0000
@@ -36,6 +36,7 @@
private:
unsigned int _debounce_us;
InterruptIn *_in;
+ DigitalIn *_din;
// Diagnostics
volatile unsigned int _bounce_count;
