SN3193 Driver for Rust
This Rust embedded-hal-based library is a simple way to control the SN3193 RGB LED driver.
The SN3193 is a 3-channel LED driver with PWM control and breathing mode. It can drive up to
3 LEDs with a maximum current of 42 mA and is controlled via I2C. This driver is designed for the
no_std environment, so it can be used in embedded systems.
Usage
Add this to your Cargo.toml:
[]
= "0.1"
Then to create a new driver:
use DelayMs;
use I2c;
use
Features
PWM mode
The driver can set the LEDs to PWM mode. This allows you to set the brightness of each LED individually.
if let Err = diver.set_led_mode
// check your device wiring to know which LED is which
if let Err = driver.set_pwm_levels
Breathing mode
The driver can set the LEDs to breathing mode. This mode allows you to set the time it takes for the LED to ramp up to full brightness, hold at full brightness, ramp down to off, and hold at off. Each of these times can be set individually for each LED. Furthermore, the PWM levels can be set for each LED.
// set the breathing times the same for all LEDs
if let Err = driver.set_breathing_times_for_led
// enable breathing mode
if let Err = driver.set_led_mode
The PWM levels and breathing times can be changed at any time. The driver will update the LEDs with the new settings.
Function chaining
The driver functions return a Result that contains the driver reference in the Ok value. This
can be chained together to make the code more readable.
driver.set_led_mode?
.set_current?
.set_pwm_levels?
.enable_leds?;
License
This library is licensed under the MIT license.