Library for the Sparkfun 5- Way Tact Switch (Part# BOB- 1187) Board is modified for use with a single analog input.
Fork of FivePosSwitch by
Revision 4:10c4b7cb4e8c, committed 2015-10-04
- Comitter:
- electromotivated
- Date:
- Sun Oct 04 20:07:52 2015 +0000
- Parent:
- 3:dcb9eef119cf
- Child:
- 5:413df8008ce3
- Commit message:
- release v1;
Changed in this revision
| FivePosSwitch.cpp | Show annotated file Show diff for this revision Revisions of this file |
| FivePosSwitch.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/FivePosSwitch.cpp Sun Oct 04 19:50:26 2015 +0000
+++ b/FivePosSwitch.cpp Sun Oct 04 20:07:52 2015 +0000
@@ -4,7 +4,7 @@
FivePosSwitch::FivePosSwitch(AnalogIn pin):_pin(pin){
}
-ACTIVE_POSITION_t FivePosSwitch::getPosition(){
+ACTIVE_POSITION FivePosSwitch::getPosition(){
float ain = _pin;
if((1.0 - TOLERANCE <= ain) && (ain <= 1.0 + TOLERANCE)) return UP;
--- a/FivePosSwitch.h Sun Oct 04 19:50:26 2015 +0000
+++ b/FivePosSwitch.h Sun Oct 04 20:07:52 2015 +0000
@@ -48,7 +48,7 @@
#define FIVE_POS_SWITCH
#include "mbed.h"
-typedef enum {NONE, UP, CENTER, LEFT, DOWN, RIGHT}ACTIVE_POSITION_t;
+enum ACTIVE_POSITION{NONE, UP, CENTER, LEFT, DOWN, RIGHT};
class FivePosSwitch{
public:
@@ -59,7 +59,7 @@
/** Get the currently pressed switch position
@return The currently pressed switch position
*/
- ACTIVE_POSITION_t getPosition();
+ ACTIVE_POSITION getPosition();
private:
AnalogIn _pin;
static const float TOLERANCE = 0.075; // Allowable tolerance in evaluating for active switch
