#include <pas-co2-pulse.hpp>
Public Member Functions | |
PASCO2Pulse (PWM *const pwm, Timer *const timer=nullptr, pasco2::GPIO *const interrupt=nullptr, pasco2::GPIO *const power3V3=nullptr, pasco2::GPIO *const power12V=nullptr, pasco2::GPIO *const pwmSelect=nullptr) | |
PAS CO2 Pulse Constructor. More... | |
virtual | ~PASCO2Pulse () |
PAS CO2 Pulse Destructor. More... | |
Error_t | enable () |
Enables the sensor. More... | |
Error_t | disable () |
Disables the sensor. More... | |
Error_t | startMeasure (void(*cback)(void *)=nullptr) |
Triggers the internal measuring of the sensor. More... | |
Error_t | stopMeasure () |
Stops the internal measuring of the sensor. More... | |
Error_t | getCO2 (int16_t &co2ppm) |
Gets the CO2 concentration measured. More... | |
Error_t | reset () |
Resets the sensor. More... | |
PASCO2Pulse::PASCO2Pulse | ( | PWM *const | pwm, |
Timer *const | timer = nullptr , |
||
pasco2::GPIO *const | interrupt = nullptr , |
||
pasco2::GPIO *const | power3V3 = nullptr , |
||
pasco2::GPIO *const | power12V = nullptr , |
||
pasco2::GPIO *const | pwmSelect = nullptr |
||
) |
PAS CO2 Pulse Constructor.
Mandatory arguments:
Optional arguments:
Most of the GPIO will be fixed by hardware. In particular those enabling the sensor main power and the emitter power. They are part of the sensor library to provide potential absolute control by software. The hardware interface and its features, are also provided in the library. But it can be as well handled externally
[in] | *PWM | PWM instance |
[in] | *timer | Timer instance |
[in] | *interrupt | Interrupt GPIO instance. Default is nullptr |
[in] | *power3V3 | Power 3V3 control GPIO instance. Default is nullptr |
[in] | *power12V | Power 12V control GPIO instance. Default is nullptr |
[in] | *pwmSelect | PWM select GPIO instance. Default is nullptr |
|
virtual |
PAS CO2 Pulse Destructor.
Error_t PASCO2Pulse::enable | ( | ) |
Enables the sensor.
Initializes the controller peripheral interfaces and enable VDD and IR emitter power of the sensor
OK | if success |
INTF_ERROR | if interface error |
IC_POWERON_ERROR | if power-on error |
Error_t PASCO2Pulse::disable | ( | ) |
Disables the sensor.
Initializes the controller peripheral interfaces and enable VDD and IR emitter power of the sensor
OK | if success |
INTF_ERROR | if interface error |
Error_t PASCO2Pulse::startMeasure | ( | void(*)(void *) | cback = nullptr | ) |
Triggers the internal measuring of the sensor.
The PWM select signal will be enabled if it is available. If this signal is fixed on hardware, the sensor will already output the PWM signal without the need of calling startMeasure().
By default, if no other setup has been configured through the serial interface, a pulse train will be provided by the sensor every 1 min.
Optionally, if a callback is passed by argument, the interrupt event will occur approximately 1 second before the measurement starts. This can be used for synching the pwm redouts on the microcontroller. Some example:
[in] | *cback | Pointer to the callback function to be called upon interrupt. Default is nullptr |
OK | if success |
INTF_ERROR | if interface error |
CONFIG_ERROR | if invalid configuration parameter |
Error_t PASCO2Pulse::stopMeasure | ( | ) |
Stops the internal measuring of the sensor.
Disables the PWM select signal
OK | if success |
INTF_ERROR | if interface error |
Error_t PASCO2Pulse::getCO2 | ( | int16_t & | co2ppm | ) |
Gets the CO2 concentration measured.
The value read is zero when no measurement is yet available. In case of error, the read value is set to -1
[out] | co2ppm | CO2 concentration read (in ppm) |
OK | if success |
INTF_ERROR | if interface error |
Error_t PASCO2Pulse::reset | ( | ) |
Resets the sensor.
The hardware reset will disable 3V3 power output for 200 ms to perform a hardware reset
OK | if success |
INTF_ERROR | if interface error |
RESET_ERROR | if the device reset error |