Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andre Julius
slc
Commits
6f237169
Commit
6f237169
authored
Oct 26, 2017
by
Andre Julius
👀
Browse files
Add fill_rgb() function.
parent
9eea8248
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main.rs
View file @
6f237169
use
std
::
net
::
UdpSocket
;
fn
fill_rgb
(
sock
:
&
UdpSocket
,
address
:
&
String
,
len
:
usize
,
r
:
u8
,
g
:
u8
,
b
:
u8
)
->
usize
{
let
mut
bytes
=
vec!
[
0
as
u8
;
len
*
3
];
for
i
in
0
..
len
{
bytes
[(
i
*
3
)
+
0
]
=
g
;
bytes
[(
i
*
3
)
+
1
]
=
r
;
bytes
[(
i
*
3
)
+
2
]
=
b
;
}
sock
.send_to
(
&
bytes
,
&
address
)
.expect
(
"error sending data"
)
}
fn
main
()
{
println!
(
"Hello, world!"
);
let
socket
=
UdpSocket
::
bind
(
"0.0.0.0:10400"
)
.expect
(
"Could not connect"
);
let
bytes_sent
=
fill_rgb
(
&
socket
,
&
"nomled:1234"
.to_string
(),
20
,
200
,
100
,
20
);
println!
(
"Total bytes sent: {:?}"
,
bytes_sent
);
}
Write
Preview
Supports
Markdown
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