Skip to content

Commit fe1cc3a

Browse files
committed
doxygen accumulation vars
1 parent 662f61c commit fe1cc3a

File tree

2 files changed

+46
-13
lines changed

2 files changed

+46
-13
lines changed

src/components/i2c/drivers/WipperSnapper_I2C_Driver_SGP30.h

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ class WipperSnapper_I2C_Driver_SGP30 : public WipperSnapper_I2C_Driver {
5959
return true;
6060
}
6161

62+
/*******************************************************************************/
63+
/*!
64+
@brief Reads the current eCO2 value (ppm).
65+
@param senseEvent Pointer to event to fill.
66+
@returns True if a value was obtained, False otherwise.
67+
*/
68+
/*******************************************************************************/
6269
bool getEventECO2(sensors_event_t *senseEvent) override {
6370
if (!_sgp30)
6471
return false;
@@ -68,6 +75,13 @@ class WipperSnapper_I2C_Driver_SGP30 : public WipperSnapper_I2C_Driver {
6875
return ok;
6976
}
7077

78+
/*******************************************************************************/
79+
/*!
80+
@brief Reads the current TVOC value (ppb).
81+
@param senseEvent Pointer to event to fill.
82+
@returns True if a value was obtained, False otherwise.
83+
*/
84+
/*******************************************************************************/
7185
bool getEventTVOC(sensors_event_t *senseEvent) override {
7286
if (!_sgp30)
7387
return false;
@@ -77,6 +91,13 @@ class WipperSnapper_I2C_Driver_SGP30 : public WipperSnapper_I2C_Driver {
7791
return ok;
7892
}
7993

94+
/*******************************************************************************/
95+
/*!
96+
@brief Background sampler to maintain ~1 Hz IAQ reads and accumulate
97+
samples for later averaging at publish time.
98+
@note Must be non-blocking; invoked once per update loop.
99+
*/
100+
/*******************************************************************************/
80101
void fastTick() override {
81102
if (!iaqEnabled())
82103
return; // nothing enabled, save cycles
@@ -95,15 +116,21 @@ class WipperSnapper_I2C_Driver_SGP30 : public WipperSnapper_I2C_Driver {
95116
Adafruit_SGP30 *_sgp30; ///< Pointer to SGP30 sensor object
96117

97118
// Fast sampling state
98-
uint32_t _lastFastMs = 0;
99-
uint32_t _n = 0;
100-
uint32_t _eco2Sum = 0;
101-
uint32_t _tvocSum = 0;
119+
uint32_t _lastFastMs = 0; ///< Last millisecond timestamp of a fastTick sample.
120+
uint32_t _n = 0; ///< Number of accumulated background samples.
121+
uint32_t _eco2Sum = 0; ///< Sum of eCO2 samples for averaging.
122+
uint32_t _tvocSum = 0; ///< Sum of TVOC samples for averaging.
102123

124+
/*******************************************************************************/
125+
/*!
126+
@brief Indicates whether IAQ background sampling should run.
127+
@returns True if either eCO2 or TVOC periods are enabled; otherwise false.
128+
*/
129+
/*******************************************************************************/
103130
inline bool iaqEnabled() {
104131
// Enable IAQ background reads if either metric is requested
105132
return (getSensorECO2Period() > 0) || (getSensorTVOCPeriod() > 0);
106133
}
107134
};
108135

109-
#endif // WipperSnapper_I2C_Driver_SGP30
136+
#endif // WipperSnapper_I2C_Driver_SGP30_H

src/components/i2c/drivers/WipperSnapper_I2C_Driver_SGP40.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,23 @@ class WipperSnapper_I2C_Driver_SGP40 : public WipperSnapper_I2C_Driver {
146146
}
147147

148148
protected:
149-
Adafruit_SGP40 *_sgp40; ///< SGP40
150-
// background accumulation state
151-
uint32_t _lastFastMs = 0;
152-
uint32_t _n = 0;
153-
float _vocSum = 0.0f;
154-
uint32_t _rawSum = 0;
149+
Adafruit_SGP40 *_sgp40; ///< Pointer to the underlying Adafruit SGP40 object.
155150

156-
// enable fast sampling if either output is requested
151+
// Background accumulation state
152+
uint32_t _lastFastMs = 0; ///< Millisecond timestamp of last fastTick sample.
153+
uint32_t _n = 0; ///< Number of background samples accumulated.
154+
float _vocSum = 0.0f; ///< Sum of VOC index samples for averaging.
155+
uint32_t _rawSum = 0; ///< Sum of raw signal samples for averaging.
156+
157+
/*******************************************************************************/
158+
/*!
159+
@brief Indicates whether VOC background sampling should run.
160+
@returns True if either VOC index or raw period polling is enabled;
161+
otherwise false.
162+
*/
163+
/*******************************************************************************/
157164
inline bool vocEnabled() {
158165
return (getSensorVOCIndexPeriod() > 0) || (getSensorRawPeriod() > 0);
159166
}
160-
};
161167

162168
#endif // WipperSnapper_I2C_Driver_SGP40_H

0 commit comments

Comments
 (0)