IO is an event based input manager which permit to select which composents are manged on your system
Dependencies: C12832 FXOS8700Q LM75B MMA7660
Diff: FrdmK64f_Input.hpp
- Revision:
- 0:2ac59c564ab0
- Child:
- 1:7be9a82f3ab8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FrdmK64f_Input.hpp Tue Feb 23 17:25:07 2016 +0000 @@ -0,0 +1,36 @@ +#pragma once + +#include "mbed.h" + +template <class Parent> +class FrdmK64f_Input : public Parent +{ + // Buttons + InterruptIn _buttonLeft; + InterruptIn _buttonRight; + +public: + + enum IDBinaryInput + { + ButtonLeft, + ButtonRight + }; + + FrdmK64f_Input(void) + : _buttonLeft(SW2), _buttonRight(SW3) + { + _buttonLeft.rise(this, &FrdmK64f_Input::onButtonLeftRise); + _buttonLeft.fall(this, &FrdmK64f_Input::onButtonLeftFall); + _buttonRight.rise(this, &FrdmK64f_Input::onButtonRightRise); + _buttonRight.fall(this, &FrdmK64f_Input::onButtonRightFall); + } + + void onButtonLeftRise(void) { Parent::_events.push(Event(Event::FrdmK64f, Event::BinaryInput, ButtonLeft, Event::Rise)); } + void onButtonLeftFall(void) { Parent::_events.push(Event(Event::FrdmK64f, Event::BinaryInput, ButtonLeft, Event::Fall)); } + void onButtonRightRise(void) { Parent::_events.push(Event(Event::FrdmK64f, Event::BinaryInput, ButtonRight, Event::Rise)); } + void onButtonRightFall(void) { Parent::_events.push(Event(Event::FrdmK64f, Event::BinaryInput, ButtonRight, Event::Fall)); } + + // Callback for others sensors + virtual void chechAnalog(void) { Parent::chechAnalog(); } +}; \ No newline at end of file