LED drivers: extract documentation from LED/RGB Matrix pages (#23630)

This commit is contained in:
Ryan 2024-07-15 12:03:30 +10:00 committed by GitHub
parent 21b9b70c50
commit 85447bd53b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 3956 additions and 697 deletions

133
docs/drivers/aw20216s.md Normal file
View File

@ -0,0 +1,133 @@
# AW20216S Driver {#aw20216s-driver}
SPI 18x12 LED matrix driver by Awinic. Supports a maximum of four drivers, each controlling up to 216 single-color LEDs, or 72 RGB LEDs.
[AW20216S Datasheet](https://doc.awinic.com/doc/20230609wm/b6a9c70b-e1bd-495b-925f-bcbed3fc2620.pdf)
## Usage {#usage}
The AW20216S driver code is automatically included if you are using the [RGB Matrix](../features/rgb_matrix) feature with the `aw20216s` 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
SRC += aw20216s.c
SPI_DRIVER_REQUIRED = yes
```
## Basic Configuration {#basic-configuration}
Add the following to your `config.h`:
|Define |Default |Description |
|-----------------------------|-------------|-------------------------------------------------------------|
|`AW20216S_CS_PIN_1` |*Not defined*|The GPIO pin connected to the first driver's Chip Select pin |
|`AW20216S_CS_PIN_2` |*Not defined*|The GPIO pin connected to the second driver's Chip Select pin|
|`AW20216S_EN_PIN` |*Not defined*|The GPIO pin connected to the drivers' Enable pins |
|`AW20216S_SPI_MODE` |`0` |The SPI mode to use |
|`AW20216S_SPI_DIVISOR` |`4` |The SPI divisor to use |
|`AW20216S_SCALING_MAX` |`150` |The scaling value |
|`AW20216S_GLOBAL_CURRENT_MAX`|`150` |The global current control value |
### Global Current Control {#global-current-control}
This setting controls the current sunk by the `CSx` pins, from 0 to 255. To adjust it, add the following to your `config.h`:
```c
#define AW20216S_GLOBAL_CURRENT_MAX 150
```
## ARM/ChibiOS Configuration {#arm-configuration}
Depending on the ChibiOS board configuration, you may need to [enable and configure SPI](spi#arm-configuration) at the keyboard level.
## LED Mapping {#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 aw20216s_led_t PROGMEM g_aw20216s_leds[AW20216S_LED_COUNT] = {
/* Driver
* | R G B */
{0, SW1_CS1, SW1_CS2, SW1_CS3},
// etc...
};
```
In this example, the first LED index on driver 0 has its red channel on `SW1_CS1`, green on `SW1_CS2` and blue on `SW1_CS3`.
These values correspond to the matrix locations as shown in the datasheet on page 16, figure 16.
## API {#api}
### `struct aw20216s_led_t` {#api-aw20216s-led-t}
Contains the PWM register addresses for a single RGB LED.
#### Members {#api-aw20216s-led-t-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.
- `uint8_t g`
The output PWM register address for the LED's green channel.
- `uint8_t b`
The output PWM register address for the LED's blue channel.
---
### `void aw20216s_init(pin_t cs_pin)` {#api-aw20216s-init}
Initialize the LED driver. This function should be called first.
#### Arguments {#api-aw20216s-init-arguments}
- `pin_t cs_pin`
The GPIO connected to the Chip Select pin of the LED driver to initialize.
---
### `void aw20216s_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)` {#api-aw20216s-set-color}
Set the color of a single LED. This function does not immediately update the LEDs; call `aw20216s_update_pwm_buffers()` after you are finished.
#### Arguments {#api-aw20216s-set-color-arguments}
- `int index`
The LED index (ie. the index into the `g_aw20216s_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 aw20216s_set_color_all(uint8_t red, uint8_t green, uint8_t blue)` {#api-aw20216s-set-color-all}
Set the color of all LEDs.
#### Arguments {#api-aw20216s-set-color-all-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 aw20216s_update_pwm_buffers(pin_t cs_pin, uint8_t index)` {#api-aw20216s-update-pwm-buffers}
Flush the PWM values to the LED driver.
#### Arguments {#api-aw20216s-update-pwm-buffers-arguments}
- `pin_t cs_pin`
The GPIO connected to the Chip Select pin of the driver.
- `uint8_t index`
The index of the driver.

194
docs/drivers/is31fl3218.md Normal file
View File

@ -0,0 +1,194 @@
# IS31FL3218 Driver {#is31fl3218-driver}
I²C LED driver by Lumissil. Supports up to 18 single-color LEDs, or 6 RGB LEDs.
[IS31FL3218 Datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3218_DS.pdf)
## Usage {#usage}
The IS31FL3218 driver code is automatically included if you are using the [LED Matrix](../features/led_matrix) or [RGB Matrix](../features/rgb_matrix) feature with the `is31fl3218` 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/issi
SRC += is31fl3218-mono.c # For single-color
SRC += is31fl3218.c # For RGB
I2C_DRIVER_REQUIRED = yes
```
## Basic Configuration {#basic-configuration}
Add the following to your `config.h`:
|Define |Default |Description |
|----------------------------|-------------|---------------------------------------------------|
|`IS31FL3218_SDB_PIN` |*Not defined*|The GPIO pin connected to the driver's shutdown pin|
|`IS31FL3218_I2C_TIMEOUT` |`100` |The I²C timeout in milliseconds |
|`IS31FL3218_I2C_PERSISTENCE`|`0` |The number of times to retry I²C transmissions |
### I²C Addressing {#i2c-addressing}
The IS31FL3218's 7-bit I²C address is `0x54`, available as `IS31FL3218_I2C_ADDRESS`.
## ARM/ChibiOS Configuration {#arm-configuration}
Depending on the ChibiOS board configuration, you may need to [enable and configure I²C](i2c#arm-configuration) at the keyboard level.
## LED Mapping {#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 is31fl3218_led_t PROGMEM g_is31fl3218_leds[IS31FL3218_LED_COUNT] = {
/* R G B */
{OUT1, OUT2, OUT3},
// etc...
};
```
In this example, the red, green and blue channels for the first LED index 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:
```c
const is31fl3218_led_t PROGMEM g_is31fl3218_leds[IS31FL3218_LED_COUNT] = {
/* V */
{OUT1},
// etc...
};
```
## API {#api}
### `struct is31fl3218_led_t` {#api-is31fl3218-led-t}
Contains the PWM register addresses for a single RGB LED.
#### Members {#api-is31fl3218-led-t-members}
- `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 is31fl3218_init(void)` {#api-is31fl3218-init}
Initialize the LED driver. This function should be called first.
---
### `void is31fl3218_write_register(uint8_t reg, uint8_t data)` {#api-is31fl3218-write-register}
Set the value of the given register.
#### Arguments {#api-is31fl3218-write-register-arguments}
- `uint8_t reg`
The register address.
- `uint8_t data`
The value to set.
---
### `void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3218-set-color}
Set the color of a single LED (RGB driver only). This function does not immediately update the LEDs; call `is31fl3218_update_pwm_buffers()` after you are finished.
#### Arguments {#api-is31fl3218-set-color-arguments}
- `int index`
The LED index (ie. the index into the `g_is31fl3218_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 is31fl3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3218-set-color-all}
Set the color of all LEDs (RGB driver only).
#### Arguments {#api-is31fl3218-set-color-all-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 is31fl3218_set_value(int index, uint8_t value)` {#api-is31fl3218-set-value}
Set the brightness of a single LED (single-color driver only). This function does not immediately update the LEDs; call `is31fl3218_update_pwm_buffers()` after you are finished.
#### Arguments {#api-is31fl3218-set-value-arguments}
- `int index`
The LED index (ie. the index into the `g_is31fl3218_leds` array).
- `uint8_t value`
The brightness value to set.
---
### `void is31fl3218_set_value_all(uint8_t value)` {#api-is31fl3218-set-value-all}
Set the brightness of all LEDs (single-color driver only).
#### Arguments {#api-is31fl3218-set-value-all-arguments}
- `uint8_t value`
The brightness value to set.
---
### `void is31fl3218_set_led_control_register(uint8_t index, bool red, bool green, bool blue)` {#api-is31fl3218-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 `is31fl3218_update_led_control_registers()` after you are finished.
#### Arguments {#api-is31fl3218-set-led-control-register-rgb-arguments}
- `uint8_t index`
The LED index (ie. the index into the `g_is31fl3218_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 is31fl3218_set_led_control_register(uint8_t index, bool value)` {#api-is31fl3218-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 `is31fl3218_update_led_control_registers()` after you are finished.
#### Arguments {#api-is31fl3218-set-led-control-register-mono-arguments}
- `uint8_t index`
The LED index (ie. the index into the `g_is31fl3218_leds` array).
- `bool value`
Enable or disable the LED.
---
### `void is31fl3218_update_pwm_buffers(void)` {#api-is31fl3218-update-pwm-buffers}
Flush the PWM values to the LED driver.
---
### `void is31fl3218_update_led_control_registers(void)` {#api-is31fl3218-update-led-control-registers}
Flush the LED control register values to the LED driver.

228
docs/drivers/is31fl3236.md Normal file
View File

@ -0,0 +1,228 @@
# IS31FL3236 Driver {#is31fl3236-driver}
I²C LED driver by Lumissil. Supports a maximum of four drivers, each controlling up to 36 single-color LEDs, or 12 RGB LEDs.
[IS31FL3236 Datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3236_DS.pdf)
## Usage {#usage}
The IS31FL3236 driver code is automatically included if you are using the [LED Matrix](../features/led_matrix) or [RGB Matrix](../features/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`:
```make
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31fl3236-mono.c # For single-color
SRC += is31fl3236.c # For RGB
I2C_DRIVER_REQUIRED = yes
```
## Basic Configuration {#basic-configuration}
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 |
### I²C Addressing {#i2c-addressing}
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`|
## ARM/ChibiOS Configuration {#arm-configuration}
Depending on the ChibiOS board configuration, you may need to [enable and configure I²C](i2c#arm-configuration) at the keyboard level.
## LED Mapping {#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 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:
```c
const is31fl3236_led_t PROGMEM g_is31fl3236_leds[IS31FL3236_LED_COUNT] = {
/* Driver
| V */
{0, OUT1},
// etc...
};
```
## API {#api}
### `struct is31fl3236_led_t` {#api-is31fl3236-led-t}
Contains the PWM register addresses for a single RGB LED.
#### Members {#api-is31fl3236-led-t-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 is31fl3236_init(uint8_t index)` {#api-is31fl3236-init}
Initialize the LED driver. This function should be called first.
#### Arguments {#api-is31fl3236-init-arguments}
- `uint8_t index`
The driver index.
---
### `void is31fl3236_write_register(uint8_t index, uint8_t reg, uint8_t data)` {#api-is31fl3236-write-register}
Set the value of the given register.
#### Arguments {#api-is31fl3236-write-register-arguments}
- `uint8_t index`
The driver index.
- `uint8_t reg`
The register address.
- `uint8_t data`
The value to set.
---
### `void 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.
#### Arguments {#api-is31fl3236-set-color-arguments}
- `int index`
The LED index (ie. the index into the `g_is31fl3236_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 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).
#### Arguments {#api-is31fl3236-set-color-all-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 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.
#### Arguments {#api-is31fl3236-set-value-arguments}
- `int index`
The LED index (ie. the index into the `g_is31fl3236_leds` array).
- `uint8_t value`
The brightness value to set.
---
### `void is31fl3236_set_value_all(uint8_t value)` {#api-is31fl3236-set-value-all}
Set the brightness of all LEDs (single-color driver only).
#### Arguments {#api-is31fl3236-set-value-all-arguments}
- `uint8_t value`
The brightness value to set.
---
### `void 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.
#### Arguments {#api-is31fl3236-set-led-control-register-rgb-arguments}
- `uint8_t index`
The LED index (ie. the index into the `g_is31fl3236_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 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.
#### Arguments {#api-is31fl3236-set-led-control-register-mono-arguments}
- `uint8_t index`
The LED index (ie. the index into the `g_is31fl3236_leds` array).
- `bool value`
Enable or disable the LED.
---
### `void is31fl3236_update_pwm_buffers(uint8_t index)` {#api-is31fl3236-update-pwm-buffers}
Flush the PWM values to the LED driver.
#### Arguments {#api-is31fl3236-update-pwm-buffers-arguments}
- `uint8_t index`
The driver index.
---
### `void is31fl3236_update_led_control_registers(uint8_t index)` {#api-is31fl3236-update-led-control-registers}
Flush the LED control register values to the LED driver.
#### Arguments {#api-is31fl3236-update-led-control-registers-arguments}
- `uint8_t index`
The driver index.

300
docs/drivers/is31fl3729.md Normal file

File diff suppressed because it is too large Load Diff

254
docs/drivers/is31fl3731.md Normal file
View File

@ -0,0 +1,254 @@
# IS31FL3731 Driver {#is31fl3731-driver}
I²C Charlieplexed 16x9 LED matrix driver by Lumissil. Supports a maximum of four drivers, each controlling up to 144 single-color LEDs, or 48 RGB LEDs.
[IS31FL3731 Datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3731_DS.pdf)
## Usage {#usage}
The IS31FL3731 driver code is automatically included if you are using the [LED Matrix](../features/led_matrix) or [RGB Matrix](../features/rgb_matrix) feature with the `is31fl3731` 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/issi
SRC += is31fl3731-mono.c # For single-color
SRC += is31fl3731.c # For RGB
I2C_DRIVER_REQUIRED = yes
```
## Basic Configuration {#basic-configuration}
Add the following to your `config.h`:
|Define |Default |Description |
|----------------------------|-------------|----------------------------------------------------|
|`IS31FL3731_SDB_PIN` |*Not defined*|The GPIO pin connected to the drivers' shutdown pins|
|`IS31FL3731_I2C_TIMEOUT` |`100` |The I²C timeout in milliseconds |
|`IS31FL3731_I2C_PERSISTENCE`|`0` |The number of times to retry I²C transmissions |
|`IS31FL3731_I2C_ADDRESS_1` |*Not defined*|The I²C address of driver 0 |
|`IS31FL3731_I2C_ADDRESS_2` |*Not defined*|The I²C address of driver 1 |
|`IS31FL3731_I2C_ADDRESS_3` |*Not defined*|The I²C address of driver 2 |
|`IS31FL3731_I2C_ADDRESS_4` |*Not defined*|The I²C address of driver 3 |
|`IS31FL3731_DEGHOST` |*Not defined*|Enable ghost image prevention |
### I²C Addressing {#i2c-addressing}
The IS31FL3731 has four possible 7-bit I²C addresses, depending on how the `AD` pin is connected.
To configure this, set the `IS31FL3731_I2C_ADDRESS_n` defines to one of the following in your `config.h`, where *n* denotes the driver index:
|Define |Value |
|----------------------------|------|
|`IS31FL3731_I2C_ADDRESS_GND`|`0x74`|
|`IS31FL3731_I2C_ADDRESS_SCL`|`0x75`|
|`IS31FL3731_I2C_ADDRESS_SDA`|`0x76`|
|`IS31FL3731_I2C_ADDRESS_VCC`|`0x77`|
### De-Ghosting {#de-ghosting}
This setting enables the de-ghosting feature on the IS31FL3731. See this [Application Note](https://www.lumissil.com/assets/pdf/core/IS31FL3731_AN.pdf) (p. 15) for more information.
To enable, add the following to your `config.h`:
```c
#define IS31FL3731_DEGHOST
```
## ARM/ChibiOS Configuration {#arm-configuration}
Depending on the ChibiOS board configuration, you may need to [enable and configure I²C](i2c#arm-configuration) at the keyboard level.
## LED Mapping {#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 is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = {
/* Driver
* | R G B */
{0, C1_1, C1_2, C1_3},
// etc...
};
```
In this example, the red, green and blue channels for the first LED index on driver 0 all have their cathodes connected to the `CA1` pin, and their anodes on the `CA2`, `CA3` and `CA4` pins respectively.
For the single-color driver, the principle is the same, but there is only one channel:
```c
const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = {
/* Driver
* | V */
{0, C1_1},
// etc...
};
```
These values correspond to the register indices as shown in the datasheet on page 11, figure 8.
## API {#api}
### `struct is31fl3731_led_t` {#api-is31fl3731-led-t}
Contains the PWM register addresses for a single RGB LED.
#### Members {#api-is31fl3731-led-t-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 is31fl3731_init(uint8_t index)` {#api-is31fl3731-init}
Initialize the LED driver. This function should be called first.
#### Arguments {#api-is31fl3731-init-arguments}
- `uint8_t index`
The driver index.
---
### `void is31fl3731_write_register(uint8_t index, uint8_t reg, uint8_t data)` {#api-is31fl3731-write-register}
Set the value of the given register.
#### Arguments {#api-is31fl3731-write-register-arguments}
- `uint8_t index`
The driver index.
- `uint8_t reg`
The register address.
- `uint8_t data`
The value to set.
---
### `void is31fl3731_select_page(uint8_t index, uint8_t page)` {#api-is31fl3731-select-page}
Change the current page for configuring the LED driver.
#### Arguments {#api-is31fl3731-select-page-arguments}
- `uint8_t index`
The driver index.
- `uint8_t page`
The page number to select.
---
### `void is31fl3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3731-set-color}
Set the color of a single LED (RGB driver only). This function does not immediately update the LEDs; call `is31fl3731_update_pwm_buffers()` after you are finished.
#### Arguments {#api-is31fl3731-set-color-arguments}
- `int index`
The LED index (ie. the index into the `g_is31fl3731_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 is31fl3731_set_color_all(uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3731-set-color-all}
Set the color of all LEDs (RGB driver only).
#### Arguments {#api-is31fl3731-set-color-all-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 is31fl3731_set_value(int index, uint8_t value)` {#api-is31fl3731-set-value}
Set the brightness of a single LED (single-color driver only). This function does not immediately update the LEDs; call `is31fl3731_update_pwm_buffers()` after you are finished.
#### Arguments {#api-is31fl3731-set-value-arguments}
- `int index`
The LED index (ie. the index into the `g_is31fl3731_leds` array).
- `uint8_t value`
The brightness value to set.
---
### `void is31fl3731_set_value_all(uint8_t value)` {#api-is31fl3731-set-value-all}
Set the brightness of all LEDs (single-color driver only).
#### Arguments {#api-is31fl3731-set-value-all-arguments}
- `uint8_t value`
The brightness value to set.
---
### `void is31fl3731_set_led_control_register(uint8_t index, bool red, bool green, bool blue)` {#api-is31fl3731-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 `is31fl3731_update_led_control_registers()` after you are finished.
#### Arguments {#api-is31fl3731-set-led-control-register-rgb-arguments}
- `uint8_t index`
The LED index (ie. the index into the `g_is31fl3731_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 is31fl3731_set_led_control_register(uint8_t index, bool value)` {#api-is31fl3731-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 `is31fl3731_update_led_control_registers()` after you are finished.
#### Arguments {#api-is31fl3731-set-led-control-register-mono-arguments}
- `uint8_t index`
The LED index (ie. the index into the `g_is31fl3731_leds` array).
- `bool value`
Enable or disable the LED.
---
### `void is31fl3731_update_pwm_buffers(uint8_t index)` {#api-is31fl3731-update-pwm-buffers}
Flush the PWM values to the LED driver.
#### Arguments {#api-is31fl3731-update-pwm-buffers-arguments}
- `uint8_t index`
The driver index.
---
### `void is31fl3731_update_led_control_registers(uint8_t index)` {#api-is31fl3731-update-led-control-registers}
Flush the LED control register values to the LED driver.
#### Arguments {#api-is31fl3731-update-led-control-registers-arguments}
- `uint8_t index`
The driver index.

338
docs/drivers/is31fl3733.md Normal file

File diff suppressed because it is too large Load Diff

322
docs/drivers/is31fl3736.md Normal file

File diff suppressed because it is too large Load Diff

310
docs/drivers/is31fl3737.md Normal file

File diff suppressed because it is too large Load Diff

310
docs/drivers/is31fl3741.md Normal file

File diff suppressed because it is too large Load Diff

310
docs/drivers/is31fl3742a.md Normal file

File diff suppressed because it is too large Load Diff

320
docs/drivers/is31fl3743a.md Normal file

File diff suppressed because it is too large Load Diff

320
docs/drivers/is31fl3745.md Normal file

File diff suppressed because it is too large Load Diff

327
docs/drivers/is31fl3746a.md Normal file

File diff suppressed because it is too large Load Diff

245
docs/drivers/snled27351.md Normal file
View File

@ -0,0 +1,245 @@
# SNLED27351 Driver {#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](https://www.sonix.com.tw/files/1/D235860C0C037C28E050007F01001CBE)
## Usage {#usage}
The SNLED27351 driver code is automatically included if you are using the [LED Matrix](../features/led_matrix) or [RGB Matrix](../features/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
SRC += snled27351-mono.c # For single-color
SRC += snled27351.c # For RGB
I2C_DRIVER_REQUIRED = yes
```
## Basic Configuration {#basic-configuration}
Add the following to your `config.h`:
|Define |Default |Description |
|----------------------------|-------------|----------------------------------------------------|
|`SNLED27351_SDB_PIN` |*Not defined*|The GPIO pin connected to the drivers' shutdown pins|
|`SNLED27351_I2C_TIMEOUT` |`100` |The I²C timeout in milliseconds |
|`SNLED27351_I2C_PERSISTENCE`|`0` |The number of times to retry I²C transmissions |
|`SNLED27351_I2C_ADDRESS_1` |*Not defined*|The I²C address of driver 0 |
|`SNLED27351_I2C_ADDRESS_2` |*Not defined*|The I²C address of driver 1 |
|`SNLED27351_I2C_ADDRESS_3` |*Not defined*|The I²C address of driver 2 |
|`SNLED27351_I2C_ADDRESS_4` |*Not defined*|The I²C address of driver 3 |
### I²C Addressing {#i2c-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:
|Define |Value |
|------------------------------|------|
|`SNLED27351_I2C_ADDRESS_GND` |`0x74`|
|`SNLED27351_I2C_ADDRESS_SCL` |`0x75`|
|`SNLED27351_I2C_ADDRESS_SDA` |`0x76`|
|`SNLED27351_I2C_ADDRESS_VDDIO`|`0x77`|
## ARM/ChibiOS Configuration {#arm-configuration}
Depending on the ChibiOS board configuration, you may need to [enable and configure I²C](i2c#arm-configuration) at the keyboard level.
## LED Mapping {#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] = {
/* Driver
* | R G B */
{0, CB1_CA1, CB1_CA2, CB1_CA3},
// etc...
};
```
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] = {
/* Driver
* | V */
{0, CB1_CA1},
// etc...
};
```
These values correspond to the register indices as shown in the datasheet on page 13.
## API {#api}
### `struct snled27351_led_t` {#api-snled27351-led-t}
Contains the PWM register addresses for a single RGB LED.
#### Members {#api-snled27351-led-t-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 snled27351_init(uint8_t index)` {#api-snled27351-init}
Initialize the LED driver. This function should be called first.
#### Arguments {#api-snled27351-init-arguments}
- `uint8_t index`
The driver index.
---
### `void snled27351_write_register(uint8_t index, uint8_t reg, uint8_t data)` {#api-snled27351-write-register}
Set the value of the given register.
#### Arguments {#api-snled27351-write-register-arguments}
- `uint8_t index`
The driver index.
- `uint8_t reg`
The register address.
- `uint8_t data`
The value to set.
---
### `void snled27351_select_page(uint8_t index, uint8_t page)` {#api-snled27351-select-page}
Change the current page for configuring the LED driver.
#### Arguments {#api-snled27351-select-page-arguments}
- `uint8_t index`
The driver index.
- `uint8_t page`
The page number to select.
---
### `void snled27351_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)` {#api-snled27351-set-color}
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 {#api-snled27351-set-color-arguments}
- `int index`
The LED index (ie. the index into the `g_snled27351_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 snled27351_set_color_all(uint8_t red, uint8_t green, uint8_t blue)` {#api-snled27351-set-color-all}
Set the color of all LEDs (RGB driver only).
#### Arguments {#api-snled27351-set-color-all-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 snled27351_set_value(int index, uint8_t value)` {#api-snled27351-set-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 {#api-snled27351-set-value-arguments}
- `int index`
The LED index (ie. the index into the `g_snled27351_leds` array).
- `uint8_t value`
The brightness value to set.
---
### `void snled27351_set_value_all(uint8_t value)` {#api-snled27351-set-value-all}
Set the brightness of all LEDs (single-color driver only).
#### Arguments {#api-snled27351-set-value-all-arguments}
- `uint8_t value`
The brightness value to set.
---
### `void snled27351_set_led_control_register(uint8_t index, bool red, bool green, bool blue)` {#api-snled27351-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 `snled27351_update_led_control_registers()` after you are finished.
#### Arguments {#api-snled27351-set-led-control-register-rgb-arguments}
- `uint8_t index`
The LED index (ie. the index into the `g_snled27351_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 snled27351_set_led_control_register(uint8_t index, bool value)` {#api-snled27351-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 `snled27351_update_led_control_registers()` after you are finished.
#### Arguments {#api-snled27351-set-led-control-register-mono-arguments}
- `uint8_t index`
The LED index (ie. the index into the `g_snled27351_leds` array).
- `bool value`
Enable or disable the LED.
---
### `void snled27351_update_pwm_buffers(uint8_t index)` {#api-snled27351-update-pwm-buffers}
Flush the PWM values to the LED driver.
#### Arguments {#api-snled27351-update-pwm-buffers-arguments}
- `uint8_t index`
The driver index.
---
### `void snled27351_update_led_control_registers(uint8_t index)` {#api-snled27351-update-led-control-registers}
Flush the LED control register values to the LED driver.
#### Arguments {#api-snled27351-update-led-control-registers-arguments}
- `uint8_t index`
The driver index.

View File

@ -4,176 +4,32 @@ This feature allows you to use LED matrices driven by external drivers. It hooks
If you want to use RGB LED's you should use the [RGB Matrix Subsystem](rgb_matrix) instead.
## Driver configuration {#driver-configuration}
---
### IS31FL3731 {#is31fl3731}
## Driver Configuration {#driver-configuration}
There is basic support for addressable LED matrix lighting with the I2C IS31FL3731 LED controller. To enable it, add this to your `rules.mk`:
LED Matrix is an abstraction layer on top of an underlying LED driver API. The list of supported LED drivers is below; see the respective documentation for information on how to configure the driver.
|Driver |Max LEDs|
|-------------------------------------|--------|
|[IS31FL3218](../drivers/is31fl3218) |18 |
|[IS31FL3236](../drivers/is31fl3236) |36 |
|[IS31FL3729](../drivers/is31fl3729) |135 |
|[IS31FL3731](../drivers/is31fl3731) |144 |
|[IS31FL3733](../drivers/is31fl3733) |192 |
|[IS31FL3736](../drivers/is31fl3736) |96 |
|[IS31FL3737](../drivers/is31fl3737) |144 |
|[IS31FL3741](../drivers/is31fl3741) |351 |
|[IS31FL3742A](../drivers/is31fl3742a)|180 |
|[IS31FL3743A](../drivers/is31fl3743a)|198 |
|[IS31FL3745](../drivers/is31fl3745) |144 |
|[IS31FL3746A](../drivers/is31fl3746a)|72 |
|[SNLED27351](../drivers/snled27351) |192 |
To assign the LED Matrix driver, add the following to your `rules.mk`, for example:
```make
LED_MATRIX_ENABLE = yes
LED_MATRIX_DRIVER = is31fl3731
LED_MATRIX_DRIVER = is31fl3218
```
You can use between 1 and 4 IS31FL3731 IC's. Do not specify `LED_DRIVER_ADDR_<N>` defines for IC's that are not present on your keyboard. You can define the following items in `config.h`:
| Variable | Description | Default |
|----------|-------------|---------|
| `IS31FL3731_I2C_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
| `IS31FL3731_I2C_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
| `LED_MATRIX_LED_COUNT` | (Required) How many LED lights are present across all drivers | |
| `IS31FL3731_I2C_ADDRESS_1` | (Required) Address for the first LED driver | |
| `IS31FL3731_I2C_ADDRESS_2` | (Optional) Address for the second LED driver | |
| `IS31FL3731_I2C_ADDRESS_3` | (Optional) Address for the third LED driver | |
| `IS31FL3731_I2C_ADDRESS_4` | (Optional) Address for the fourth LED driver | |
Here is an example using 2 drivers.
```c
// This is a 7-bit address, that gets left-shifted and bit 0
// set to 0 for write, 1 for read (as per I2C protocol)
// The address will vary depending on your wiring:
// 00 AD <-> GND
// 01 AD <-> SCL
// 10 AD <-> SDA
// 11 AD <-> VCC
// ADDR represents A1:A0 of the 7-bit address.
// The result is: 0b11101(ADDR)
#define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND
#define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA
#define LED_DRIVER_1_LED_TOTAL 25
#define LED_DRIVER_2_LED_TOTAL 24
#define LED_MATRIX_LED_COUNT (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL)
```
::: warning
Note the parentheses, this is so when `LED_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL)` will give very different results than `rand() % LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL`.
:::
For split keyboards using `LED_MATRIX_SPLIT` with an LED driver, you can either have the same driver address or different driver addresses. If using different addresses, use `IS31FL3731_I2C_ADDRESS_1` for one and `IS31FL3731_I2C_ADDRESS_2` for the other one. Then, in `g_is31fl3731_leds`, fill out the correct driver index (0 or 1). If using one address, use `IS31FL3731_I2C_ADDRESS_1` for both, and use index 0 for `g_is31fl3731_leds`.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | LED address
* | | */
{ 0, C1_1 },
{ 0, C1_15 },
// ...
}
```
Where `Cx_y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3731.pdf) and the header file `drivers/led/issi/is31fl3731-mono.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3` ).
---
### IS31FLCOMMON {#is31flcommon}
There is basic support for addressable LED matrix lighting with a selection of I2C ISSI Lumissil LED controllers through a shared common driver. To enable it, add this to your `rules.mk`:
```makefile
LED_MATRIX_ENABLE = yes
LED_MATRIX_DRIVER = <driver name>
```
Where `<driver name>` is the applicable LED driver chip as below
| Driver Name | Data Sheet | Capability |
|-------------|------------|------------|
| `IS31FL3742A` | [datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3742A_DS.pdf) | 180 LED, 30x6 Matrix |
| `IS31FL3743A` | [datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3743A_DS.pdf) | 198 LED, 18x11 Matrix |
| `IS31FL3745` | [datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3745_DS.pdf) | 144 LED, 18x8 Matrix |
| `IS31FL3746A` | [datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3746A_DS.pdf) | 72 LED, 18x4 Matrix |
You can use between 1 and 4 IC's. Do not specify `DRIVER_ADDR_<N>` define for IC's if not present on your keyboard. The `DRIVER_ADDR_1` default assumes that all Address pins on the controller have been connected to GND. Drivers that have SYNC functionality have the default settings to disable if 1 driver. If more than 1 drivers then `DRIVER_ADDR_1` will be set to Master and the remaiing ones set to Slave.
Configure the hardware via your `config.h`:
| Variable | Description | Default |
|----------|-------------|---------|
| `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
| `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
| `LED_MATRIX_LED_COUNT` | (Required) How many LED lights are present across all drivers | |
| `DRIVER_ADDR_1` | (Optional) Address for the first LED driver | |
| `DRIVER_ADDR_<N>` | (Required) Address for the additional LED drivers | |
| `ISSI_SSR_<N>` | (Optional) Configuration for the Spread Spectrum Register | |
| `ISSI_CONFIGURATION` | (Optional) Configuration for the Configuration Register | |
| `ISSI_GLOBALCURRENT` | (Optional) Configuration for the Global Current Register | 0xFF |
| `ISSI_PULLDOWNUP` | (Optional) Configuration for the Pull Up & Pull Down Register | |
| `ISSI_TEMP` | (Optional) Configuration for the Tempature Register | |
| `ISSI_PWM_ENABLE` | (Optional) Configuration for the PWM Enable Register | |
| `ISSI_PWM_SET` | (Optional) Configuration for the PWM Setting Register | |
| `ISSI_SCAL_LED ` | (Optional) Configuration for the LEDs Scaling Registers | 0xFF |
| `ISSI_MANUAL_SCALING` | (Optional) If you wish to configure the Scaling Registers manually | |
Defaults
| Variable | IS31FL3742A | IS31FL3743A | IS31FL3745 | IS31FL3746 |
|----------|-------------|-------------|------------|------------|
| `DRIVER_ADDR_1` | 0b0110000 | 0b0100000 | 0b0100000 | 0b1100000 |
| `ISSI_SSR_1` | 0x00 | 0x00 / 0x60 | 0x00 / 0xC0 | 0x00 |
| `ISSI_SSR_<2-4>` | 0x00 | 0x40 | 0x80 | 0x00 |
| `ISSI_CONFIGURATION` | 0x31 | 0x01 | 0x31 | 0x01 |
| `ISSI_PULLDOWNUP` | 0x55 | 0x33 | 0x33 | 0x33 |
| `ISSI_TEMP` | N/A | 0x00 | 0x00 | 0x00 |
| `ISSI_PWM_ENABLE` | N/A | N/A | N/A | 0x00 |
| `ISSI_PWM_SET` | 0x00 | N/A | N/A | 0x00 |
Here is an example using 2 drivers.
```c
#define DRIVER_ADDR_2 0b0100001
#define DRIVER_1_LED_TOTAL 66
#define DRIVER_2_LED_TOTAL 42
#define LED_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
```
::: warning
Note the parentheses, this is so when `LED_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
:::
Currently only 4 drivers are supported, but it would be trivial to support for more. Note that using a combination of different drivers is not supported. All drivers must be of the same model.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | LED address
* | | */
{ 0, SW1_CS1 },
{ 0, SW1_CS2 },
// ...
}
```
Where `CSx_SWx` is the location of the LED in the matrix defined by the datasheet. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3` for now).
`ISSI_MANUAL_SCALING` is used to override the Scaling for individual LED's. By default they will be set as per `ISSI_SCAL_LED`. In `config.h` set how many LED's you want to manually set scaling for.
Eg `#define ISSI_MANUAL_SCALING 3`
Then Define the array listing all the LEDs you want to override in your `<keyboard>.c`:
```c
const is31_led PROGMEM g_is31_scaling[ISSI_MANUAL_SCALING] = {
/* LED Index
* | Scaling
* | | */
{5, 120},
{9, 120},
....
}
```
Where LED Index is the position of the LED in the `g_is31_leds` array. The `scaling` value between 0 and 255 to be written to the Scaling Register.
---
## Common Configuration {#common-configuration}
From this point forward the configuration is the same for all the drivers. The `led_config_t` struct provides a key electrical matrix to led index lookup table, what the physical position of each LED is on the board, and what type of key or usage the LED if the LED represents. Here is a brief example:

File diff suppressed because it is too large Load Diff