Skip to content

SLED1734X Driver

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

SLED1734X Datasheet

Usage

The SLED1734X driver code is automatically included if you are using the RGB Matrix feature with the sled1734x driver set, and you would use that API instead.

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

make
COMMON_VPATH += $(DRIVER_PATH)/led
SRC += sled1734x.c # For RGB
I2C_DRIVER_REQUIRED = yes

Basic Configuration

Add the following to your config.h:

DefineDefaultDescription
SLED1734X_SDB_PINNot definedThe GPIO pin connected to the drivers' shutdown pins
SLED1734X_I2C_TIMEOUT100The I²C timeout in milliseconds
SLED1734X_I2C_PERSISTENCE0The number of times to retry I²C transmissions
SLED1734X_I2C_ADDRESS_1Not definedThe I²C address of driver 0
SLED1734X_I2C_ADDRESS_2Not definedThe I²C address of driver 1
SLED1734X_I2C_ADDRESS_3Not definedThe I²C address of driver 2
SLED1734X_I2C_ADDRESS_4Not definedThe I²C address of driver 3

I²C Addressing

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

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

DefineValue
SLED1734X_I2C_ADDRESS_GND0x74
SLED1734X_I2C_ADDRESS_SCL0x75
SLED1734X_I2C_ADDRESS_SDA0x76
SLED1734X_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 sled1734x_led PROGMEM g_sled1734x_leds[SLED1734X_LED_COUNT] = {
/* Driver
 *   |  R         G         B */
    {0, CA3_D,  CA1_D,  CA2_D},
    // etc...
};

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

These values correspond to the register indices as shown in the datasheet on page 64. At the moment, the driver supports MATRIX TYPE 3 only.

API

struct sled1734x_led_t

Contains the PWM register addresses for a single RGB LED.

Members

  • uint8_t driver The driver index of the LED, from 0 to 3.
  • uint8_t r The output PWM register address for the LED's red channel (RGB driver only).
  • uint8_t g The output PWM register address for the LED's green channel (RGB driver only).
  • uint8_t b The output PWM register address for the LED's blue channel (RGB driver only).
  • uint8_t v The output PWM register address for the LED (single-color driver only).

void sled1734x_init(uint8_t index)

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

Arguments

  • uint8_t index The driver index.

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

Set the value of the given register.

Arguments

  • uint8_t index The driver index.
  • uint8_t reg The register address.
  • uint8_t data The value to set.

void sled1734x_select_page(uint8_t index, uint8_t page)

Change the current page for configuring the LED driver.

Arguments

  • uint8_t index The driver index.
  • uint8_t page The page number to select.

void sled1734x_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 sled1734x_update_pwm_buffers() after you are finished.

Arguments

  • int index The LED index (ie. the index into the g_sled1734x_leds array).
  • uint8_t red The red value to set.
  • uint8_t green The green value to set.
  • uint8_t blue The blue value to set.

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

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

Arguments

  • uint8_t red The red value to set.
  • uint8_t green The green value to set.
  • uint8_t blue The blue value to set.

void sled1734x_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 sled1734x_update_led_control_registers() after you are finished.

Arguments

  • uint8_t index The LED index (ie. the index into the g_sled1734x_leds array).
  • bool red Enable or disable the red channel.
  • bool green Enable or disable the green channel.
  • bool blue Enable or disable the blue channel.

void sled1734x_update_pwm_buffers(uint8_t index)

Flush the PWM values to the LED driver.

Arguments

  • uint8_t index The driver index.

void sled1734x_update_led_control_registers(uint8_t index)

Flush the LED control register values to the LED driver.

Arguments

  • uint8_t index The driver index.