|
21 | 21 | // red for brake, green for gas, blue for clutch |
22 | 22 | //#define PEDAL_COLORS true |
23 | 23 |
|
| 24 | +// use static thresholds rather than on-the-fly calibration |
| 25 | +#define STATIC_THRESHOLDS true |
| 26 | + |
24 | 27 | // LED PINS |
25 | 28 | #define RED_PIN 3 |
26 | 29 | #define GREEN_PIN 5 |
|
93 | 96 | #define SHIFTER_YAXIS_135 600 //Gears 1,3,5 |
94 | 97 | #define SHIFTER_YAXIS_246 300 //Gears 2,4,6, R |
95 | 98 |
|
| 99 | +// PEDAL AXIS THRESHOLDS |
| 100 | +#define MIN_GAS 27 |
| 101 | +#define MAX_GAS 925 |
| 102 | +#define MIN_BRAKE 26 |
| 103 | +#define MAX_BRAKE 845 |
| 104 | +#define MIN_CLUTCH 45 |
| 105 | +#define MAX_CLUTCH 932 |
| 106 | + |
96 | 107 | // MISC. |
97 | 108 | #define MAX_AXIS 1023 |
98 | 109 | #define SIGNAL_SETTLE_DELAY 10 |
@@ -133,10 +144,12 @@ void processPedal(void* in) { |
133 | 144 |
|
134 | 145 | input->cur = analogRead(input->pin); |
135 | 146 |
|
| 147 | + #if !defined(STATIC_THRESHOLDS) |
136 | 148 | // calibrate, we want the highest this pedal has been |
137 | 149 | input->max = input->cur > input->max ? input->cur : input->max; |
138 | 150 | // same for lowest, but bottom out at current value rather than 0 |
139 | 151 | input->min = input->min == 0 || input->cur < input->min ? input->cur : input->min; |
| 152 | + #endif |
140 | 153 |
|
141 | 154 | input->axis = axisValue(input); |
142 | 155 | } |
@@ -360,6 +373,17 @@ void setup() { |
360 | 373 | brake->pin = BRAKE_PIN; |
361 | 374 | clutch->pin = CLUTCH_PIN; |
362 | 375 |
|
| 376 | + #if defined(STATIC_THRESHOLDS) |
| 377 | + gas->min = MIN_GAS; |
| 378 | + gas->max = MAX_GAS; |
| 379 | + |
| 380 | + brake->min = MIN_BRAKE; |
| 381 | + brake->max = MAX_BRAKE; |
| 382 | + |
| 383 | + clutch->min = MIN_CLUTCH; |
| 384 | + clutch->max = MAX_CLUTCH; |
| 385 | + #endif |
| 386 | + |
363 | 387 | gasPedal = gas; |
364 | 388 | brakePedal = brake; |
365 | 389 | clutchPedal = clutch; |
|
0 commit comments