Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
5c8619eb
Commit
5c8619eb
authored
Oct 22, 2017
by
Nathaniel Wesley Filardo
Committed by
Marcel Stör
Oct 22, 2017
Browse files
ws2812 mix: add all, then divide (#2032)
This achieves rounding between multiple summed frame buffers
parent
ded599f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/ws2812.c
View file @
5c8619eb
...
...
@@ -399,17 +399,19 @@ static int ws2812_buffer_mix(lua_State* L) {
size_t
i
;
for
(
i
=
0
;
i
<
cells
;
i
++
)
{
int
val
=
0
;
int
32_t
val
=
0
;
for
(
src
=
0
;
src
<
n_sources
;
src
++
)
{
val
+=
(
(
int
)(
source
[
src
].
values
[
i
]
*
source
[
src
].
factor
)
>>
8
)
;
val
+=
(
int
32_t
)(
source
[
src
].
values
[
i
]
*
source
[
src
].
factor
);
}
val
>>=
8
;
if
(
val
<
0
)
{
val
=
0
;
}
else
if
(
val
>
255
)
{
val
=
255
;
}
buffer
->
values
[
i
]
=
val
;
buffer
->
values
[
i
]
=
(
uint8_t
)
val
;
}
return
0
;
...
...
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