Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Astro
rust-card10
Commits
3eee1dd5
Commit
3eee1dd5
authored
Sep 24, 2019
by
Astro
⚙
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'leds' into 'master'
leds: add support for the rocket LEDs See merge request
!21
parents
673ef495
e51772d7
Pipeline
#4013
failed with stage
in 13 minutes and 58 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
card10-l0dable/src/leds.rs
card10-l0dable/src/leds.rs
+23
-0
example/src/main.rs
example/src/main.rs
+4
-0
No files found.
card10-l0dable/src/leds.rs
View file @
3eee1dd5
...
...
@@ -30,3 +30,26 @@ where
}
}
}
/// Set powersave mode for the RGB leds
///
/// Setting powersave mode disables the LEDs, saving
/// ~15 mA
pub
fn
set_rgb_leds_powersave
(
v
:
bool
)
{
unsafe
{
epic_leds_set_powersave
(
v
);
}
}
#[repr(i32)]
pub
enum
Rocket
{
Blue
=
0
,
Yellow
=
1
,
Green
=
2
,
}
/// Set one of the rocket LEDs to the desired brightness.
///
/// Brightness should be 0 - 31; larger values will be clamped.
pub
fn
set_rocket
(
r
:
Rocket
,
brightness
:
u8
)
{
let
v
=
if
brightness
>
31
{
31
}
else
{
brightness
};
// clamp
unsafe
{
epic_leds_set_rocket
(
r
as
i32
,
v
)
}
}
example/src/main.rs
View file @
3eee1dd5
...
...
@@ -25,6 +25,10 @@ fn run() -> Result<(), Error> {
let
g
=
BHI160
::
<
Gyroscope
>
::
start
()
?
;
let
o
=
BHI160
::
<
Orientation
>
::
start
()
?
;
set_rocket
(
Rocket
::
Blue
,
20
);
set_rocket
(
Rocket
::
Yellow
,
20
);
set_rocket
(
Rocket
::
Green
,
10
);
let
display
=
Display
::
open
();
let
light
=
LightSensor
::
start
();
...
...
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