docs/drivers/is31fl3236.md
I²C LED driver by Lumissil. Supports a maximum of four drivers, each controlling up to 36 single-color LEDs, or 12 RGB LEDs.
The IS31FL3236 driver code is automatically included if you are using the LED Matrix or RGB Matrix feature with the is31fl3236 driver set, and you would use those APIs instead.
However, if you need to use the driver standalone, add this to your rules.mk:
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31fl3236-mono.c # For single-color
SRC += is31fl3236.c # For RGB
I2C_DRIVER_REQUIRED = yes
Add the following to your config.h:
| Define | Default | Description |
|---|---|---|
IS31FL3236_SDB_PIN | Not defined | The GPIO pin connected to the drivers' shutdown pins |
IS31FL3236_I2C_TIMEOUT | 100 | The I²C timeout in milliseconds |
IS31FL3236_I2C_PERSISTENCE | 0 | The number of times to retry I²C transmissions |
IS31FL3236_I2C_ADDRESS_1 | Not defined | The I²C address of driver 0 |
IS31FL3236_I2C_ADDRESS_2 | Not defined | The I²C address of driver 1 |
IS31FL3236_I2C_ADDRESS_3 | Not defined | The I²C address of driver 2 |
IS31FL3236_I2C_ADDRESS_4 | Not defined | The I²C address of driver 3 |
The IS31FL3236 has four possible 7-bit I²C addresses, depending on how the AD pin is connected.
To configure this, set the IS31FL3236_I2C_ADDRESS_n defines to one of the following in your config.h, where n denotes the driver index:
| Define | Value |
|---|---|
IS31FL3236_I2C_ADDRESS_GND | 0x3C |
IS31FL3236_I2C_ADDRESS_SCL | 0x3D |
IS31FL3236_I2C_ADDRESS_SDA | 0x3E |
IS31FL3236_I2C_ADDRESS_VCC | 0x3F |
Depending on the ChibiOS board configuration, you may need to enable and configure I²C at the keyboard level.
In order to use this driver, each output must be mapped to an LED index, by adding the following to your <keyboard>.c:
const is31fl3236_led_t PROGMEM g_is31fl3236_leds[IS31FL3236_LED_COUNT] = {
/* Driver
| R G B */
{0, OUT1, OUT2, OUT3},
// etc...
};
In this example, the red, green and blue channels for the first LED index on driver 0 all have their anodes connected to VCC, and their cathodes on the OUT1, OUT2 and OUT3 pins respectively.
For the single-color driver, the principle is the same, but there is only one channel:
const is31fl3236_led_t PROGMEM g_is31fl3236_leds[IS31FL3236_LED_COUNT] = {
/* Driver
| V */
{0, OUT1},
// etc...
};
struct is31fl3236_led_t {#api-is31fl3236-led-t}Contains the PWM register addresses for a single RGB LED.
uint8_t driveruint8_t ruint8_t guint8_t buint8_t vvoid is31fl3236_init(uint8_t index) {#api-is31fl3236-init}Initialize the LED driver. This function should be called first.
uint8_t indexvoid is31fl3236_write_register(uint8_t index, uint8_t reg, uint8_t data) {#api-is31fl3236-write-register}Set the value of the given register.
uint8_t indexuint8_t reguint8_t datavoid is31fl3236_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {#api-is31fl3236-set-color}Set the color of a single LED (RGB driver only). This function does not immediately update the LEDs; call is31fl3236_update_pwm_buffers() after you are finished.
int indexg_is31fl3236_leds array).uint8_t reduint8_t greenuint8_t bluevoid is31fl3236_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {#api-is31fl3236-set-color-all}Set the color of all LEDs (RGB driver only).
uint8_t reduint8_t greenuint8_t bluevoid is31fl3236_set_value(int index, uint8_t value) {#api-is31fl3236-set-value}Set the brightness of a single LED (single-color driver only). This function does not immediately update the LEDs; call is31fl3236_update_pwm_buffers() after you are finished.
int indexg_is31fl3236_leds array).uint8_t valuevoid is31fl3236_set_value_all(uint8_t value) {#api-is31fl3236-set-value-all}Set the brightness of all LEDs (single-color driver only).
uint8_t valuevoid is31fl3236_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {#api-is31fl3236-set-led-control-register-rgb}Configure the LED control registers for a single LED (RGB driver only). This function does not immediately update the LEDs; call is31fl3236_update_led_control_registers() after you are finished.
uint8_t indexg_is31fl3236_leds array).bool redbool greenbool bluevoid is31fl3236_set_led_control_register(uint8_t index, bool value) {#api-is31fl3236-set-led-control-register-mono}Configure the LED control registers for a single LED (single-color driver only). This function does not immediately update the LEDs; call is31fl3236_update_led_control_registers() after you are finished.
uint8_t indexg_is31fl3236_leds array).bool valuevoid is31fl3236_update_pwm_buffers(uint8_t index) {#api-is31fl3236-update-pwm-buffers}Flush the PWM values to the LED driver.
uint8_t indexvoid is31fl3236_update_led_control_registers(uint8_t index) {#api-is31fl3236-update-led-control-registers}Flush the LED control register values to the LED driver.
uint8_t index