sensehat_screen/
framebuffer.rs

1//! Framebuffer support for the Sense HAT LED Matrix.
2use super::{error::ScreenError, FrameLine};
3use framebuffer::Framebuffer;
4
5/// This is the main type for interacting with the LED Matrix Screen.
6#[derive(Debug)]
7pub struct Screen {
8    framebuffer: Framebuffer,
9}
10
11#[cfg(feature = "linux-framebuffer")]
12impl Screen {
13    /// Open the framebuffer to the screen at the given file-system path.
14    pub fn open(path: &str) -> Result<Self, ScreenError> {
15        let framebuffer = Framebuffer::new(path)?;
16        Ok(Screen { framebuffer })
17    }
18
19    /// Write the contents of a `FrameLine` into the framebuffer. This will
20    /// render the frameline on the screen.
21    pub fn write_frame(&mut self, frame: &FrameLine) {
22        self.framebuffer.write_frame(&frame.as_bytes());
23    }
24}