Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
efc613be
Commit
efc613be
authored
Dec 27, 2020
by
Eric Duminil
Browse files
Trying to use integer sine for LED breathing
parent
26bf5a15
Changes
1
Hide whitespace changes
Inline
Side-by-side
led_effects.cpp
View file @
efc613be
...
...
@@ -11,10 +11,9 @@ namespace config {
/*****************************************************************
* Configuration (calculated from above values) *
*****************************************************************/
namespace
config
//
TODO
: Use a class instead
.
NightMode could then be another state.
namespace
config
//
NOTE
: Use a class instead
?
NightMode could then be another state.
{
const
float
average_brightness
=
0.5
*
(
config
::
max_brightness
+
config
::
min_brightness
);
const
float
brightness_amplitude
=
0.5
*
(
config
::
max_brightness
-
config
::
min_brightness
);
const
uint8_t
brightness_amplitude
=
config
::
max_brightness
-
config
::
min_brightness
;
bool
night_mode
=
false
;
}
...
...
@@ -176,9 +175,9 @@ namespace LedEffects {
void
breathe
(
int16_t
co2
)
{
if
(
!
config
::
night_mode
)
{
static
uint16_t
breathing_offset
=
0
;
//TODO: use integer sine
pixels
.
s
etBrightness
(
static_cast
<
int
>
(
config
::
average_brightness
+
cos
(
breathing_offset
*
0.1
)
*
config
::
brightness_amplitude
)
);
uint16_t
brightness
=
config
::
min_brightness
+
pixels
.
s
ine8
(
breathing_offset
*
3
)
*
config
::
brightness_amplitude
/
255
;
pixels
.
setBrightness
(
brightness
);
pixels
.
show
();
breathing_offset
++
;
}
...
...
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