Skip to content

Commit 8228e12

Browse files
author
Jason Duncan
committed
Added static thresholds for consistency and such.
1 parent a9cfbee commit 8228e12

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

G27_Pedals_and_Shifter.ino

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
// red for brake, green for gas, blue for clutch
2222
//#define PEDAL_COLORS true
2323

24+
// use static thresholds rather than on-the-fly calibration
25+
#define STATIC_THRESHOLDS true
26+
2427
// LED PINS
2528
#define RED_PIN 3
2629
#define GREEN_PIN 5
@@ -93,6 +96,14 @@
9396
#define SHIFTER_YAXIS_135 600 //Gears 1,3,5
9497
#define SHIFTER_YAXIS_246 300 //Gears 2,4,6, R
9598

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+
96107
// MISC.
97108
#define MAX_AXIS 1023
98109
#define SIGNAL_SETTLE_DELAY 10
@@ -133,10 +144,12 @@ void processPedal(void* in) {
133144

134145
input->cur = analogRead(input->pin);
135146

147+
#if !defined(STATIC_THRESHOLDS)
136148
// calibrate, we want the highest this pedal has been
137149
input->max = input->cur > input->max ? input->cur : input->max;
138150
// same for lowest, but bottom out at current value rather than 0
139151
input->min = input->min == 0 || input->cur < input->min ? input->cur : input->min;
152+
#endif
140153

141154
input->axis = axisValue(input);
142155
}
@@ -360,6 +373,17 @@ void setup() {
360373
brake->pin = BRAKE_PIN;
361374
clutch->pin = CLUTCH_PIN;
362375

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+
363387
gasPedal = gas;
364388
brakePedal = brake;
365389
clutchPedal = clutch;

0 commit comments

Comments
 (0)