Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mensactrl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
stratum0
mensactrl
Commits
bb5f92cc
Commit
bb5f92cc
authored
10 years ago
by
Drahflow
Browse files
Options
Downloads
Patches
Plain Diff
Multipart server
parent
2e83ffbe
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/common.h
+9
-0
9 additions, 0 deletions
src/common.h
src/mensactrl.c
+50
-25
50 additions, 25 deletions
src/mensactrl.c
with
59 additions
and
25 deletions
src/common.h
+
9
−
0
View file @
bb5f92cc
#define CMD_PIXEL 0
struct
pixel
{
int
x
,
y
;
uint8_t
bright
;
};
struct
packet
{
uint8_t
cmd
;
union
{
struct
pixel
pixel
;
};
};
This diff is collapsed.
Click to expand it.
src/mensactrl.c
+
50
−
25
View file @
bb5f92cc
...
...
@@ -58,35 +58,35 @@ static void blit_area(struct mensa_fb *mensafb, const int col, const int row,
return
;
for
(
r
=
row
;
r
<
row
+
height
;
r
++
)
{
for
(
c
=
col
;
c
<
col
+
width
;
c
++
)
{
/* Calculate module and position inside the module */
vmpos
=
r
/
(
LINES_PER_MODULE
*
ROWS_PER_LINE
);
vpos
=
r
%
(
LINES_PER_MODULE
*
ROWS_PER_LINE
);
hmpos
=
c
/
(
COLS_PER_MODULE
);
hpos
=
c
%
(
COLS_PER_MODULE
);
for
(
c
=
col
;
c
<
col
+
width
;
c
++
)
{
/* Calculate module and position inside the module */
vmpos
=
r
/
(
LINES_PER_MODULE
*
ROWS_PER_LINE
);
vpos
=
r
%
(
LINES_PER_MODULE
*
ROWS_PER_LINE
);
hmpos
=
c
/
(
COLS_PER_MODULE
);
hpos
=
c
%
(
COLS_PER_MODULE
);
pos
=
hpos
+
hmpos
*
COLS_PER_MODULE
*
LINES_PER_MODULE
;
pos
=
hpos
+
hmpos
*
COLS_PER_MODULE
*
LINES_PER_MODULE
;
if
(
vpos
>=
ROWS_PER_LINE
)
{
vpos
-=
ROWS_PER_LINE
;
pos
+=
COLS_PER_MODULE
;
}
if
(
vpos
>=
ROWS_PER_LINE
)
{
vpos
-=
ROWS_PER_LINE
;
pos
+=
COLS_PER_MODULE
;
}
/* Invert order */
pos
=
(
LINES_PER_MODULE
*
COLS_PER_MODULE
*
mensafb
->
hmodules
-
1
)
-
pos
;
pos
=
(
LINES_PER_MODULE
*
COLS_PER_MODULE
*
mensafb
->
hmodules
-
1
)
-
pos
;
/* Add in row offset */
pos
=
pos
+
vpos
*
(
mensafb
->
hmodules
*
COLS_PER_MODULE
*
LINES_PER_MODULE
);
pos
=
pos
+
vpos
*
(
mensafb
->
hmodules
*
COLS_PER_MODULE
*
LINES_PER_MODULE
);
if
(
mensafb
->
inputfb
[
c
+
r
*
mensafb
->
x_res
]
==
0
)
{
/* clear bit */
mensafb
->
fbmem
[
pos
]
&=
~
(
1
<<
(
mensafb
->
vmodules
-
1
-
vmpos
));
}
else
{
/* set bit */
mensafb
->
fbmem
[
pos
]
|=
(
1
<<
(
mensafb
->
vmodules
-
1
-
vmpos
));
}
}
/* clear bit */
mensafb
->
fbmem
[
pos
]
&=
~
(
1
<<
(
mensafb
->
vmodules
-
1
-
vmpos
));
}
else
{
/* set bit */
mensafb
->
fbmem
[
pos
]
|=
(
1
<<
(
mensafb
->
vmodules
-
1
-
vmpos
));
}
}
}
}
...
...
@@ -95,6 +95,7 @@ void encodeToFb(struct mensa_fb *mensafb)
{
blit_area
(
mensafb
,
0
,
0
,
mensafb
->
x_res
,
mensafb
->
y_res
);
}
// int pix, row, cols, idx, fbidx, i, ledrow;
// uint16_t pattern;
//
...
...
@@ -178,6 +179,17 @@ static struct mensa_fb *setup_fb(const char *devname, int hmodules, int vmodules
return
mensafb
;
}
void
handlePixel
(
struct
mensa_fb
*
mensafb
,
struct
pixel
*
pix
)
{
setPixel
(
mensafb
,
pix
->
x
,
pix
->
y
,
pix
->
bright
);
blit_area
(
mensafb
,
pix
->
x
,
pix
->
y
,
1
,
1
);
}
void
handleCommand
(
struct
mensa_fb
*
mensafb
,
struct
packet
*
p
)
{
switch
(
p
->
cmd
)
{
case
CMD_PIXEL
:
handlePixel
(
mensafb
,
&
p
->
pixel
);
break
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
struct
mensa_fb
*
mensafb
;
void
*
context
=
zmq_ctx_new
();
...
...
@@ -194,11 +206,24 @@ int main(int argc, char *argv[]) {
mensafb
=
setup_fb
(
argv
[
1
],
12
,
5
);
while
(
1
)
{
struct
pixel
pix
;
zmq_recv
(
responder
,
&
pix
,
sizeof
(
pix
),
0
);
setPixel
(
mensafb
,
pix
.
x
,
pix
.
y
,
pix
.
bright
);
zmq_send
(
responder
,
&
pix
,
sizeof
(
pix
),
0
);
encodeToFb
(
mensafb
);
int64_t
more
;
size_t
more_size
=
sizeof
(
more
);
do
{
zmq_msg_t
message
;
zmq_msg_init
(
&
message
);
zmq_msg_recv
(
&
message
,
responder
,
0
);
if
(
zmq_msg_size
(
&
message
))
{
handleCommand
(
mensafb
,
(
struct
packet
*
)
zmq_msg_data
(
&
message
));
}
zmq_getsockopt
(
responder
,
ZMQ_RCVMORE
,
&
more
,
&
more_size
);
zmq_msg_close
(
&
message
);
}
while
(
more
);
zmq_send
(
responder
,
NULL
,
0
,
0
);
}
return
0
;
...
...
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