Crate sensehat_screen

Source
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:

    1. Screen::open which opens the framebuffer file-descriptor given as the only argument.

    2. Screen::write_frame which takes a &FrameLine and writes the raw bytes onto the framebuffer, effectively displaying the PixelFrame on the LED Matrix.

  • PixelFrame is a collection of 64 PixelColor, 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/from PixelColor. supported by the LED Matrix’s framebuffer device.
  • FrameLine is the raw-byte rendering of the PixelFrame, properly encoded and ready to be written into the framebuffer device.

§Frame operations

  • Rotate

    Requires feature = "rotate", which is enabled by default.

    Rotate the PixelFrame by Rotate::None, Rotate::Ccw90, Rotate::Ccw180, or Rotate::Ccw270, that correspond to a counter-clockwise angle of , 90°, 180°, and 270°, respectively.

  • Offset

    Requires feature = "offset", which is enabled by default.

    Offset the PixelFrame by Offset::left(n), Offset::right(n), Offset::bottom(n), or Offset::top(n), where n is an integer between in the 0..=8 range.

    Offset with a value of n = 0, return a clone of the PixelFrame.

    Offset with a value of n = 8, return a PixelFrame offset out of view, represented with black pixels (LEDs are off).

  • Clip

    Requires feature = "clip", which is enabled by default.

    Creates a clip of two PixelFrames, by defining an Offset. See the clip documentation for more details.

Re-exports§

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.