#embedded-hal-driver #ledcontrol #pin #chip #devices #repo

no-std max7219

A platform agnostic driver to interface the MAX7219 (LED driver)

11 releases

0.5.0 Mar 4, 2025
0.4.2 Dec 13, 2023
0.4.0 Apr 4, 2023
0.3.1 May 9, 2021
0.1.2 Jun 17, 2019

#201 in Embedded development

Download history 32/week @ 2024-12-04 89/week @ 2024-12-11 23/week @ 2024-12-18 60/week @ 2024-12-25 16/week @ 2025-01-01 19/week @ 2025-01-08 47/week @ 2025-01-15 32/week @ 2025-01-22 30/week @ 2025-01-29 50/week @ 2025-02-05 79/week @ 2025-02-12 19/week @ 2025-02-19 89/week @ 2025-02-26 128/week @ 2025-03-05 104/week @ 2025-03-12 27/week @ 2025-03-19

350 downloads per month
Used in 2 crates

MIT license

26KB
465 lines

max7219

A platform agnostic driver to interface with the MAX7219 (LED display driver)

Build Status

What works

  • Powering on/off the MAX chip
  • Basic commands for setting LEDs on/off.
  • Chaining support (max 8 devices)
  • Hardware SPI support (with or without CS pin)

Changelog

Example

Example projects are at this repo

Here is a simple example for using the MAX7219 on a hifive1-revb device with e310x_hal:

#![no_std]
#![no_main]

extern crate panic_halt;

use riscv_rt::entry;
use hifive1::hal::prelude::*;
use hifive1::hal::DeviceResources;
use hifive1::pin;
use max7219::*;

#[entry]
fn main() -> ! {
    let dr = DeviceResources::take().unwrap();
    let p = dr.peripherals;
    let gpio = dr.pins;

    // Configure clocks
    hifive1::clock::configure(p.PRCI, p.AONCLK, 320.mhz().into());
    
    let data = pin!(gpio, spi0_mosi).into_output();
    let sck = pin!(gpio, spi0_sck).into_output();
    let cs = pin!(gpio, spi0_ss0).into_output();

    let mut display = MAX7219::from_pins(1, data, cs, sck).unwrap();

    // make sure to wake the display up
    display.power_on().unwrap();
    // write given octet of ASCII characters with dots specified by 3rd param bits
    display.write_str(0, b"pls help", 0b00100000).unwrap();
    // set display intensity lower
    display.set_intensity(0, 0x1).unwrap();

    loop {}
}

Credits

Original work by Maikel Wever. Adapted to latest embedded-hal and documented by Ales Katona.

License

Licensed under MIT license (LICENSE or http://opensource.org/licenses/MIT)

Dependencies

~56KB