max-7219-led-matrix-util

Crates.iomax-7219-led-matrix-util
lib.rsmax-7219-led-matrix-util
version0.2.4
sourcesrc
created_at2020-07-08 22:07:08.522124
updated_at2022-10-03 07:54:10.059382
descriptionSimple `no_std`-utility-library using 'max7219'-crate for LED matrix displays with optional easy setup functions for Linux (Raspberry Pi).
homepagehttps://github.com/phip1611/max-7219-led-matrix-util
repositoryhttps://github.com/phip1611/max-7219-led-matrix-util
max_upload_size
id262661
size32,221
Philipp Schuster (phip1611)

documentation

https://docs.rs/max-7219-led-matrix-util/

README

Util library for MAX7219-powered LED matrix displays written in Rust for Linux (Raspberry Pi).

This is a no_std utility library on top of max7219-crate that allows you to easily display text on dot matrix displays. The main purpose of this lib is educational. There aren't mappings for all chars yet! Feel free to contribute on Github!

no_std support vs usage on Raspberry Pi

By default, this crate requires std and provide easy setup functions using gpio_cdev-crate on Raspberry Pi for example. If you need no_std, disable the default features.

Cargo.toml

[dependencies]
max-7219-led-matrix-util = "<latest-version>"
# or if you need `no_std`
max-7219-led-matrix-util = { version = "<latest-version>", default-features = false }

demo

Usage example (std)

use max_7219_led_matrix_util::setup_adapter;
use max_7219_led_matrix_util::{prepare_display, show_moving_text_in_loop};

const NUM_DISPLAYS: usize = 4;

fn main() {
    println!("Demo for the 4-display device by AzDelivery. This is the device in the gif in the README.md.");
    println!();
    println!(
        "Provide 3 pins (gpio pin nums) please and connect all to the device: <data> <cs> <clk>"
    );
    println!("for example: '12 16 21'");
    println!();

    let args: Vec<String> = std::env::args().collect();
    assert_eq!(args.len(), 4, "Provide three args!");

    let data_pin = args[1].parse::<u32>().unwrap();
    let cs_pin = args[2].parse::<u32>().unwrap();
    let clk_pin = args[3].parse::<u32>().unwrap();

    println!("data={}, cs={}, clk={}", data_pin, cs_pin, clk_pin);

    // display adapter (std-feature, doesn't work in no_std)
    let mut display = setup_adapter("/dev/gpiochip0", NUM_DISPLAYS, data_pin, cs_pin, clk_pin);
    prepare_display(&mut display, NUM_DISPLAYS, 0x0F);
    show_moving_text_in_loop(
        &mut display,
        "HELLO 01 ABCDEF MAPA   ",
        NUM_DISPLAYS,
        // ms for each animation step
        50,
        // max_gap_width
        2
    );
}

MSRV

The MSRV is 1.56.1.

Thanks to

Thanks to the creators of the max7219-crate!

Commit count: 39

cargo fmt