Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rust-card10
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
R. Nestler
rust-card10
Commits
16d5d0b1
Commit
16d5d0b1
authored
5 years ago
by
Astro
Browse files
Options
Downloads
Patches
Plain Diff
light_sensor
parent
6a50161e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
example/src/main.rs
+2
-0
2 additions, 0 deletions
example/src/main.rs
l0dable/src/lib.rs
+2
-1
2 additions, 1 deletion
l0dable/src/lib.rs
l0dable/src/light_sensor.rs
+27
-0
27 additions, 0 deletions
l0dable/src/light_sensor.rs
with
31 additions
and
1 deletion
example/src/main.rs
+
2
−
0
View file @
16d5d0b1
...
@@ -9,6 +9,7 @@ fn main() {
...
@@ -9,6 +9,7 @@ fn main() {
writeln!
(
UART
,
"Hello from Rust
\r
"
)
.unwrap
();
writeln!
(
UART
,
"Hello from Rust
\r
"
)
.unwrap
();
let
display
=
Display
::
open
();
let
display
=
Display
::
open
();
let
light
=
LightSensor
::
start
();
for
t
in
0
..
Display
::
W
{
for
t
in
0
..
Display
::
W
{
display
.clear
(
Color
::
yellow
());
display
.clear
(
Color
::
yellow
());
display
.print
(
160
-
t
,
10
,
b"Hello Rust
\0
"
,
Color
::
white
(),
Color
::
black
());
display
.print
(
160
-
t
,
10
,
b"Hello Rust
\0
"
,
Color
::
white
(),
Color
::
black
());
...
@@ -29,6 +30,7 @@ fn main() {
...
@@ -29,6 +30,7 @@ fn main() {
if
b
.right_top
()
{
if
b
.right_top
()
{
display
.print
(
80
,
30
,
b"Reset
\0
"
,
Color
::
red
(),
Color
::
black
());
display
.print
(
80
,
30
,
b"Reset
\0
"
,
Color
::
red
(),
Color
::
black
());
}
}
writeln!
(
UART
,
"Light: {:?}
\r
"
,
light
.get
());
display
.update
();
display
.update
();
}
}
...
...
This diff is collapsed.
Click to expand it.
l0dable/src/lib.rs
+
2
−
1
View file @
16d5d0b1
...
@@ -67,9 +67,10 @@ mod display;
...
@@ -67,9 +67,10 @@ mod display;
pub
use
display
::{
Display
,
Color
,
LineStyle
};
pub
use
display
::{
Display
,
Color
,
LineStyle
};
mod
buttons
;
mod
buttons
;
pub
use
buttons
::
Buttons
;
pub
use
buttons
::
Buttons
;
pub
mod
uart
;
pub
mod
uart
;
pub
const
UART
:
uart
::
Uart
=
uart
::
Uart
;
pub
const
UART
:
uart
::
Uart
=
uart
::
Uart
;
mod
light_sensor
;
pub
use
light_sensor
::
LightSensor
;
pub
fn
exit
(
ret
:
i32
)
->
!
{
pub
fn
exit
(
ret
:
i32
)
->
!
{
unsafe
{
unsafe
{
...
...
This diff is collapsed.
Click to expand it.
l0dable/src/light_sensor.rs
0 → 100644
+
27
−
0
View file @
16d5d0b1
use
super
::
bindings
::
*
;
pub
struct
LightSensor
;
impl
LightSensor
{
pub
fn
start
()
->
Self
{
if
unsafe
{
epic_light_sensor_run
()
}
!=
0
{
panic!
(
"Cannot start light sensor"
);
}
LightSensor
}
pub
fn
get
(
&
self
)
->
Option
<
u16
>
{
let
mut
result
=
0
;
if
unsafe
{
epic_light_sensor_get
(
&
mut
result
)
}
==
0
{
Some
(
result
)
}
else
{
None
}
}
}
impl
Drop
for
LightSensor
{
fn
drop
(
&
mut
self
)
{
unsafe
{
epic_light_sensor_stop
();
}
}
}
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