I2C reclock guard - avoid gazillion calls to reclock on SENXX sensors (#11412)

* Add SEN6X

* Adds new SENXX class for SEN5X and SEN6X
* Adds CO2 sensor calibration class to be shared among othre CO2 sensors

* Make existing CO2 sensor draw from CO2Sensor class

* Minor coment for CO2 sensor class

* Move away from getRTC in SENXX class to keep track of time changes.

* Change all sensors to millis for tracking time, instead of using getRTC

* Add comments regarding VOC state

* Avoid storing non-valid RTC

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Avoid CO2 sensor warm-up time to be below PM measured started

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fix limits in CO2 sensor calibration

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Add pragma once on headers

* Avoid non-working ASC commands

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fix data poll

* Move pm measure started before warmup check

* Make cleaning non-blocking

* Restore previous state if cleaning fails. Fix data ready condition.

* Fix CO2 sensor checks for calibration

* Add ReClockI2C guard to simplify calls to Reclock. Make SENXX calls to reclock outside of readBuffer, to avoid bizillion calls

* Add new reClockGuard to all sensor classes that require it

* Make clock guard store values on each construction and restore them directly

* Reduce log messages

* Update ADS1X15 to new guard

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
oscgonfer
2026-08-16 11:58:59 +00:00
committed by GitHub
co-authored by coderabbitai[bot]
parent bca7c0b480
commit c773049b1d
10 changed files with 126 additions and 232 deletions
@@ -255,6 +255,11 @@ class SENXXSensor : public TelemetrySensor, public CO2CalibrationSensor
bool readPNValues(bool cumulative);
bool readValues();
// Actual wakeUp() logic, factored out so handleAdminMessage() can resume
// measurement after a calibration pause without nesting a second I2C-clock
// guard inside its own (see ReClockI2CGuard's reentrancy note).
uint32_t wakeUpInternal();
// Monotonic (millis()) timers for warmup/poll intervals. Deliberately not
// wall-clock (getTime()) based: getTime() can jump discontinuously the moment the RTC
// quality improves mid-session (see checkRTCQualityImproved()), which would corrupt