@@ -49,27 +49,31 @@ class WipperSnapper_I2C_Driver_SGP30 : public WipperSnapper_I2C_Driver {
4949 bool begin () {
5050 _sgp30 = new Adafruit_SGP30 ();
5151 if (!_sgp30->begin (_i2c)) {
52- delete _sgp30; // avoid leak on init failure
52+ delete _sgp30; // avoid leak on init failure
5353 _sgp30 = nullptr ;
5454 return false ;
5555 }
56- _sgp30->IAQinit (); // start IAQ algorithm
56+ _sgp30->IAQinit (); // start IAQ algorithm
5757 _lastFastMs = millis (); // reset fast sampler
5858 _n = _eco2Sum = _tvocSum = 0 ; // clear accumulators
5959 return true ;
6060 }
6161
6262 bool getEventECO2 (sensors_event_t *senseEvent) override {
63- if (!_sgp30) return false ;
63+ if (!_sgp30)
64+ return false ;
6465 bool ok = _sgp30->IAQmeasure ();
65- if (ok) senseEvent->eCO2 = _sgp30->eCO2 ;
66+ if (ok)
67+ senseEvent->eCO2 = _sgp30->eCO2 ;
6668 return ok;
6769 }
6870
6971 bool getEventTVOC (sensors_event_t *senseEvent) override {
70- if (!_sgp30) return false ;
72+ if (!_sgp30)
73+ return false ;
7174 bool ok = _sgp30->IAQmeasure ();
72- if (ok) senseEvent->tvoc = _sgp30->TVOC ;
75+ if (ok)
76+ senseEvent->tvoc = _sgp30->TVOC ;
7377 return ok;
7478 }
7579
@@ -79,16 +83,15 @@ class WipperSnapper_I2C_Driver_SGP30 : public WipperSnapper_I2C_Driver {
7983 uint32_t now = millis ();
8084 if (now - _lastFastMs >= 1000 ) { // ~1 Hz cadence
8185 if (_sgp30 && _sgp30->IAQmeasure ()) {
82- _eco2Sum += _sgp30->eCO2 ; // uint16_t in library
83- _tvocSum += _sgp30->TVOC ; // uint16_t in library
86+ _eco2Sum += _sgp30->eCO2 ; // uint16_t in library
87+ _tvocSum += _sgp30->TVOC ; // uint16_t in library
8488 _n++;
8589 }
8690 _lastFastMs = now;
8791 }
8892 }
8993
9094protected:
91-
9295 Adafruit_SGP30 *_sgp30; // /< Pointer to SGP30 sensor object
9396
9497 // Fast sampling state
0 commit comments