Skip to content

Commit 1ad63d1

Browse files
author
Richard Unger
committed
also add a check to prevent negative angles
1 parent 70362bb commit 1ad63d1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/sensors/MagneticSensorPWM.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ float MagneticSensorPWM::getSensorAngle(){
6363
// raw data from sensor
6464
raw_count = getRawCount();
6565
if (raw_count > max_raw_count) raw_count = max_raw_count;
66+
if (raw_count < min_raw_count) raw_count = min_raw_count;
6667
return( (float) (raw_count - min_raw_count) / (float)cpr) * _2PI;
6768
}
6869

0 commit comments

Comments
 (0)