Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Fadecandy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scanlime
Fadecandy
Commits
ee559e5d
Commit
ee559e5d
authored
11 years ago
by
Micah Elizabeth Scott
Browse files
Options
Downloads
Patches
Plain Diff
Faster and smoother test harness
parent
fe006cfe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/hcolor.h
+3
-3
3 additions, 3 deletions
src/hcolor.h
src/main.cpp
+10
-4
10 additions, 4 deletions
src/main.cpp
with
13 additions
and
7 deletions
src/hcolor.h
+
3
−
3
View file @
ee559e5d
...
...
@@ -94,9 +94,9 @@ struct HPixel {
uint32_t
dither
()
{
// Incorporate the residual from last frame
int
r16
=
color
.
r
+
(
residual
[
0
]
>>
1
)
;
int
g16
=
color
.
g
+
(
residual
[
1
]
>>
1
)
;
int
b16
=
color
.
b
+
(
residual
[
2
]
>>
1
)
;
int
r16
=
color
.
r
+
residual
[
0
];
int
g16
=
color
.
g
+
residual
[
1
];
int
b16
=
color
.
b
+
residual
[
2
];
// Round to the nearest 8-bit value
int
r8
=
std
::
min
<
int
>
(
0xff
,
std
::
max
<
int
>
(
0
,
(
r16
+
0x80
)
>>
8
));
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
+
10
−
4
View file @
ee559e5d
...
...
@@ -17,6 +17,8 @@ int drawingMemory[ledsPerStrip * 6];
OctoWS2811
leds
(
ledsPerStrip
,
displayMemory
,
drawingMemory
,
WS2811_GRB
|
WS2811_800kHz
);
HPixelBuffer
<
ledsTotal
>
pixbuf
;
uint16_t
sinelut
[
1024
];
void
setup
()
{
leds
.
begin
();
...
...
@@ -25,6 +27,11 @@ void setup()
for
(
unsigned
i
=
0
;
i
<
ledsTotal
;
++
i
)
{
pixbuf
.
pixels
[
i
].
color
=
HColor16
(
0
,
0
,
0
);
}
// Quick and dirty...
for
(
unsigned
i
=
0
;
i
<
1024
;
++
i
)
{
sinelut
[
i
]
=
pow
(
sin
(
i
*
(
M_PI
*
2
/
1024
))
*
0.5
+
0.5
,
2.2
)
*
0x1000
;
}
}
void
loop
()
...
...
@@ -32,11 +39,10 @@ void loop()
// XXX: Proof of concept
for
(
int
i
=
0
;
i
<
16
;
i
++
)
{
unsigned
c
=
pow
(
sin
(
i
*
0.2
+
millis
()
*
0.0005
)
*
0.5
+
0.5
,
2.2
)
*
0x1000
;
int
t
=
(
millis
()
>>
2
)
+
(
i
<<
4
);
unsigned
c
=
sinelut
[
t
&
1023
];
pixbuf
.
pixels
[
i
].
color
=
HColor16
(
c
>>
2
,
c
,
c
>>
1
);
}
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
pixbuf
.
show
(
leds
);
}
pixbuf
.
show
(
leds
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment