108 this->callback = callback;
130 static void IRAM_ATTR staticInterruptHandler()
132 return self->interruptHandler();
135 void interruptHandler();
137 static void staticCallback(uint32_t
value);
140 uint32_t isrTicks{0};
142 volatile Pulse reading{};
146 State state{State::disabled};
static constexpr uint16_t CYCLE_TOLERANCE
Definition: PwmReader.h:44
Reads input pulse width asynchronously.
Definition: PwmReader.h:39
void end()
Stop the PWM reader.
void begin(uint8_t pin, DetectionRange range)
Start the PWM reader.
uint16_t low
Definition: PwmReader.h:56
ValType muldiv(const ValType &value, const NumDenType &num, const NumDenType &den)
Perform muldiv using unsigned integer types.
Definition: muldiv.h:110
uint16_t calculatePpm(DetectionRange range)
Definition: PwmReader.h:73
bool suspend()
Temporarily suspend readings and disable interrupts on the PWM pin.
uint16_t getCycleTime() const
Definition: PwmReader.h:61
~PwmReader()
Definition: PwmReader.h:79
DetectionRange
Device may be configured to output CO2 PPM values in various ranges.
Definition: common.h:27
static constexpr uint16_t CYCLE_MS
Definition: PwmReader.h:43
uint16_t high
Definition: PwmReader.h:57
bool resume()
Resume reading after a call to suspend()
uint32_t value
Definition: PwmReader.h:59
void setCallback(Callback callback)
Set a callback to be invoked whenever a valid reading is obtained.
Definition: PwmReader.h:106
uint16_t getMeasurement() const
Obtain the most recent measurement.
unsigned pwmRead(uint8_t pwmPin, DetectionRange range)
Read PWM output from sensor.
Used internally to measure a high/low pulse pair.
Definition: PwmReader.h:54
bool isValid() const
Definition: PwmReader.h:66