Skip to content

Commit e283291

Browse files
committed
Update name of helper functions in SCDs
1 parent 7ee24c3 commit e283291

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/components/i2c/drivers/WipperSnapper_I2C_Driver_SCD30.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver {
5858
@brief Checks if sensor was read within last 1s, or is the first read.
5959
@returns True if the sensor was recently read, False otherwise.
6060
*/
61-
bool alreadyRecentlyRead() {
61+
bool hasBeenReadInLastSecond() {
6262
return _lastRead != 0 && millis() - _lastRead < 1000;
6363
}
6464

@@ -68,7 +68,7 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver {
6868
@returns True if the sensor is ready, False otherwise.
6969
*/
7070
/*******************************************************************************/
71-
bool sensorReady() {
71+
bool isSensorReady() {
7272
if (!_scd->dataReady()) {
7373
// failed, one more quick attempt
7474
delay(100);
@@ -87,11 +87,11 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver {
8787
/*******************************************************************************/
8888
bool readSensorData() {
8989
// dont read sensor more than once per second
90-
if (alreadyRecentlyRead()) {
90+
if (hasBeenReadInLastSecond()) {
9191
return true;
9292
}
9393

94-
if (!sensorReady()) {
94+
if (!isSensorReady()) {
9595
return false;
9696
}
9797

src/components/i2c/drivers/WipperSnapper_I2C_Driver_SCD4X.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,16 @@ class WipperSnapper_I2C_Driver_SCD4X : public WipperSnapper_I2C_Driver {
4242
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {
4343
_i2c = i2c;
4444
_sensorAddress = sensorAddress;
45+
_lastRead = 0;
46+
_temperature = 20.0;
47+
_humidity = 50.0;
4548
}
4649

4750
/*******************************************************************************/
4851
/*!
4952
@brief Initializes the SCD40 sensor and begins I2C.
5053
@param pollPeriod
51-
The sensor's polling period in milliseconds.
54+
The sensor's polling period in seconds.
5255
@returns True if initialized successfully, False otherwise.
5356
*/
5457
/*******************************************************************************/
@@ -67,7 +70,7 @@ class WipperSnapper_I2C_Driver_SCD4X : public WipperSnapper_I2C_Driver {
6770
}
6871

6972
// Takes 5seconds to have data ready, don't queue read until then
70-
ulong currentTime = millis() - (pollPeriod * 1000 - 5000); // 5s time
73+
long currentTime = (long)millis() - ((pollPeriod * 1000) - 5000); // 5s time
7174
this->setSensorCO2PeriodPrv(currentTime);
7275
this->setSensorAmbientTempFPeriodPrv(currentTime);
7376
this->setSensorAmbientTempPeriodPrv(currentTime);
@@ -80,7 +83,7 @@ class WipperSnapper_I2C_Driver_SCD4X : public WipperSnapper_I2C_Driver {
8083
@brief Checks if sensor was read within last 1s, or is the first read.
8184
@returns True if the sensor was recently read, False otherwise.
8285
*/
83-
bool alreadyRecentlyRead() {
86+
bool hasBeenReadInLastSecond() {
8487
return _lastRead != 0 && millis() - _lastRead < 1000;
8588
}
8689

@@ -90,7 +93,7 @@ class WipperSnapper_I2C_Driver_SCD4X : public WipperSnapper_I2C_Driver {
9093
@returns True if the sensor is ready, False otherwise.
9194
*/
9295
/*******************************************************************************/
93-
bool sensorReady() {
96+
bool isSensorReady() {
9497
bool isDataReady = false;
9598
uint16_t error = _scd->getDataReadyFlag(isDataReady);
9699
if (error != 0 || !isDataReady) {
@@ -112,11 +115,11 @@ class WipperSnapper_I2C_Driver_SCD4X : public WipperSnapper_I2C_Driver {
112115
/*******************************************************************************/
113116
bool readSensorData() {
114117
// dont read sensor more than once per second
115-
if (alreadyRecentlyRead()) {
118+
if (hasBeenReadInLastSecond()) {
116119
return true;
117120
}
118121

119-
if (!sensorReady()) {
122+
if (!isSensorReady()) {
120123
return false;
121124
}
122125

@@ -189,9 +192,9 @@ class WipperSnapper_I2C_Driver_SCD4X : public WipperSnapper_I2C_Driver {
189192
protected:
190193
SensirionI2CScd4x *_scd = nullptr; ///< SCD4x driver object
191194
uint16_t _co2 = 0; ///< SCD4x co2 reading
192-
float _temperature = 20.0f; ///< SCD4x temperature reading
193-
float _humidity = 50.0f; ///< SCD4x humidity reading
194-
ulong _lastRead = 0; ///< Last time the sensor was read
195+
float _temperature; ///< SCD4x temperature reading
196+
float _humidity; ///< SCD4x humidity reading
197+
ulong _lastRead; ///< Last time the sensor was read
195198
};
196199

197200
#endif // WipperSnapper_I2C_Driver_SCD4X

0 commit comments

Comments
 (0)