A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/leonidv/is31fl3728-rs below:

GitHub - leonidv/is31fl3728-rs: Rust embedded driver for is31fl3728

Rust IS31FL3728 audio modulated matrix led driver

IS31FL3728 is a general purpose 8×8 LED matrix driver which features an audio frequency equalizer (EQ) mode or a general LED dot matrix display mode. The matrix picture brightness can be modulated by audio. In either the audio EQ mode or matrix display mode, the array is internally scanned, and requires only one-time programming, thus eliminating the need for real time system resource utilization.

Add the following to your Cargo.tml to get is a dependency (check that version is the latest!).

[dependency]
is31fl3728-rs="1.1.0"

This crate provides a platform-agnostic driver for the IS31FL3728 LED Matrix. Led driver uses I2C.

Support all features of driver:

See IS31FL3728 data sheet for details.

This crate based on [embedded-hal] version 1.0.

Features:

Important

You MUST initialize rtt in your application

The IS31FL3728 uses columns, not rows, as the more popular MAX7219 does. This is why you can't use a 8x8 led matrix editor like this one: https://xantorohara.github.io/led-matrix-editor/ . The library provides a method "draw_bitmap" which solves this trouble.

Create an instance of driver with the new method, by passing initialized I2C and configuration

let i2c = // depends of your MCU and HAL
let matrix_addr: u8 = 0x60;
let mut led_matrix = IS31FL3728::new(i2c, matrix_addr, MatrixDimensions::M8x8, false).unwrap();

Driver is ready to use after creating.

Folder examples contains full examples:

#![deny(unsafe_code)]
#![no_main]
#![no_std]


use is31fl3728_led_matrix::{LightingIntensity, MatrixDimensions, DEFAULT_LIGHTING_INTENSITY, IS31FL3728};

// Halt on panic
use panic_halt as _;

use rtt_target::rtt_init_print;

use cortex_m_rt::entry;
use stm32f4xx_hal::{self as hal, gpio::GpioExt, i2c::I2c, pac, prelude::*};

#[allow(clippy::empty_loop)]
#[entry]
fn main() -> ! {
    rtt_init_print!();

    let dp = pac::Peripherals::take().unwrap();

    let rcc = dp.RCC.constrain();
    let clocks = rcc.cfgr.use_hse(8.MHz()).sysclk(84.MHz()).freeze();
    let mut delay = dp.TIM5.delay_us(&clocks);      


    let gpiob = dp.GPIOB.split();

    let pb8_scl = gpiob.pb8;
    let pb9_sda = gpiob.pb9;

    // Initiation of I2C
    let i2c1 = I2c::new(
        dp.I2C1,
        (pb8_scl, pb9_sda),
        hal::i2c::Mode::standard(400.kHz()),
        &clocks,
    );

    let matrix_addr: u8 = 0x60;
    let mut led_matrix = IS31FL3728::new(i2c1, matrix_addr, MatrixDimensions::M8x8, false).unwrap();
    led_matrix.clear().unwrap();

    let picture = [
        0b00000000,
        0b01100110,
        0b11111111,
        0b11111111,
        0b11111111,
        0b01111110,
        0b00111100,
        0b00011000,
    ];

    led_matrix.draw_bitmap(&picture).unwrap();
    led_matrix.set_intensity(LightingIntensity::C20mA).unwrap();

    loop {
        led_matrix.software_on().unwrap();
        led_matrix.set_intensity(LightingIntensity::C10mA).unwrap();
        delay.delay_ms(150);
        led_matrix.set_intensity(LightingIntensity::C25mA).unwrap();
        delay.delay_ms(150);
        led_matrix.set_intensity(DEFAULT_LIGHTING_INTENSITY).unwrap();
        delay.delay_ms(500);

        led_matrix.set_intensity(LightingIntensity::C25mA).unwrap();
        delay.delay_ms(150);
        led_matrix.set_intensity(LightingIntensity::C10mA).unwrap();
        delay.delay_ms(150);
        led_matrix.software_shutdown().unwrap();
        delay.delay_ms(300);
    }
}

Result of application:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4