-
Notifications
You must be signed in to change notification settings - Fork 4
/
rotate.rs
36 lines (33 loc) · 1.47 KB
/
rotate.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
36
#[cfg(feature = "default")]
extern crate sensehat_screen;
#[cfg(feature = "default")]
use sensehat_screen::Rotate;
#[cfg(feature = "default")]
use sensehat_screen::{font_to_pixel_frame, FontCollection, PixelColor, PixelFrame, Screen};
#[cfg(not(feature = "default"))]
fn main() {
unimplemented!("This examples needs the 'default' features.");
}
#[cfg(feature = "default")]
fn main() {
let mut screen = Screen::open("/dev/fb1").unwrap();
let fonts = FontCollection::new();
for &(sym, color) in &[('Ñ', PixelColor::YELLOW), ('ó', PixelColor::MAGENTA)] {
let font = fonts.get(sym).unwrap();
let symbol = font_to_pixel_frame(font.byte_array(), color);
let symbol_90 = symbol.rotate(Rotate::Ccw90);
let symbol_180 = symbol.rotate(Rotate::Ccw180);
let symbol_270 = symbol.rotate(Rotate::Ccw270);
for _ in 0..=4 {
screen.write_frame(&symbol.frame_line());
::std::thread::sleep(::std::time::Duration::from_millis(500));
screen.write_frame(&symbol_90.frame_line());
::std::thread::sleep(::std::time::Duration::from_millis(500));
screen.write_frame(&symbol_180.frame_line());
::std::thread::sleep(::std::time::Duration::from_millis(500));
screen.write_frame(&symbol_270.frame_line());
::std::thread::sleep(::std::time::Duration::from_millis(500));
}
screen.write_frame(&PixelFrame::new(&[PixelColor::BLACK; 64]).frame_line());
}
}