Skip to content

Commit 8ea87ab

Browse files
author
Richard Unger
committed
timeout configurable in MagneticSensorPWM #348
1 parent 3eb2bc3 commit 8ea87ab

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/sensors/MagneticSensorPWM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ float MagneticSensorPWM::getSensorAngle(){
8585
int MagneticSensorPWM::getRawCount(){
8686
if (!is_interrupt_based){ // if it's not interrupt based read the value in a blocking way
8787
pulse_timestamp = _micros(); // ideally this should be done right at the rising edge of the pulse
88-
pulse_length_us = pulseIn(pinPWM, HIGH, 1200); // 1200us timeout, should this be configurable?
88+
pulse_length_us = pulseIn(pinPWM, HIGH, timeout_us); // 1200us timeout, should this be configurable?
8989
}
9090
return pulse_length_us;
9191
}

src/sensors/MagneticSensorPWM.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class MagneticSensorPWM: public Sensor{
4444
void enableInterrupt(void (*doPWM)());
4545
unsigned long pulse_length_us;
4646

47+
unsigned int timeout_us = 1200;
48+
4749
private:
4850
// raw count (typically in range of 0-1023)
4951
int raw_count;

0 commit comments

Comments
 (0)