From 6c8ac37b48b8ac23a5f82b8893d129d204e68108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ppler?= Date: Tue, 30 Mar 2021 22:44:07 +0200 Subject: [PATCH 1/3] Breathing: Return immediately in night mode This is more in line with the other effects that are deactivated in night mode. Additionally, waiting at the end of the function does not make sense if it does nothing. --- ampel-firmware/led_effects.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ampel-firmware/led_effects.cpp b/ampel-firmware/led_effects.cpp index f654e77..6895406 100644 --- a/ampel-firmware/led_effects.cpp +++ b/ampel-firmware/led_effects.cpp @@ -180,14 +180,15 @@ 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; } + 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 > 1600 ? 50 : 100); // faster breathing for higher CO2 values } -- GitLab From 4cb1d3a19a6738b1ddfb6ca39ab8da90564da617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ppler?= Date: Tue, 30 Mar 2021 23:02:39 +0200 Subject: [PATCH 2/3] Allow to switch LED breathing off --- ampel-firmware/co2_sensor.cpp | 5 ++++- ampel-firmware/config.public.h | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ampel-firmware/co2_sensor.cpp b/ampel-firmware/co2_sensor.cpp index 7110776..70eff69 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 0033935..6c09f44 100644 --- a/ampel-firmware/config.public.h +++ b/ampel-firmware/config.public.h @@ -64,6 +64,9 @@ # define MAX_BRIGHTNESS 255 # define MIN_BRIGHTNESS 60 +// Should the LED display show a breathing effect during measurement? +# define LED_BREATHING true // [true / false] + /** * WEB SERVER * available at http://local_ip, with user HTTP_USER and password HTTP_PASSWORD -- GitLab From 91ba8f01338d899a191b563780646d2795a86412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ppler?= Date: Thu, 1 Apr 2021 22:00:47 +0200 Subject: [PATCH 3/3] Breathing acceleration: configurable threshold The LED breathing effect will double its speed, if a specific CO2 concentration is exceeded. --- ampel-firmware/config.public.h | 3 +++ ampel-firmware/led_effects.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ampel-firmware/config.public.h b/ampel-firmware/config.public.h index 6c09f44..f89cbae 100644 --- a/ampel-firmware/config.public.h +++ b/ampel-firmware/config.public.h @@ -66,6 +66,9 @@ // 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 diff --git a/ampel-firmware/led_effects.cpp b/ampel-firmware/led_effects.cpp index 6895406..3629be8 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 } @@ -189,7 +190,7 @@ namespace led_effects { pixels.setBrightness(brightness); pixels.show(); breathing_offset += 3; // breathing speed. +3 looks like slow human breathing. - delay(co2 > 1600 ? 50 : 100); // faster breathing for higher CO2 values + delay(co2 > config::led_breathing_accel_threshold ? 50 : 100); // faster breathing for higher CO2 values } /** -- GitLab