split project a bit
This commit is contained in:
31
src/sensors/CCS811Sensor.cpp
Normal file
31
src/sensors/CCS811Sensor.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// CCS811Sensor.cpp
|
||||
|
||||
#include "CCS811Sensor.h"
|
||||
|
||||
CCS811Sensor::CCS811Sensor(uint8_t wakePin) : _wakePin(wakePin), ccs811(wakePin) {
|
||||
// Constructor sets the wake pin and initializes the ccs811 object
|
||||
}
|
||||
|
||||
void CCS811Sensor::init(double* temperature, double* humidity) {
|
||||
// Enable CCS811
|
||||
bool ok = ccs811.begin();
|
||||
// let's handle if not OK later
|
||||
// Lock pointers to temperature and humidity values
|
||||
ok = ccs811.start(CCS811_MODE_1SEC);
|
||||
// if( !ok ) Serial.println("setup: CCS811 start FAILED");
|
||||
_temperaturePtr = temperature;
|
||||
_humidityPtr = humidity;
|
||||
}
|
||||
|
||||
void CCS811Sensor::init() {
|
||||
bool ok = ccs811.begin();
|
||||
}
|
||||
|
||||
void CCS811Sensor::read_values(uint16_t* eco2, uint16_t* etvoc, uint16_t* errstat, uint16_t* raw) {
|
||||
if (_temperaturePtr && _humidityPtr) {
|
||||
// Set environmental data for CCS811 sensor using pointers
|
||||
ccs811.set_envdata(*_temperaturePtr, *_humidityPtr);
|
||||
}
|
||||
// Read eCO2, eTVOC, error status, and raw data values from CCS811 sensor
|
||||
ccs811.read(eco2, etvoc, errstat, raw);
|
||||
}
|
||||
Reference in New Issue
Block a user