Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Käppler
ampel-firmware
Commits
962aa081
Commit
962aa081
authored
Apr 15, 2021
by
Eric Duminil
Browse files
Code Format
parent
62016309
Changes
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/led_effects.cpp
View file @
962aa081
...
@@ -4,11 +4,11 @@
...
@@ -4,11 +4,11 @@
*****************************************************************/
*****************************************************************/
namespace
config
{
namespace
config
{
const
uint8_t
max_brightness
=
MAX_BRIGHTNESS
;
const
uint8_t
max_brightness
=
MAX_BRIGHTNESS
;
#if defined(MIN_BRIGHTNESS)
#if defined(MIN_BRIGHTNESS)
const
uint8_t
min_brightness
=
MIN_BRIGHTNESS
;
const
uint8_t
min_brightness
=
MIN_BRIGHTNESS
;
#else
#else
const
uint8_t
min_brightness
=
MAX_BRIGHTNESS
;
const
uint8_t
min_brightness
=
MAX_BRIGHTNESS
;
#endif
#endif
const
uint8_t
brightness_amplitude
=
config
::
max_brightness
-
config
::
min_brightness
;
const
uint8_t
brightness_amplitude
=
config
::
max_brightness
-
config
::
min_brightness
;
const
int
kitt_tail
=
3
;
// How many dimmer LEDs follow in K.I.T.T. wheel
const
int
kitt_tail
=
3
;
// How many dimmer LEDs follow in K.I.T.T. wheel
const
uint16_t
poor_air_quality_ppm
=
1600
;
// Above this threshold, LED breathing effect is faster.
const
uint16_t
poor_air_quality_ppm
=
1600
;
// Above this threshold, LED breathing effect is faster.
...
@@ -135,14 +135,12 @@ namespace led_effects {
...
@@ -135,14 +135,12 @@ namespace led_effects {
*/
*/
void
breathe
(
int16_t
co2
)
{
void
breathe
(
int16_t
co2
)
{
static
uint8_t
breathing_offset
=
0
;
static
uint8_t
breathing_offset
=
0
;
uint16_t
brightness
=
config
::
min_brightness
uint16_t
brightness
=
config
::
min_brightness
+
pixels
.
sine8
(
breathing_offset
)
*
config
::
brightness_amplitude
/
255
;
+
pixels
.
sine8
(
breathing_offset
)
*
config
::
brightness_amplitude
/
255
;
pixels
.
setBrightness
(
brightness
);
pixels
.
setBrightness
(
brightness
);
pixels
.
show
();
pixels
.
show
();
breathing_offset
+=
co2
>
config
::
poor_air_quality_ppm
?
6
:
3
;
// breathing speed. +3 looks like slow human breathing.
breathing_offset
+=
co2
>
config
::
poor_air_quality_ppm
?
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.
*/
*/
...
@@ -156,7 +154,7 @@ namespace led_effects {
...
@@ -156,7 +154,7 @@ 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
){
if
(
config
::
brightness_amplitude
>
0
)
{
breathe
(
co2
);
breathe
(
co2
);
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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