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 26:2df374d23986, committed 2017-04-27
- Comitter:
- Jeej
- Date:
- Thu Apr 27 16:06:12 2017 +0000
- Parent:
- 25:2163ebb21aef
- Commit message:
- Updated deprecated callback.
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 Wed Apr 26 11:02:18 2017 +0000
+++ b/DebouncedInterrupt.cpp Thu Apr 27 16:06:12 2017 +0000
@@ -21,7 +21,7 @@
void DebouncedInterrupt::attach(void (*fptr)(void), const gpio_irq_event trigger, const uint32_t debounce_ms, bool immediate)
{
if(fptr) {
- _fAttach.attach(fptr);
+ _callback = callback(fptr);
_last_bounce_count = _bounce_count = 0;
_debounce_us = 1000*debounce_ms;
_trigger = trigger;
@@ -56,13 +56,13 @@
return _last_bounce_count;
}
-void DebouncedInterrupt::_callback()
+void DebouncedInterrupt::_onCallback()
{
_last_bounce_count = _bounce_count;
_bounce_count = 0;
if (!_immediate) {
if (_din->read() == (_trigger==IRQ_RISE)) {
- _fAttach.call();
+ _callback.call();
}
}
_timeout_expired = true;
@@ -75,11 +75,11 @@
if (_immediate) {
if (_timeout_expired) {
_timeout_expired = false;
- _fAttach.call();
- _timeout->attach_us(callback(this, &DebouncedInterrupt::_callback), _debounce_us);
+ _callback.call();
+ _timeout->attach_us(callback(this, &DebouncedInterrupt::_onCallback), _debounce_us);
}
}
else {
- _timeout->attach_us(callback(this, &DebouncedInterrupt::_callback), _debounce_us);
+ _timeout->attach_us(callback(this, &DebouncedInterrupt::_onCallback), _debounce_us);
}
}
--- a/DebouncedInterrupt.h Wed Apr 26 11:02:18 2017 +0000
+++ b/DebouncedInterrupt.h Thu Apr 27 16:06:12 2017 +0000
@@ -56,7 +56,7 @@
volatile unsigned int _last_bounce_count;
void _onInterrupt(void);
- void _callback(void);
+ void _onCallback(void);
public:
DebouncedInterrupt(PinName pin);
~DebouncedInterrupt();
@@ -66,7 +66,7 @@
template<typename T, typename M>
void attach(T *obj, M method, const gpio_irq_event trigger, const uint32_t debounce_ms=10, bool immediate=false) {
- _fAttach.attach(callback(obj, method));
+ _callback = callback(obj, method);
_last_bounce_count = _bounce_count = 0;
_debounce_us = 1000*debounce_ms;
_trigger = trigger;
@@ -96,6 +96,6 @@
unsigned int get_bounce();
protected:
// https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/api/FunctionPointer.h
- Callback<void()> _fAttach;
+ Callback<void()> _callback;
};
#endif
\ No newline at end of file
