Merge pull request #281 from airgradienthq/fix/zero-display

Fix display 0 measurements value on boot
This commit is contained in:
Samuel Siburian
2025-02-03 18:47:13 +07:00
committed by GitHub
2 changed files with 44 additions and 6 deletions

View File

@ -268,15 +268,16 @@ void setup() {
oledDisplay.setBrightness(configuration.getDisplayBrightness()); oledDisplay.setBrightness(configuration.getDisplayBrightness());
} }
// Update display and led bar after finishing setup to show dashboard // Reset post schedulers to make sure measurements value already available
updateDisplayAndLedBar(); agApiPostSchedule.update();
} }
void loop() { void loop() {
/** Handle schedule */ /** Run schedulers */
dispLedSchedule.run(); dispLedSchedule.run();
configSchedule.run(); configSchedule.run();
agApiPostSchedule.run(); agApiPostSchedule.run();
watchdogFeedSchedule.run();
if (configuration.hasSensorS8) { if (configuration.hasSensorS8) {
co2Schedule.run(); co2Schedule.run();
@ -310,15 +311,13 @@ void loop() {
} }
} }
watchdogFeedSchedule.run();
/** Check for handle WiFi reconnect */ /** Check for handle WiFi reconnect */
wifiConnector.handle(); wifiConnector.handle();
/** factory reset handle */ /** factory reset handle */
factoryConfigReset(); factoryConfigReset();
/** check that local configura changed then do some action */ /** check that local configuration changed then do some action */
configUpdateHandle(); configUpdateHandle();
/** Firmware check for update handle */ /** Firmware check for update handle */

View File

@ -31,6 +31,45 @@ Measurements::Measurements() {
#ifndef ESP8266 #ifndef ESP8266
_resetReason = (int)ESP_RST_UNKNOWN; _resetReason = (int)ESP_RST_UNKNOWN;
#endif #endif
/* Set invalid value for each measurements as default value when initialized*/
_temperature[0].update.avg = utils::getInvalidTemperature();
_temperature[1].update.avg = utils::getInvalidTemperature();
_humidity[0].update.avg = utils::getInvalidHumidity();
_humidity[1].update.avg = utils::getInvalidHumidity();
_co2.update.avg = utils::getInvalidCO2();
_tvoc.update.avg = utils::getInvalidVOC();
_tvoc_raw.update.avg = utils::getInvalidVOC();
_nox.update.avg = utils::getInvalidNOx();
_nox_raw.update.avg = utils::getInvalidNOx();
_pm_03_pc[0].update.avg = utils::getInvalidPmValue();
_pm_03_pc[1].update.avg = utils::getInvalidPmValue();
_pm_05_pc[0].update.avg = utils::getInvalidPmValue();
_pm_05_pc[1].update.avg = utils::getInvalidPmValue();
_pm_5_pc[0].update.avg = utils::getInvalidPmValue();
_pm_5_pc[1].update.avg = utils::getInvalidPmValue();
_pm_01[0].update.avg = utils::getInvalidPmValue();
_pm_01_sp[0].update.avg = utils::getInvalidPmValue();
_pm_01_pc[0].update.avg = utils::getInvalidPmValue();
_pm_01[1].update.avg = utils::getInvalidPmValue();
_pm_01_sp[1].update.avg = utils::getInvalidPmValue();
_pm_01_pc[1].update.avg = utils::getInvalidPmValue();
_pm_25[0].update.avg = utils::getInvalidPmValue();
_pm_25_sp[0].update.avg = utils::getInvalidPmValue();
_pm_25_pc[0].update.avg = utils::getInvalidPmValue();
_pm_25[1].update.avg = utils::getInvalidPmValue();
_pm_25_sp[1].update.avg = utils::getInvalidPmValue();
_pm_25_pc[1].update.avg = utils::getInvalidPmValue();
_pm_10[0].update.avg = utils::getInvalidPmValue();
_pm_10_sp[0].update.avg = utils::getInvalidPmValue();
_pm_10_pc[0].update.avg = utils::getInvalidPmValue();
_pm_10[1].update.avg = utils::getInvalidPmValue();
_pm_10_sp[1].update.avg = utils::getInvalidPmValue();
_pm_10_pc[1].update.avg = utils::getInvalidPmValue();
} }
void Measurements::maxPeriod(MeasurementType type, int max) { void Measurements::maxPeriod(MeasurementType type, int max) {