Expand description
§A Rust library for the Raspberry Pi Sense HAT LED Screen
The Raspberry Pi Sense HAT has an 8×8 RGB LED matrix that provides its own driver for the Linux framebuffer.
This library provides a thread-safe, strong-typed, high-level API for the LED matrix, treating it as you would any other screen on a Linux box.
For examples, please check the examples/ folder in the source code.
§Basics
-
Screenoffers a high-level API for the LED Matrix.Internally, it stores a
PixelFramemeant to be rendered on the LED Matrix.With the
linux-framebufferfeature, enabled by default,Screenwill have two methods:-
Screen::openwhich opens the framebuffer file-descriptor given as the only argument. -
Screen::write_framewhich takes a&FrameLineand writes the raw bytes onto the framebuffer, effectively displaying thePixelFrameon the LED Matrix.
-
-
PixelFrameis a collection of 64PixelColor, representing the 8-row by 8-column LED Matrix. -
PixelColoris a 24-bit representation of an RGB color, encoded in three bytes.
§Low-level constructs
Rgb565is a 16-bit representation of an RGB color, encoded in two bytes. This is the format.Rgb565converts into/fromPixelColor. supported by the LED Matrix’s framebuffer device.FrameLineis the raw-byte rendering of thePixelFrame, properly encoded and ready to be written into the framebuffer device.
§Frame operations
-
Requires
feature = "rotate", which is enabled by default.Rotate the PixelFrame by
Rotate::None,Rotate::Ccw90,Rotate::Ccw180, orRotate::Ccw270, that correspond to a counter-clockwise angle of0°,90°,180°, and270°, respectively. -
Requires
feature = "offset", which is enabled by default.Offset the PixelFrame by
Offset::left(n),Offset::right(n),Offset::bottom(n), orOffset::top(n), wherenis an integer between in the0..=8range.Offsetwith a value ofn = 0, return a clone of thePixelFrame.Offsetwith a value ofn = 8, return aPixelFrameoffset out of view, represented with black pixels (LEDs are off). -
Requires
feature = "clip", which is enabled by default.Creates a clip of two
PixelFrames, by defining anOffset. See the clip documentation for more details.
Re-exports§
pub extern crate framebuffer;pub use self::color::BackgroundColor;pub use self::color::PixelColor;pub use self::color::StrokeColor;pub use self::fonts::font_to_frame;pub use self::fonts::font_to_pixel_frame;pub use self::fonts::FontCollection;pub use self::fonts::FontString;pub use self::fonts::FONT_COLLECTION;pub use self::fonts::FONT_HASHMAP;pub use self::frame::clip::Clip;pub use self::frame::Offset;pub use self::frame::rotate::Rotate;pub use self::frame::FrameLine;pub use self::frame::PixelFrame;pub use self::screen::Screen;pub use self::scroll::Scroll;