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.
Dependencies: N5110 PinDetect PowerControl mbed
InputManager.h
00001 #ifndef INPUT_H 00002 #define INPUT_H 00003 00004 #include "N5110.h" 00005 #include "PinDetect.h" 00006 #include "Joystick.h" 00007 00008 /// @file InputManager.h 00009 00010 struct Input 00011 { 00012 /** Used as identificator for the different buttons */ 00013 enum Button{ButtonA, ButtonB, ButtonC}; 00014 }; 00015 00016 /// Used to manage user input from buttons and thumb joystick 00017 class InputManager 00018 { 00019 public: 00020 00021 /** Creates a new InputManager object 00022 * @param pinA Pin connected to button A 00023 * @param pinB Pin connected to button B 00024 * @param pinc Pin connected to button C 00025 * @param x Pin connected to the horizontal potentiometer of the joystick 00026 * @param y Pin connected to the vertical potentiometer of the joystick 00027 * @param button Pin connected to the button of the thumb joystick 00028 */ 00029 InputManager(PinName pinA, PinName pinB, PinName pinC, PinName joyH, PinName joyV, PinName joyBtn); 00030 00031 /** Deconstructor. Frees allocated memory related to the buttons and the joystick **/ 00032 ~InputManager(); 00033 00034 Joystick *joystick; 00035 00036 /** @brief Adds a button interrupt which is invoked when the button is pressed. Button needs to be released for the interrupt to occur again. 00037 * @param button Name of the button. 00038 * @param func Callback function. 00039 */ 00040 void addBtnPressInterrupt(Input::Button button, void (*func)(void)); 00041 00042 00043 /** Reads the current value of a button. 00044 * @param button The button we want to read. 00045 * @return Returns 1 if button is pressed, 0 otherwise. 00046 */ 00047 int read(Input::Button button); 00048 00049 private: 00050 /// Button objects 00051 PinDetect *btnA; 00052 PinDetect *btnB; 00053 PinDetect *btnC; 00054 00055 /** Returns a pointer to the actual button object 00056 * @param button The requested button. 00057 * @return Pointer to the button. 00058 */ 00059 PinDetect* getBtnPtr(Input::Button button); 00060 }; 00061 00062 #endif 00063
Generated on Tue Jul 12 2022 21:59:47 by
