Commit f4b28201 authored by Eric Duminil's avatar Eric Duminil
Browse files

Merge branch 'develop'

parents 64da8b35 278a1ce7
Pipeline #4516 passed with stage
in 2 minutes and 39 seconds
......@@ -85,7 +85,7 @@ In Arduino IDE *Serial Monitor* or PlatformIO *Monitor*, type `help` + <kbd>Ente
* `lora 300` (Sets LoRaWAN sending interval, in s).
* `mqtt 60` (Sets MQTT sending interval, in s).
* `night_mode` (Toggles night mode on/off).
* `reset` (Restarts the sensor).
* `reset` (Restarts the ESP).
* `reset_scd` (Resets SCD30).
* `send_local_ip` (Sends local IP and SSID via MQTT. Can be useful to find sensor).
* `set_time 1618829570` (Sets time to the given UNIX time).
......
......@@ -189,8 +189,10 @@ void checkFlashButton() {
led_effects::toggleNightMode();
} else {
Serial.println(F("Flash has been pressed for a long time. Keep it pressed for calibration."));
if (led_effects::countdownToZero() < 0) {
if (led_effects::countdownToZero()) {
Serial.println(F("You can now release the button."));
sensor::startCalibrationProcess();
led_effects::showKITTWheel(color::red, 2);
}
}
led_effects::onBoardLEDOff();
......
......@@ -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();
}
}
......
......@@ -211,14 +211,17 @@ namespace led_effects {
}
/**
* Displays a complete blue circle, and starts removing LEDs one by one. Returns the number of remaining LEDs.
* Can be used for calibration, e.g. when countdown is 0. Does not work in night mode.
* Displays a complete blue circle, and starts removing LEDs one by one.
* Does nothing in night mode and returns false then. Returns true if
* the countdown has finished. Can be used for calibration, e.g. when countdown is 0.
* NOTE: This function is blocking and returns only after the button has
* been released or after every LED has been turned off.
*/
int countdownToZero() {
bool countdownToZero() {
if (config::night_mode) {
Serial.println(F("Night mode. Not doing anything."));
delay(1000); // Wait for a while, to avoid coming back to this function too many times when button is pressed.
return 1;
return false;
}
pixels.fill(color::blue);
pixels.show();
......@@ -229,6 +232,6 @@ namespace led_effects {
Serial.println(countdown);
delay(500);
}
return countdown;
return countdown < 0;
}
}
......@@ -26,7 +26,7 @@ namespace led_effects {
void setupRing();
void redAlert();
int countdownToZero();
bool countdownToZero();
void showWaitingLED(uint32_t color);
void showKITTWheel(uint32_t color, uint16_t duration_s = 2);
void showRainbowWheel(uint16_t duration_ms = 1000);
......
......@@ -85,7 +85,7 @@ Ampel::Ampel() :
sensor_console::defineCommand("free", Ampel::showFreeSpace, F("(Displays available heap space)"));
sensor_console::defineCommand("reset", []() {
ESP.restart();
}, F("(Restarts the sensor)"));
}, F("(Restarts the ESP)"));
}
Ampel ampel;
Supports Markdown
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