File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -565,7 +565,7 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
565
565
WS_DEBUG_PRINTLN (" VEML7700 Initialized Successfully!" );
566
566
} else if (strcmp (" scd40" , msgDeviceInitReq->i2c_device_name ) == 0 ) {
567
567
_scd40 = new WipperSnapper_I2C_Driver_SCD4X (this ->_i2c , i2cAddress);
568
- if (!_scd40->begin ()) {
568
+ if (!_scd40->begin (msgDeviceInitReq-> i2c_device_properties [ 0 ]. sensor_period )) {
569
569
WS_DEBUG_PRINTLN (" ERROR: Failed to initialize SCD4x!" );
570
570
_busStatusResponse =
571
571
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
Original file line number Diff line number Diff line change @@ -47,10 +47,12 @@ class WipperSnapper_I2C_Driver_SCD4X : public WipperSnapper_I2C_Driver {
47
47
/* ******************************************************************************/
48
48
/* !
49
49
@brief Initializes the SCD40 sensor and begins I2C.
50
+ @param pollPeriod
51
+ The sensor's polling period in milliseconds.
50
52
@returns True if initialized successfully, False otherwise.
51
53
*/
52
54
/* ******************************************************************************/
53
- bool begin () {
55
+ bool begin (ulong pollPeriod ) {
54
56
_scd = new SensirionI2CScd4x ();
55
57
_scd->begin (*_i2c);
56
58
@@ -65,7 +67,7 @@ class WipperSnapper_I2C_Driver_SCD4X : public WipperSnapper_I2C_Driver {
65
67
}
66
68
67
69
// Takes 5seconds to have data ready, don't queue read until then
68
- ulong currentTime = millis () - 25000uL; // T-25s, so 5s time for 30s polling
70
+ ulong currentTime = millis () - (pollPeriod * 1000 - 5000 ); // 5s time
69
71
this ->setSensorCO2PeriodPrv (currentTime);
70
72
this ->setSensorAmbientTempFPeriodPrv (currentTime);
71
73
this ->setSensorAmbientTempPeriodPrv (currentTime);
You can’t perform that action at this time.
0 commit comments