unicorn_hat_mini

Crates.iounicorn_hat_mini
lib.rsunicorn_hat_mini
version0.1.0
sourcesrc
created_at2023-01-20 21:59:14.171618
updated_at2023-01-20 21:59:14.171618
descriptionInterface to the Pimoroni Unicorn HAT Mini on a Raspberry Pi
homepage
repositoryhttps://github.com/daniel-tp/unicorn_hat_mini
max_upload_size
id763778
size16,147
Daniel P (daniel-tp)

documentation

README

Unicorn_Hat_Mini Crate

Crates.io

This is a Rust Library for interfacing with a Pimorini Unicorn HAT Mini, for Raspberry Pi.

It is strongly based on their Python Library with some changes.

SPI must be enabled on your Raspberry Pi for it to work: sudo raspi-config nonint do_spi 0

Example

Cargo.toml

[dependencies]
unicorn_hat_mini = "0.1"

Example code that sets all the pixels.

use core::time;
use rgb::RGB8;
use unicorn_hat_mini::UnicornHATMini;

fn main() -> Result<(), unicorn_hat_mini::UnicornError>{
    let mut uni = UnicornHATMini::default();
    uni.set_brightness(0.1)?;
    let mut rgb = 100;
    loop {
        uni.set_all(RGB8{r:rgb, g:rgb, b:rgb});
        uni.show();
        if rgb <255 {
            rgb+=1;
        }else{
            rgb=0;
        }
        std::thread::sleep(time::Duration::from_millis(16));
    }
}
Commit count: 10

cargo fmt