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
-
Screen
offers a high-level API for the LED Matrix.Internally, it stores a
PixelFrame
meant to be rendered on the LED Matrix.With the
linux-framebuffer
feature, enabled by default,Screen
will have two methods:-
Screen::open
which opens the framebuffer file-descriptor given as the only argument. -
Screen::write_frame
which takes a&FrameLine
and writes the raw bytes onto the framebuffer, effectively displaying thePixelFrame
on the LED Matrix.
-
-
PixelFrame
is a collection of 64PixelColor
, representing the 8-row by 8-column LED Matrix. -
PixelColor
is a 24-bit representation of an RGB color, encoded in three bytes.
§Low-level constructs
Rgb565
is a 16-bit representation of an RGB color, encoded in two bytes. This is the format.Rgb565
converts into/fromPixelColor
. supported by the LED Matrix’s framebuffer device.FrameLine
is 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)
, wheren
is an integer between in the0..=8
range.Offset
with a value ofn = 0
, return a clone of thePixelFrame
.Offset
with a value ofn = 8
, return aPixelFrame
offset out of view, represented with black pixels (LEDs are off). -
Requires
feature = "clip"
, which is enabled by default.Creates a clip of two
PixelFrame
s, 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_COLLECTION;
pub use self::fonts::FONT_HASHMAP;
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;
Modules§
- RGB color for LED pixels, with RGB565 rendering support.
- Errors for the SenseHat Screen.
- 8x8 font collection
- Frames for the LED Matrix screen
- Framebuffer support for the Sense HAT LED Matrix.
- Scrolling for pixel frames on the LED Matrix.