lp50xx
Embedded driver for the Texas Instruments LP5009 and LP5012 LED drivers
description
The LP50xx device is an 9- or 12-channel constantcurrent sink LED driver. The LP50xx device includes integrated color mixing and brightness control, and pre-configuration simplifies the software coding process. Integrated 12-bit, 29-kHz PWM generatorsfor each channel enable smooth, vivid color for LEDs, and eliminate audible noise.
example
Examples are based on the stm32h7xx_hal
.
// Initialize I2C pins, SCL, SDA
let scl = scl
.into_alternate_af4
.internal_pull_up
.set_open_drain;
let sda = sda
.into_alternate_af4
.internal_pull_up
.set_open_drain;
// Initialize the Enable line
let en = en.into_push_pull_output;
// Initialize
let i2c: I2c =
i2c.i2c;
// Initialize with blocking I2C
let interface = init_with_i2c;
// Use the LP50xx in monochromatic mode
let mut monochromatic_controller = interface.into_monochromatic_mode;
// Enable it, this requires a delay provider
monochromatic_controller.enable.ok;
// Set LED 5 to 255
monchromatic_controller.set.ok;
// The continuous addressing feature is enabled by default, allowing you to address
// multiple LP50xx devices on the same bus in an intuitive way.
// There are 12 LEDs available per LP5012, therefore the following command
// will illuminate the 1st LED on the on the second LP5012:
monchromatic_controller.set.ok;
// You can turn this feature off and set the active address manually also:
monchromatic_controller.set_continuous_addressing;
// Set the active address to be the second device
monchromatic_controller.set_active_address;
// And then turn off the same 1st LED on the second device
monchromatic_controller.set.ok;
// Alternatively, if you are using RGB LEDs you can use the LP50xx in color mode
let mut color_controller = monochromatic_controller.into_color_mode;
// Set channel 1 brightness and RGB values
color_controller.set.ok;
// Release the blocking i2c example to regain access to its underyling resources
let = color_controller.release;
// Additionally, if you need to integrate this driver with platform specific DMA controllers then
// a flexible callback can be used rather than blocking i2c
static mut DMA_BUFFER: = ;
let interface = init_with_callback
.into_monochromatic_mode;
contributing
Feel free to create a ticket and a MR for any changes you would like to see in this library.