import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.B9AX-CPi.js"; const __pageData = JSON.parse('{"title":"SNLED27351 Driver","description":"","frontmatter":{},"headers":[],"relativePath":"drivers/snled27351.md","filePath":"drivers/snled27351.md"}'); const _sfc_main = { name: "drivers/snled27351.md" }; const _hoisted_1 = /* @__PURE__ */ createStaticVNode('

SNLED27351 Driver

I²C 16x12 LED matrix driver by Sonix. Supports a maximum of four drivers, each controlling up to 192 single-color LEDs, or 64 RGB LEDs.

A slightly modified version of this IC is also known as "CKLED2001".

SNLED27351 Datasheet

Usage

The SNLED27351 driver code is automatically included if you are using the LED Matrix or RGB Matrix feature with the snled27351 driver set, and you would use those APIs instead.

However, if you need to use the driver standalone, add this to your rules.mk:

make
COMMON_VPATH += $(DRIVER_PATH)/led\nSRC += snled27351-mono.c # For single-color\nSRC += snled27351.c # For RGB\nI2C_DRIVER_REQUIRED = yes

Basic Configuration

Add the following to your config.h:

DefineDefaultDescription
SNLED27351_SDB_PINNot definedThe GPIO pin connected to the drivers' shutdown pins
SNLED27351_I2C_TIMEOUT100The I²C timeout in milliseconds
SNLED27351_I2C_PERSISTENCE0The number of times to retry I²C transmissions
SNLED27351_I2C_ADDRESS_1Not definedThe I²C address of driver 0
SNLED27351_I2C_ADDRESS_2Not definedThe I²C address of driver 1
SNLED27351_I2C_ADDRESS_3Not definedThe I²C address of driver 2
SNLED27351_I2C_ADDRESS_4Not definedThe I²C address of driver 3

I²C Addressing

The SNLED27351 has four possible 7-bit I²C addresses, depending on how the ADDR pin is connected.

To configure this, set the SNLED27351_I2C_ADDRESS_n defines to one of the following in your config.h, where n denotes the driver index:

DefineValue
SNLED27351_I2C_ADDRESS_GND0x74
SNLED27351_I2C_ADDRESS_SCL0x75
SNLED27351_I2C_ADDRESS_SDA0x76
SNLED27351_I2C_ADDRESS_VDDIO0x77

ARM/ChibiOS Configuration

Depending on the ChibiOS board configuration, you may need to enable and configure I²C at the keyboard level.

LED Mapping

In order to use this driver, each output must be mapped to an LED index, by adding the following to your <keyboardname>.c:

c
const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {\n/* Driver\n *   |  R         G         B */\n    {0, CB1_CA1,  CB1_CA2,  CB1_CA3},\n    // etc...\n};

In this example, the red, green and blue channels for the first LED index on driver 0 all have their cathodes connected to the CB1 pin, and their anodes on the CA1, CA2 and CA3 pins respectively.

For the single-color driver, the principle is the same, but there is only one channel:

c
const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {\n/* Driver\n *   |  V */\n    {0, CB1_CA1},\n    // etc...\n};

These values correspond to the register indices as shown in the datasheet on page 13.

API

struct snled27351_led_t

Contains the PWM register addresses for a single RGB LED.

Members


void snled27351_init(uint8_t index)

Initialize the LED driver. This function should be called first.

Arguments


void snled27351_write_register(uint8_t index, uint8_t reg, uint8_t data)

Set the value of the given register.

Arguments


void snled27351_select_page(uint8_t index, uint8_t page)

Change the current page for configuring the LED driver.

Arguments


void snled27351_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)

Set the color of a single LED (RGB driver only). This function does not immediately update the LEDs; call snled27351_update_pwm_buffers() after you are finished.

Arguments


void snled27351_set_color_all(uint8_t red, uint8_t green, uint8_t blue)

Set the color of all LEDs (RGB driver only).

Arguments


void snled27351_set_value(int index, uint8_t value)

Set the brightness of a single LED (single-color driver only). This function does not immediately update the LEDs; call snled27351_update_pwm_buffers() after you are finished.

Arguments


void snled27351_set_value_all(uint8_t value)

Set the brightness of all LEDs (single-color driver only).

Arguments


void snled27351_set_led_control_register(uint8_t index, bool red, bool green, bool blue)

Configure the LED control registers for a single LED (RGB driver only). This function does not immediately update the LEDs; call snled27351_update_led_control_registers() after you are finished.

Arguments


void snled27351_set_led_control_register(uint8_t index, bool value)

Configure the LED control registers for a single LED (single-color driver only). This function does not immediately update the LEDs; call snled27351_update_led_control_registers() after you are finished.

Arguments


void snled27351_update_pwm_buffers(uint8_t index)

Flush the PWM values to the LED driver.

Arguments


void snled27351_update_led_control_registers(uint8_t index)

Flush the LED control register values to the LED driver.

Arguments

', 84); const _hoisted_85 = [ _hoisted_1 ]; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("div", null, _hoisted_85); } const snled27351 = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { __pageData, snled27351 as default };