diff --git a/ampel-firmware/co2_sensor.cpp b/ampel-firmware/co2_sensor.cpp index 7110776f7ab9362e431917afa8ebc84cd8bcb653..70eff6987302aa03f7bd3105e8884cf27c70a3ea 100644 --- a/ampel-firmware/co2_sensor.cpp +++ b/ampel-firmware/co2_sensor.cpp @@ -13,6 +13,7 @@ namespace config { const float temperature_offset = -3.0; // [K] Temperature measured by sensor is usually at least 3K too high. #endif const bool auto_calibrate_sensor = AUTO_CALIBRATE_SENSOR; // [true / false] + const bool led_breathing = LED_BREATHING; } namespace sensor { @@ -137,7 +138,9 @@ namespace sensor { */ if (co2 < 2000) { led_effects::displayCO2color(co2); - led_effects::breathe(co2); + if (config::led_breathing) { + led_effects::breathe(co2); + } } else { // >= 2000: entire ring blinks red led_effects::redAlert(); diff --git a/ampel-firmware/config.public.h b/ampel-firmware/config.public.h index 00339350cf751165bbd1c1ac46f78ef859e46ed5..f89cbae72b916ed8f1ae4b7fa4dcd82039c981e2 100644 --- a/ampel-firmware/config.public.h +++ b/ampel-firmware/config.public.h @@ -64,6 +64,12 @@ # define MAX_BRIGHTNESS 255 # define MIN_BRIGHTNESS 60 +// Should the LED display show a breathing effect during measurement? +# define LED_BREATHING true // [true / false] +// Accelerate breathing above this CO2 concentration. +# define LED_BREATHING_ACCEL_THRESHOLD 1600 // [ppm] + + /** * WEB SERVER * available at http://local_ip, with user HTTP_USER and password HTTP_PASSWORD diff --git a/ampel-firmware/led_effects.cpp b/ampel-firmware/led_effects.cpp index f654e77e581ec88bfce7c3dd8be9b648740e9583..3629be8f4c982ca29e9fe66159f5441dd6a71159 100644 --- a/ampel-firmware/led_effects.cpp +++ b/ampel-firmware/led_effects.cpp @@ -5,6 +5,7 @@ namespace config { const uint8_t max_brightness = MAX_BRIGHTNESS; const uint8_t min_brightness = MIN_BRIGHTNESS; + const uint16_t led_breathing_accel_threshold = LED_BREATHING_ACCEL_THRESHOLD; const int kitt_tail = 3; // How many dimmer LEDs follow in K.I.T.T. wheel } @@ -180,15 +181,16 @@ namespace led_effects { } void breathe(int16_t co2) { - if (!config::night_mode) { - static uint16_t breathing_offset = 0; - uint16_t brightness = config::min_brightness - + pixels.sine8(breathing_offset) * config::brightness_amplitude / 255; - pixels.setBrightness(brightness); - pixels.show(); - breathing_offset += 3; // breathing speed. +3 looks like slow human breathing. + if (config::night_mode) { + return; } - delay(co2 > 1600 ? 50 : 100); // faster breathing for higher CO2 values + static uint16_t breathing_offset = 0; + uint16_t brightness = config::min_brightness + + pixels.sine8(breathing_offset) * config::brightness_amplitude / 255; + pixels.setBrightness(brightness); + pixels.show(); + breathing_offset += 3; // breathing speed. +3 looks like slow human breathing. + delay(co2 > config::led_breathing_accel_threshold ? 50 : 100); // faster breathing for higher CO2 values } /**