import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.DyMmIvSC.js"; const __pageData = JSON.parse('{"title":"AW20216S Driver","description":"","frontmatter":{},"headers":[],"relativePath":"drivers/aw20216s.md","filePath":"drivers/aw20216s.md"}'); const _sfc_main = { name: "drivers/aw20216s.md" }; const _hoisted_1 = /* @__PURE__ */ createStaticVNode('
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.
The AW20216S driver code is automatically included if you are using the 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
:
COMMON_VPATH += $(DRIVER_PATH)/led\nSRC += aw20216s.c\nSPI_DRIVER_REQUIRED = yes
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 |
This setting controls the current sunk by the CSx
pins, from 0 to 255. To adjust it, add the following to your config.h
:
#define AW20216S_GLOBAL_CURRENT_MAX 150
Depending on the ChibiOS board configuration, you may need to enable and configure SPI 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 <keyboardname>.c
:
const aw20216s_led_t PROGMEM g_aw20216s_leds[AW20216S_LED_COUNT] = {\n/* Driver\n * | R G B */\n {0, SW1_CS1, SW1_CS2, SW1_CS3},\n // etc...\n};
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.
struct aw20216s_led_t
Contains the PWM register addresses for a single RGB LED.
uint8_t driver
uint8_t r
uint8_t g
uint8_t b
void aw20216s_init(pin_t cs_pin)
Initialize the LED driver. This function should be called first.
pin_t cs_pin
void aw20216s_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)
Set the color of a single LED. This function does not immediately update the LEDs; call aw20216s_update_pwm_buffers()
after you are finished.
int index
g_aw20216s_leds
array).uint8_t red
uint8_t green
uint8_t blue
void aw20216s_set_color_all(uint8_t red, uint8_t green, uint8_t blue)
Set the color of all LEDs.
uint8_t red
uint8_t green
uint8_t blue
void aw20216s_update_pwm_buffers(pin_t cs_pin, uint8_t index)
Flush the PWM values to the LED driver.
pin_t cs_pin
uint8_t index