Skip to content

Commit 76f0d56

Browse files
Merge pull request #354 from runger1101001/dev
Make timeout configurable in MagneticSensorPWM #348
2 parents 186e5cf + 8ea87ab commit 76f0d56

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)