wobblyhead hg > arduino > Joystick
comparison Joystick.h @ 4:a3fceeff4b21
adjusted deadzone thresholds
| author | ark |
|---|---|
| date | 2017-02-04 22:59 +0100 |
| parents | 395297edda26 |
| children | 88126e5a9d86 |
comparison
equal
deleted
inserted
replaced
| 3:d423ea399401 | 4:a3fceeff4b21 |
|---|---|
| 1 #ifndef Joystick_h | 1 #ifndef Joystick_h |
| 2 #define Joystick_h | 2 #define Joystick_h |
| 3 | 3 |
| 4 #include <Potentiometer.h> | 4 #include <Potentiometer.h> |
| 5 #include <Button.h> | 5 #include <Button.h> |
| 6 | |
| 7 /** | |
| 8 * center deadzone radius, if the joystick is not calibrated. | |
| 9 * raw pot value (0..1023) | |
| 10 */ | |
| 11 #define CENTER_DEADZONE_UNCALIBRATED 100 | |
| 12 | |
| 13 /** | |
| 14 * center deadzone radius, if the joystick is calibrated. | |
| 15 * raw pot value (0..1023) | |
| 16 */ | |
| 17 #define CENTER_DEADZONE_CALIBRATED 15 | |
| 18 | |
| 19 /** | |
| 20 * center radius, for digital interpretation. logical (-100..100) value | |
| 21 */ | |
| 22 #define CENTER_RADIUS_DIGITAL 20 | |
| 6 | 23 |
| 7 | 24 |
| 8 /** | 25 /** |
| 9 utility class for interpreting joystick values. | 26 utility class for interpreting joystick values. |
| 10 combines two potentiometer and calibration information to provide a vector | 27 combines two potentiometer and calibration information to provide a vector |
| 37 | 54 |
| 38 // calibrated center of x axis | 55 // calibrated center of x axis |
| 39 int centerX; | 56 int centerX; |
| 40 // calibrated center of y axis | 57 // calibrated center of y axis |
| 41 int centerY; | 58 int centerY; |
| 42 | |
| 43 /** | |
| 44 * center deadzone radius, if the joystick is not calibrated. | |
| 45 * | |
| 46 * positions within this distance from the center are considered in the | |
| 47 * center. | |
| 48 */ | |
| 49 const int CENTER_DEADZONE_UNCALIBRATED = 50; | |
| 50 | |
| 51 /** | |
| 52 * center deadzone radius, if the joystick is calibrated. | |
| 53 * positions within this distance from the center are considered in the | |
| 54 * center. | |
| 55 */ | |
| 56 const int CENTER_DEADZONE_CALIBRATED = 5; | |
| 57 | |
| 58 /** | |
| 59 * center radius, for digital interpretation. | |
| 60 */ | |
| 61 const int CENTER_RADIUS_DIGITAL = 20; | |
| 62 | 59 |
| 63 /** | 60 /** |
| 64 create an uninitialised Joystick. | 61 create an uninitialised Joystick. |
| 65 setup() must be called after this to make it usable. | 62 setup() must be called after this to make it usable. |
| 66 */ | 63 */ |
