ESE519 blank Joystick class
Dependents: ESE519_Lab6_part1_skeleton
Fork of Joystick_skelleton by
Joystick.h@2:893fd930d3fb, 2016-10-20 (annotated)
- Committer:
- csharer
- Date:
- Thu Oct 20 23:12:18 2016 +0000
- Revision:
- 2:893fd930d3fb
- Parent:
- 1:c42a77267f7b
added comments; changed DEAD_ZONE/2 to just DEAD_ZONE;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
csharer | 0:46523bf02e61 | 1 | #ifndef _Joystick_h |
csharer | 0:46523bf02e61 | 2 | #define _Joystick_h |
csharer | 0:46523bf02e61 | 3 | |
csharer | 0:46523bf02e61 | 4 | #include "mbed.h" |
csharer | 0:46523bf02e61 | 5 | |
csharer | 2:893fd930d3fb | 6 | #define DEAD_ZONE 2 //where values will be set to zero. [-2,+2] |
csharer | 0:46523bf02e61 | 7 | |
csharer | 0:46523bf02e61 | 8 | class Joystick |
csharer | 0:46523bf02e61 | 9 | { |
csharer | 0:46523bf02e61 | 10 | public: //Function and variables go here |
csharer | 0:46523bf02e61 | 11 | Joystick(PinName pinA, PinName pinB); //Constructor |
csharer | 2:893fd930d3fb | 12 | float horizontal(void); //Reads horizontal value of joystick |
csharer | 2:893fd930d3fb | 13 | float vertical(void); //Reads vertical value of joystick |
csharer | 2:893fd930d3fb | 14 | void setScale(float min, float max); //Set the scale of values |
csharer | 0:46523bf02e61 | 15 | |
csharer | 0:46523bf02e61 | 16 | private: |
csharer | 2:893fd930d3fb | 17 | AnalogIn horiz; //horizontal pot in joystick |
csharer | 2:893fd930d3fb | 18 | AnalogIn vert; //Vertical pot in joystick |
csharer | 0:46523bf02e61 | 19 | |
csharer | 0:46523bf02e61 | 20 | float _min, _max; //Min and Max for scaling |
csharer | 0:46523bf02e61 | 21 | float rawMinH, rawMaxH, rawMinV, rawMaxV; //Max/Min raw values we have seen so far |
csharer | 0:46523bf02e61 | 22 | float raw_hc, raw_vc; //Raw Center values |
csharer | 0:46523bf02e61 | 23 | }; |
csharer | 0:46523bf02e61 | 24 | |
csharer | 0:46523bf02e61 | 25 | #endif |