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
32fefdbe
Commit
32fefdbe
authored
Dec 21, 2020
by
Eric Duminil
Browse files
Removing counter namespace
parent
9b11a49b
Changes
1
Show whitespace changes
Inline
Side-by-side
led_effects.cpp
View file @
32fefdbe
...
...
@@ -34,12 +34,6 @@ const uint16_t CO2_TICKS[NUMPIXELS + 1] = { 0, 500, 600, 700, 800, 900, 1000, 12
const
uint16_t
LED_HUES
[
NUMPIXELS
]
=
{
21845
,
19114
,
16383
,
13653
,
10922
,
8191
,
5461
,
2730
,
0
,
0
,
0
,
0
};
// [hue angle]
Adafruit_NeoPixel
pixels
(
NUMPIXELS
,
NEOPIXELS_PIN
,
NEO_GRB
+
NEO_KHZ800
);
namespace
counter
{
uint16_t
wheel_offset
=
0
;
uint16_t
kitt_offset
=
0
;
uint16_t
breathing_offset
=
0
;
}
namespace
LedEffects
{
//On-board LED on D4, aka GPIO02
const
int
ONBOARD_LED_PIN
=
2
;
...
...
@@ -84,13 +78,14 @@ namespace LedEffects {
if
(
config
::
night_mode
)
{
return
;
}
static
uint16_t
kitt_offset
=
0
;
pixels
.
clear
();
for
(
int
j
=
config
::
kitt_tail
;
j
>=
0
;
j
--
)
{
int
ledNumber
=
abs
((
counter
::
kitt_offset
-
j
+
NUMPIXELS
)
%
(
2
*
NUMPIXELS
)
-
NUMPIXELS
)
%
NUMPIXELS
;
// Triangular function
int
ledNumber
=
abs
((
kitt_offset
-
j
+
NUMPIXELS
)
%
(
2
*
NUMPIXELS
)
-
NUMPIXELS
)
%
NUMPIXELS
;
// Triangular function
pixels
.
setPixelColor
(
ledNumber
,
color
*
pixels
.
gamma8
(
255
-
j
*
76
)
/
255
);
}
pixels
.
show
();
counter
::
kitt_offset
+=
1
;
kitt_offset
++
;
}
// Start K.I.T.T. led effect. Red color as default.
...
...
@@ -140,12 +135,13 @@ namespace LedEffects {
if
(
config
::
night_mode
)
{
return
;
}
static
uint16_t
wheel_offset
=
0
;
unsigned
long
t0
=
seconds
();
pixels
.
setBrightness
(
config
::
max_brightness
);
while
(
seconds
()
<
t0
+
duration_s
)
{
for
(
int
i
=
0
;
i
<
NUMPIXELS
;
i
++
)
{
pixels
.
setPixelColor
(
i
,
pixels
.
ColorHSV
(
i
*
65535
/
NUMPIXELS
+
counter
::
wheel_offset
));
counter
::
wheel_offset
+=
hue_increment
;
pixels
.
setPixelColor
(
i
,
pixels
.
ColorHSV
(
i
*
65535
/
NUMPIXELS
+
wheel_offset
));
wheel_offset
+=
hue_increment
;
}
pixels
.
show
();
delay
(
10
);
...
...
@@ -170,12 +166,12 @@ namespace LedEffects {
void
breathe
(
int16_t
co2
)
{
if
(
!
config
::
night_mode
)
{
static
uint16_t
breathing_offset
=
0
;
//TODO: use integer sine
pixels
.
setBrightness
(
static_cast
<
int
>
(
config
::
average_brightness
+
cos
(
counter
::
breathing_offset
*
0.1
)
*
config
::
brightness_amplitude
));
static_cast
<
int
>
(
config
::
average_brightness
+
cos
(
breathing_offset
*
0.1
)
*
config
::
brightness_amplitude
));
pixels
.
show
();
counter
::
breathing_offset
+=
1
;
breathing_offset
++
;
}
delay
(
co2
>
1600
?
50
:
100
);
// faster breathing for higher CO2 values
}
...
...
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