From b37b803457934079e7a456d2b69e305a0563ac0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ppler?= <michael_kaeppler@web.de> Date: Mon, 7 Jun 2021 11:46:38 +0200 Subject: [PATCH] co2_sensor: Make co2 alert threshold configurable Previously, it was hardcoded to 2000 ppm, which remains the default value. --- ampel-firmware/co2_sensor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ampel-firmware/co2_sensor.cpp b/ampel-firmware/co2_sensor.cpp index 1eb76fc..25a7102 100644 --- a/ampel-firmware/co2_sensor.cpp +++ b/ampel-firmware/co2_sensor.cpp @@ -10,6 +10,7 @@ namespace config { const int8_t max_deviation_during_calibration = 30; // [ppm] const int16_t timestep_during_calibration = 10; // [s] WARNING: Measurements can be unreliable for timesteps shorter than 10s. const int8_t stable_measurements_before_calibration = 120 / timestep_during_calibration; // [-] Stable measurements during at least 2 minutes. + const uint16_t co2_alert_threshold = 2000; // [ppm] Display a flashing led ring, if concentration exceeds this value #ifdef TEMPERATURE_OFFSET // Residual heat from CO2 sensor seems to be high enough to change the temperature reading. How much should it be offset? @@ -227,11 +228,11 @@ namespace sensor { * A short delay is required in order to let background tasks run on the ESP8266. * see https://github.com/esp8266/Arduino/issues/3241#issuecomment-301290392 */ - if (co2 < 2000) { + if (co2 < config::co2_alert_threshold) { led_effects::displayCO2color(co2); delay(100); } else { - // >= 2000: entire ring blinks red + // Display a flashing led ring, if concentration exceeds a specific value led_effects::redAlert(); } } -- GitLab