rotate/
rotate.rs

1#[cfg(feature = "default")]
2extern crate sensehat_screen;
3
4#[cfg(feature = "default")]
5use sensehat_screen::Rotate;
6#[cfg(feature = "default")]
7use sensehat_screen::{font_to_pixel_frame, FontCollection, PixelColor, PixelFrame, Screen};
8
9#[cfg(not(feature = "default"))]
10fn main() {
11    unimplemented!("This examples needs the 'default' features.");
12}
13#[cfg(feature = "default")]
14fn main() {
15    let mut screen = Screen::open("/dev/fb1").unwrap();
16    let fonts = FontCollection::new();
17
18    for &(sym, color) in &[('Ñ', PixelColor::YELLOW), ('ó', PixelColor::MAGENTA)] {
19        let font = fonts.get(sym).unwrap();
20        let symbol = font_to_pixel_frame(font.byte_array(), color);
21        let symbol_90 = symbol.rotate(Rotate::Ccw90);
22        let symbol_180 = symbol.rotate(Rotate::Ccw180);
23        let symbol_270 = symbol.rotate(Rotate::Ccw270);
24        for _ in 0..=4 {
25            screen.write_frame(&symbol.frame_line());
26            ::std::thread::sleep(::std::time::Duration::from_millis(500));
27            screen.write_frame(&symbol_90.frame_line());
28            ::std::thread::sleep(::std::time::Duration::from_millis(500));
29            screen.write_frame(&symbol_180.frame_line());
30            ::std::thread::sleep(::std::time::Duration::from_millis(500));
31            screen.write_frame(&symbol_270.frame_line());
32            ::std::thread::sleep(::std::time::Duration::from_millis(500));
33        }
34        screen.write_frame(&PixelFrame::new(&[PixelColor::BLACK; 64]).frame_line());
35    }
36}