Go to the documentation of this file.
108 this->callback = callback;
130 static void IRAM_ATTR staticInterruptHandler()
132 return self->interruptHandler();
135 void interruptHandler();
137 static void staticCallback(uint32_t value);
139 static PwmReader*
self;
140 uint32_t isrTicks{0};
142 volatile Pulse reading{};
146 State state{State::disabled};
Delegate< void(uint16_t ppm)> Callback
Callback for regular readings.
Definition: PwmReader.h:83
uint16_t getCycleTime() const
Definition: PwmReader.h:95
void end()
Stop the PWM reader.
unsigned pwmRead(uint8_t pwmPin, DetectionRange range)
Read PWM output from sensor.
bool resume()
Resume reading after a call to suspend()
uint16_t high
Definition: PwmReader.h:91
DetectionRange
Device may be configured to output CO2 PPM values in various ranges.
Definition: common.h:44
static constexpr uint16_t CYCLE_TOLERANCE
Definition: PwmReader.h:78
void setCallback(Callback callback)
Set a callback to be invoked whenever a valid reading is obtained.
Definition: PwmReader.h:140
uint32_t value
Definition: PwmReader.h:93
~PwmReader()
Definition: PwmReader.h:113
bool isValid() const
Definition: PwmReader.h:100
ValType muldiv(const ValType &value, const NumDenType &num, const NumDenType &den)
Perform muldiv using unsigned integer types.
Definition: muldiv.h:110
uint16_t getMeasurement() const
Obtain the most recent measurement.
uint16_t low
Definition: PwmReader.h:90
static constexpr uint16_t CYCLE_MS
Definition: PwmReader.h:77
bool suspend()
Temporarily suspend readings and disable interrupts on the PWM pin.
void begin(uint8_t pin, DetectionRange range)
Start the PWM reader.
Definition: Delegate.h:20
uint16_t calculatePpm(DetectionRange range)
Definition: PwmReader.h:107