TargetManager
Dependents: TargetManagerManualTest NerfUSTarget
Revision 10:1b5440d9226c, committed 2017-04-11
- Comitter:
- GaiSensei
- Date:
- Tue Apr 11 03:47:38 2017 +0000
- Parent:
- 9:1069bd8c9472
- Commit message:
- Calibrate servomotors
Changed in this revision
include/Bumper.hpp | Show annotated file Show diff for this revision Revisions of this file |
mbed_source/Bumper.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1069bd8c9472 -r 1b5440d9226c include/Bumper.hpp --- a/include/Bumper.hpp Sun Apr 09 23:46:00 2017 +0000 +++ b/include/Bumper.hpp Tue Apr 11 03:47:38 2017 +0000 @@ -13,12 +13,13 @@ class Bumper { public: - Bumper(PinName pin, NerfusCallbackInterface& nerfus_callback); - void bumped(); + Bumper(PinName pin, NerfusCallbackInterface* nerfus_rise_callback); + void set_callbacks(NerfusCallbackInterface* nerfus_rise_callback); + void rise_callback(); private: InterruptIn interrupt_in; - NerfusCallbackInterface& nerfus_callback; + NerfusCallbackInterface* nerfus_rise_callback; }; #endif \ No newline at end of file
diff -r 1069bd8c9472 -r 1b5440d9226c mbed_source/Bumper.cpp --- a/mbed_source/Bumper.cpp Sun Apr 09 23:46:00 2017 +0000 +++ b/mbed_source/Bumper.cpp Tue Apr 11 03:47:38 2017 +0000 @@ -1,14 +1,21 @@ #include "Bumper.hpp" -Bumper::Bumper(PinName pin, NerfusCallbackInterface& nerfus_callback) : +Bumper::Bumper(PinName pin, NerfusCallbackInterface* nerfus_rise_callback) : interrupt_in(pin), - nerfus_callback(nerfus_callback) + nerfus_rise_callback(nerfus_rise_callback) { - interrupt_in.rise(callback(this, &Bumper::bumped)); + interrupt_in.rise(callback(this, &Bumper::rise_callback)); +} + +void Bumper::set_callbacks(NerfusCallbackInterface* nerfus_rise_callback) +{ + this->nerfus_rise_callback = nerfus_rise_callback; } -void Bumper::bumped() +void Bumper::rise_callback() { - nerfus_callback.call(); + if(nerfus_rise_callback) + { + nerfus_rise_callback->call(); + } } - \ No newline at end of file