Crate unicorn_hat

Crate unicorn_hat 

Source
Expand description

Rust library for controlling the Pimoroni Unicorn HAT (8x8) on Raspberry Pi

This library provides a safe, ergonomic API for controlling the 8x8 WS2812 LED grid on the Pimoroni Unicorn HAT.

§Hardware Requirements

  • Pimoroni Unicorn HAT (8x8, NOT the HD version)
  • Raspberry Pi with GPIO access
  • SPI enabled via raspi-config
  • Root/sudo privileges (required for PWM hardware access)

§Quick Start

use unicorn_hat::{UnicornHat, RGB8};

// Initialize the HAT
let mut hat = UnicornHat::new()?;

// Set a pixel and display
hat.set_pixel_raw(0, RGB8::RED)?;
hat.display()?;

// Clear all pixels
hat.clear();
hat.display()?;

Re-exports§

pub use buffer::PixelBuffer;
pub use buffer::TestBuffer;

Modules§

buffer
Buffer abstraction for pixel operations.
primitives
Drawing primitives for the Unicorn HAT.

Structs§

HSV
HSV color representation
RGB8
RGB color with 8-bit channels
UnicornHat
Main interface for controlling the Unicorn HAT
ZigzagMapping
Standard zigzag mapping for Pimoroni Unicorn HAT

Enums§

Error
Errors that can occur when using the Unicorn HAT
Origin
Coordinate system origin location
Palette
Standard color palettes for data visualization
Rotate
Rotation angles for the display

Traits§

PixelMapper
Trait for converting (x, y) coordinates to buffer indices