-
Notifications
You must be signed in to change notification settings - Fork 3
/
scroll-right-left.rs
35 lines (29 loc) · 1.19 KB
/
scroll-right-left.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#[cfg(feature = "default")]
extern crate sensehat_screen;
#[cfg(feature = "default")]
use sensehat_screen::{FontCollection, PixelColor, Screen, Scroll};
#[cfg(not(feature = "default"))]
fn main() {
unimplemented!("This examples needs the 'default' features.");
}
#[cfg(feature = "default")]
fn main() {
// Connect to our LED Matrix screen.
let mut screen = Screen::open("/dev/fb1").unwrap();
// Get the default `FontCollection`.
let fonts = FontCollection::new();
// Create a sanitized `FontString`.
let sanitized = fonts.sanitize_str(" «««123««« ").unwrap();
// Render the `FontString` as a vector of pixel frames, with
// a stroke color of GREEN and a BLACK background.
let pixel_frames = sanitized.pixel_frames(PixelColor::GREEN, PixelColor::BLACK);
// Create a `Scroll` from the pixel frame vector.
let scroll = Scroll::new(&pixel_frames);
// Consume the `FrameSequence` returned by the `right_to_left` method.
scroll.right_to_left().for_each(|frame| {
println!("Now printing:");
println!("{:?}", frame);
screen.write_frame(&frame.frame_line());
::std::thread::sleep(::std::time::Duration::from_millis(250));
});
}