Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
14c90bc9
Commit
14c90bc9
authored
Apr 15, 2021
by
Eric Duminil
Browse files
LED Effects : small breathe refactor.
parent
42d90309
Changes
3
Show whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
14c90bc9
...
@@ -138,7 +138,6 @@ namespace sensor {
...
@@ -138,7 +138,6 @@ namespace sensor {
*/
*/
if
(
co2
<
2000
)
{
if
(
co2
<
2000
)
{
led_effects
::
displayCO2color
(
co2
);
led_effects
::
displayCO2color
(
co2
);
led_effects
::
breathe
(
co2
);
delay
(
100
);
delay
(
100
);
}
else
{
}
else
{
// >= 2000: entire ring blinks red
// >= 2000: entire ring blinks red
...
...
ampel-firmware/led_effects.cpp
View file @
14c90bc9
...
@@ -129,6 +129,19 @@ namespace led_effects {
...
@@ -129,6 +129,19 @@ namespace led_effects {
}
}
}
}
/**
* If enabled, slowly varies the brightness between MAX_BRIGHTNESS & MIN_BRIGHTNESS.
*/
void
breathe
(
int16_t
co2
)
{
static
uint8_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
+=
co2
>
1600
?
6
:
3
;
// breathing speed. +3 looks like slow human breathing.
}
/**
/**
* Fills the whole ring with green, yellow, orange or black, depending on co2 input and CO2_TICKS.
* Fills the whole ring with green, yellow, orange or black, depending on co2 input and CO2_TICKS.
*/
*/
...
@@ -142,6 +155,9 @@ namespace led_effects {
...
@@ -142,6 +155,9 @@ namespace led_effects {
pixels
.
setPixelColor
(
ledId
,
pixels
.
ColorHSV
(
LED_HUES
[
ledId
],
255
,
brightness
));
pixels
.
setPixelColor
(
ledId
,
pixels
.
ColorHSV
(
LED_HUES
[
ledId
],
255
,
brightness
));
}
}
pixels
.
show
();
pixels
.
show
();
if
(
config
::
brightness_amplitude
>
0
){
breathe
(
co2
);
}
}
}
void
showRainbowWheel
(
uint16_t
duration_ms
,
uint16_t
hue_increment
)
{
void
showRainbowWheel
(
uint16_t
duration_ms
,
uint16_t
hue_increment
)
{
...
@@ -177,18 +193,6 @@ namespace led_effects {
...
@@ -177,18 +193,6 @@ namespace led_effects {
}
}
}
}
void
breathe
(
int16_t
co2
)
{
if
(
config
::
night_mode
||
config
::
brightness_amplitude
==
0
)
{
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
+=
co2
>
1600
?
6
:
3
;
// breathing speed. +3 looks like slow human breathing.
}
/**
/**
* Displays a complete blue circle, and starts removing LEDs one by one. Returns the number of remaining LEDs.
* 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.
* Can be used for calibration, e.g. when countdown is 0. Does not work in night mode.
...
...
ampel-firmware/led_effects.h
View file @
14c90bc9
...
@@ -25,7 +25,6 @@ namespace led_effects {
...
@@ -25,7 +25,6 @@ namespace led_effects {
void
setupRing
();
void
setupRing
();
void
redAlert
();
void
redAlert
();
void
breathe
(
int16_t
co2
);
int
countdownToZero
();
int
countdownToZero
();
void
showWaitingLED
(
uint32_t
color
);
void
showWaitingLED
(
uint32_t
color
);
void
showKITTWheel
(
uint32_t
color
,
uint16_t
duration_s
=
2
);
void
showKITTWheel
(
uint32_t
color
,
uint16_t
duration_s
=
2
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment