Skip to content

Commit

Permalink
fix small things
Browse files Browse the repository at this point in the history
  • Loading branch information
vospascal committed Apr 25, 2021
1 parent d085b85 commit 9c63af4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pedaal/Pedal.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,21 @@ class Pedal
int rawValue = 0;
if (_signal == 0) {
rawValue = analogRead(_analogInput);
if (rawValue < 0) rawValue = 0;
}
if (_signal == 1) {
rawValue = _loadCell.read();
if (rawValue > BRAKE_PEDAL_LOAD_BEAM_CELL_MAX_VAL) {
rawValue = 0;
}
if (rawValue < 0) rawValue = 0;
rawValue /= BRAKE_PEDAL_LOAD_BEAM_CELL_SCALING;
}
if (_signal == 2) {
rawValue = _ads1015.getValue();
if (rawValue < 0) rawValue = 0;
}

if (rawValue < 0) rawValue = 0;
if (_smooth == 1) {
rawValue = as.smooth(rawValue);
}
Pedal::updatePedal(rawValue);
}

Expand Down Expand Up @@ -178,6 +180,10 @@ class Pedal

////////////////////////////////////////////////////////////////////////////////

if (_smooth == 1) {
rawValue = as.smooth(rawValue);
}

if (_inverted == 1) {
rawValue = SENSOR_RANGE - rawValue;
}
Expand Down

0 comments on commit 9c63af4

Please sign in to comment.