Skip to content

Commit e8c59b0

Browse files
committed
fix(sensor): replace magic number with constant for sensor read interval
1 parent 993fc01 commit e8c59b0

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

.agents/skills/add-sensor-component-v1/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ protected:
642642

643643
bool _readSensor() {
644644
unsigned long now = millis();
645-
if (_lastRead != 0 && now - _lastRead < 1000)
645+
if (_lastRead != 0 && now - _lastRead < ONE_SECOND_IN_MILLIS)
646646
return true; // recently read, use cached value
647647
if (!_tmp119->getEvent(&_cachedTemp))
648648
return false;

src/components/i2c/drivers/WipperSnapper_I2C_Driver_APDS9999.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class WipperSnapper_I2C_Driver_APDS9999 : public WipperSnapper_I2C_Driver {
8686
bool ReadSensorData() {
8787
unsigned long now = millis();
8888
// Don't read sensor more than once per second
89-
if (_lastRead != 0 && (now - _lastRead < 1000))
89+
if (_lastRead != 0 && (now - _lastRead < ONE_SECOND_IN_MILLIS))
9090
return true;
9191

9292
uint32_t r, g, b, ir;

src/components/i2c/drivers/WipperSnapper_I2C_Driver_SCD30.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class WipperSnapper_I2C_Driver_SCD30 : public WipperSnapper_I2C_Driver {
5959
@returns True if the sensor was recently read, False otherwise.
6060
*/
6161
bool HasBeenReadInLastSecond() {
62-
return _lastRead != 0 && millis() - _lastRead < 1000;
62+
return _lastRead != 0 && millis() - _lastRead < ONE_SECOND_IN_MILLIS;
6363
}
6464

6565
/*******************************************************************************/

src/components/i2c/drivers/WipperSnapper_I2C_Driver_SCD4X.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class WipperSnapper_I2C_Driver_SCD4X : public WipperSnapper_I2C_Driver {
7474
*/
7575
/*******************************************************************************/
7676
bool HasBeenReadInLastSecond() {
77-
return _lastRead != 0 && millis() - _lastRead < 1000;
77+
return _lastRead != 0 && millis() - _lastRead < ONE_SECOND_IN_MILLIS;
7878
}
7979

8080
/*******************************************************************************/

src/components/i2c/drivers/WipperSnapper_I2C_Driver_SEN5X.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class WipperSnapper_I2C_Driver_SEN5X : public WipperSnapper_I2C_Driver {
8282
@returns True if the sensor was recently read, False otherwise.
8383
*/
8484
bool HasBeenReadInLastSecond() {
85-
return _lastRead != 0 && millis() - _lastRead < 1000;
85+
return _lastRead != 0 && millis() - _lastRead < ONE_SECOND_IN_MILLIS;
8686
}
8787

8888
/*******************************************************************************/

src/components/i2c/drivers/WipperSnapper_I2C_Driver_SEN6X.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class WipperSnapper_I2C_Driver_SEN6X : public WipperSnapper_I2C_Driver {
8585
@returns True if the sensor was recently read, False otherwise.
8686
*/
8787
bool HasBeenReadInLastSecond() {
88-
return _lastRead != 0 && millis() - _lastRead < 1000;
88+
return _lastRead != 0 && millis() - _lastRead < ONE_SECOND_IN_MILLIS;
8989
}
9090

9191
/*******************************************************************************/

src/components/i2c/drivers/WipperSnapper_I2C_Driver_TMP119.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class WipperSnapper_I2C_Driver_TMP119 : public WipperSnapper_I2C_Driver {
9494
*/
9595
/*******************************************************************************/
9696
bool _readSensor() {
97-
if (_lastRead != 0 && millis() - _lastRead < 1000)
97+
if (_lastRead != 0 && millis() - _lastRead < ONE_SECOND_IN_MILLIS)
9898
return true; // use cached value
9999
if (!_tmp119->getEvent(&_cachedTemp))
100100
return false;

0 commit comments

Comments
 (0)