IO is an event based input manager which permit to select which composents are manged on your system
Dependencies: C12832 FXOS8700Q LM75B MMA7660
FrdmK64f_Input.hpp
- Committer:
- co838_app56
- Date:
- 2016-02-23
- Revision:
- 1:7be9a82f3ab8
- Parent:
- 0:2ac59c564ab0
- Child:
- 2:c871dc21467b
File content as of revision 1:7be9a82f3ab8:
#pragma once #include "mbed.h" template <class Parent> class FrdmK64f_Input : public Parent { public: // List of manged Inputs enum IDBinaryInput { ButtonLeft, ButtonRight, IDBinaryInput_MAX }; private: // Buttons InterruptIn _buttonLeft; InterruptIn _buttonRight; bool _buttonEnable[2]; public: FrdmK64f_Input(void) : _buttonLeft(SW3), _buttonRight(SW2) { memset(_buttonEnable, 1, sizeof(_buttonEnable)); _buttonLeft.rise(this, &FrdmK64f_Input::onButtonLeftRise); _buttonLeft.fall(this, &FrdmK64f_Input::onButtonLeftFall); _buttonRight.rise(this, &FrdmK64f_Input::onButtonRightRise); _buttonRight.fall(this, &FrdmK64f_Input::onButtonRightFall); } using Parent::setEnable; void setEnable(FrdmK64f_Input::IDBinaryInput inp, bool act) { _buttonEnable[inp] = act; } // Not interresting section (do not use those methods) // Callbacks for joystick void onButtonLeftRise(void) { if (_buttonEnable[ButtonLeft]) Parent::_events.push(Event(Event::FrdmK64f, Event::BinaryInput, ButtonLeft, Event::Rise)); } void onButtonLeftFall(void) { if (_buttonEnable[ButtonLeft]) Parent::_events.push(Event(Event::FrdmK64f, Event::BinaryInput, ButtonLeft, Event::Fall)); } void onButtonRightRise(void) { if (_buttonEnable[ButtonRight]) Parent::_events.push(Event(Event::FrdmK64f, Event::BinaryInput, ButtonRight, Event::Rise)); } void onButtonRightFall(void) { if (_buttonEnable[ButtonRight]) Parent::_events.push(Event(Event::FrdmK64f, Event::BinaryInput, ButtonRight, Event::Fall)); } // Callback for others sensors virtual void chechAnalog(void) { Parent::chechAnalog(); } };