Since our code is based on lab 6 code and we also used the joystick to test movement initially. So joystick still existed tough we haven't use that eventually
Fork of Joystick_skeleton by
Joystick.h@5:8b41e2fc69f9, 2017-04-26 (annotated)
- Committer:
- britneyd
- Date:
- Wed Apr 26 21:00:09 2017 +0000
- Revision:
- 5:8b41e2fc69f9
- Parent:
- 2:893fd930d3fb
Controller code;
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 |