Skip to content

Commit

Permalink
timeout configurable in MagneticSensorPWM #348
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Unger committed Dec 2, 2023
1 parent 3eb2bc3 commit 8ea87ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sensors/MagneticSensorPWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ float MagneticSensorPWM::getSensorAngle(){
int MagneticSensorPWM::getRawCount(){
if (!is_interrupt_based){ // if it's not interrupt based read the value in a blocking way
pulse_timestamp = _micros(); // ideally this should be done right at the rising edge of the pulse
pulse_length_us = pulseIn(pinPWM, HIGH, 1200); // 1200us timeout, should this be configurable?
pulse_length_us = pulseIn(pinPWM, HIGH, timeout_us); // 1200us timeout, should this be configurable?
}
return pulse_length_us;
}
Expand Down
2 changes: 2 additions & 0 deletions src/sensors/MagneticSensorPWM.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class MagneticSensorPWM: public Sensor{
void enableInterrupt(void (*doPWM)());
unsigned long pulse_length_us;

unsigned int timeout_us = 1200;

private:
// raw count (typically in range of 0-1023)
int raw_count;
Expand Down

0 comments on commit 8ea87ab

Please sign in to comment.