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
cae9cab6
Commit
cae9cab6
authored
5 years ago
by
Raphael Nestler
Browse files
Options
Downloads
Patches
Plain Diff
Rolling buffer
parent
7654125f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sensor-plot/src/main.rs
+6
-4
6 additions, 4 deletions
sensor-plot/src/main.rs
with
6 additions
and
4 deletions
sensor-plot/src/main.rs
+
6
−
4
View file @
cae9cab6
...
@@ -7,7 +7,7 @@ use core::fmt::Write;
...
@@ -7,7 +7,7 @@ use core::fmt::Write;
struct
PlotBuffer
{
struct
PlotBuffer
{
buffer
:
[
i32
;
Display
::
W
as
usize
],
buffer
:
[
i32
;
Display
::
W
as
usize
],
index
:
u
size
,
index
:
u
16
,
}
}
impl
PlotBuffer
{
impl
PlotBuffer
{
...
@@ -27,9 +27,9 @@ impl PlotBuffer {
...
@@ -27,9 +27,9 @@ impl PlotBuffer {
}
}
pub
fn
add_sample
(
&
mut
self
,
sample
:
i32
)
{
pub
fn
add_sample
(
&
mut
self
,
sample
:
i32
)
{
self
.buffer
[
self
.index
]
=
sample
;
self
.buffer
[
self
.index
as
usize
]
=
sample
;
self
.index
+=
1
;
self
.index
+=
1
;
if
self
.index
>=
Display
::
W
as
usize
{
if
self
.index
>=
Display
::
W
{
self
.index
=
0
;
self
.index
=
0
;
}
}
}
}
...
@@ -45,9 +45,11 @@ impl PlotBuffer {
...
@@ -45,9 +45,11 @@ impl PlotBuffer {
};
};
for
i
in
0
..
Display
::
W
{
for
i
in
0
..
Display
::
W
{
let
index
=
(
self
.index
+
i
)
%
Display
::
W
;
display
.pixel
(
display
.pixel
(
i
,
i
,
((
Display
::
H
-
1
)
as
f32
-
((
self
.buffer
[
i
as
usize
]
as
f32
-
min
)
*
multiplier
))
((
Display
::
H
-
1
)
as
f32
-
((
self
.buffer
[
index
as
usize
]
as
f32
-
min
)
*
multiplier
))
as
u16
,
as
u16
,
Color
::
white
(),
Color
::
white
(),
);
);
...
...
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