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
f1b9d7a0
Commit
f1b9d7a0
authored
11 years ago
by
Micah Elizabeth Scott
Browse files
Options
Downloads
Patches
Plain Diff
CPU utilization tweaks; default frame rate, no draw when disconnected
parent
9fb077f3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/cpp/lib/effect.h
+17
-12
17 additions, 12 deletions
examples/cpp/lib/effect.h
examples/cpp/lib/opcclient.h
+10
-5
10 additions, 5 deletions
examples/cpp/lib/opcclient.h
examples/cpp/spokes.cpp
+0
-1
0 additions, 1 deletion
examples/cpp/spokes.cpp
with
27 additions
and
18 deletions
examples/cpp/lib/effect.h
+
17
−
12
View file @
f1b9d7a0
...
...
@@ -182,7 +182,8 @@ inline EffectRunner::EffectRunner()
lastTime
.
tv_sec
=
0
;
lastTime
.
tv_usec
=
0
;
// Default server
// Defaults
setMaxFrameRate
(
300
);
setServer
(
"localhost"
);
}
...
...
@@ -279,22 +280,26 @@ inline void EffectRunner::doFrame(float timeDelta)
frameInfo
.
advance
(
timeDelta
);
effect
->
beginFrame
(
frameInfo
);
uint8_t
*
dest
=
OPCClient
::
Header
::
view
(
frameBuffer
).
data
();
// Only calculate the effect if we have a connection
if
(
opc
.
tryConnect
())
{
uint8_t
*
dest
=
OPCClient
::
Header
::
view
(
frameBuffer
).
data
();
for
(
PixelInfoIter
i
=
frameInfo
.
pixels
.
begin
(),
e
=
frameInfo
.
pixels
.
end
();
i
!=
e
;
++
i
)
{
Vec3
rgb
(
0
,
0
,
0
);
const
PixelInfo
&
p
=
*
i
;
for
(
PixelInfoIter
i
=
frameInfo
.
pixels
.
begin
(),
e
=
frameInfo
.
pixels
.
end
();
i
!=
e
;
++
i
)
{
Vec3
rgb
(
0
,
0
,
0
);
const
PixelInfo
&
p
=
*
i
;
if
(
p
.
isMapped
())
{
effect
->
calculatePixel
(
rgb
,
p
);
}
if
(
p
.
isMapped
())
{
effect
->
calculatePixel
(
rgb
,
p
);
}
for
(
unsigned
i
=
0
;
i
<
3
;
i
++
)
{
*
(
dest
++
)
=
std
::
min
<
int
>
(
255
,
std
::
max
<
int
>
(
0
,
rgb
[
i
]
*
255
+
0.5
));
for
(
unsigned
i
=
0
;
i
<
3
;
i
++
)
{
*
(
dest
++
)
=
std
::
min
<
int
>
(
255
,
std
::
max
<
int
>
(
0
,
rgb
[
i
]
*
255
+
0.5
));
}
}
}
opc
.
write
(
frameBuffer
);
opc
.
write
(
frameBuffer
);
}
effect
->
endFrame
(
frameInfo
);
...
...
This diff is collapsed.
Click to expand it.
examples/cpp/lib/opcclient.h
+
10
−
5
View file @
f1b9d7a0
...
...
@@ -47,6 +47,8 @@ public:
bool
resolve
(
const
char
*
hostport
,
int
defaultPort
=
7890
);
bool
write
(
const
uint8_t
*
data
,
ssize_t
length
);
bool
write
(
const
std
::
vector
<
uint8_t
>
&
data
);
bool
tryConnect
();
bool
isConnected
();
struct
Header
{
...
...
@@ -139,12 +141,15 @@ inline bool OPCClient::isConnected()
return
fd
>
0
;
}
inline
bool
OPCClient
::
tryConnect
()
{
return
isConnected
()
||
connectSocket
();
}
inline
bool
OPCClient
::
write
(
const
uint8_t
*
data
,
ssize_t
length
)
{
if
(
!
isConnected
())
{
if
(
!
connectSocket
())
{
return
false
;
}
if
(
!
tryConnect
())
{
return
false
;
}
while
(
length
>
0
)
{
...
...
@@ -170,7 +175,7 @@ inline bool OPCClient::connectSocket()
fd
=
socket
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
connect
(
fd
,
(
struct
sockaddr
*
)
&
address
,
sizeof
address
)
<
0
)
{
close
(
fd
);
close
Socket
(
);
return
false
;
}
...
...
This diff is collapsed.
Click to expand it.
examples/cpp/spokes.cpp
+
0
−
1
View file @
f1b9d7a0
...
...
@@ -76,7 +76,6 @@ int main(int argc, char **argv)
EffectRunner
r
;
r
.
setEffect
(
&
br
);
r
.
setMaxFrameRate
(
200
);
r
.
setLayout
(
"../layouts/grid32x16z.json"
);
return
r
.
main
(
argc
,
argv
);
}
...
...
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