Skip to content

Commit a9cfbee

Browse files
author
Jason Duncan
committed
Fixed a bug where a pedal would have to be pushed in halfway before itd start to register.
1 parent 54cb5c5 commit a9cfbee

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

G27_Pedals_and_Shifter.ino

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,12 @@ void* clutchPedal;
112112
int axisValue(void* in) {
113113
Pedal* input = (Pedal*)in;
114114

115-
int range = input->max - input->min;
116-
if (range == 0) {
115+
int physicalRange = input->max - input->min;
116+
if (physicalRange == 0) {
117117
return 0;
118118
}
119119

120-
long step1 = input->cur - input->min;
121-
long step2 = step1 * (MAX_AXIS * 2);
122-
float step3 = step2 / range;
123-
int result = step3 - MAX_AXIS;
120+
int result = map(input->cur, input->min, input->max, 0, MAX_AXIS);
124121

125122
if (result < 0) {
126123
return 0;

0 commit comments

Comments
 (0)