Commit 1440e361 authored by Käppler's avatar Käppler
Browse files

co2_sensor: Start calibration process by state

This removes the superfluous bool `should_calibrate`.
parent 295800aa
...@@ -48,8 +48,6 @@ namespace sensor { ...@@ -48,8 +48,6 @@ namespace sensor {
state current_state = INITIAL; state current_state = INITIAL;
void switchState(state); void switchState(state);
bool should_calibrate = false;
void initialize() { void initialize() {
#if defined(ESP8266) #if defined(ESP8266)
Wire.begin(12, 14); // ESP8266 - D6, D5; Wire.begin(12, 14); // ESP8266 - D6, D5;
...@@ -140,7 +138,6 @@ namespace sensor { ...@@ -140,7 +138,6 @@ namespace sensor {
scd30.setMeasurementInterval(2); // [s] The change will only take effect after next measurement. scd30.setMeasurementInterval(2); // [s] The change will only take effect after next measurement.
Serial.println(F("Waiting until the measurements are stable for at least 2 minutes.")); Serial.println(F("Waiting until the measurements are stable for at least 2 minutes."));
Serial.println(F("It could take a very long time.")); Serial.println(F("It could take a very long time."));
should_calibrate = true;
switchState(PREPARECALIBRATION); switchState(PREPARECALIBRATION);
} }
...@@ -223,7 +220,7 @@ namespace sensor { ...@@ -223,7 +220,7 @@ namespace sensor {
} else if (co2 < 250) { } else if (co2 < 250) {
// Sensor should be calibrated. // Sensor should be calibrated.
switchState(NEEDSCALIBRATION); switchState(NEEDSCALIBRATION);
} else if (should_calibrate) { } else if (current_state == PREPARECALIBRATION) {
countStableMeasurements(); countStableMeasurements();
if (stable_measurements == config::enough_stable_measurements) { if (stable_measurements == config::enough_stable_measurements) {
calibrateAndRestart(); calibrateAndRestart();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment