diff options
| author | Drashna Jaelre <drashna@live.com> | 2021-09-18 00:28:57 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-18 17:28:57 +1000 |
| commit | 7c10d00ca6ec07f169d6f5e3c83bd7449a578ac0 (patch) | |
| tree | 6761699b048ced82e5ccf8a09129bb26e493746b /platforms/chibios/drivers/ws2812_spi.c | |
| parent | 07600939786186277e2db53dd42e0e35ce1a04f6 (diff) | |
| download | qmk_firmware-7c10d00ca6ec07f169d6f5e3c83bd7449a578ac0.tar.gz qmk_firmware-7c10d00ca6ec07f169d6f5e3c83bd7449a578ac0.zip | |
Add RGBW support to PWM and SPI drivers for ChibiOS (#14327)
* Add RGBW support to PWM and SPI drivers for ChibiOS
* Apply suggestions from code review
Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'platforms/chibios/drivers/ws2812_spi.c')
| -rw-r--r-- | platforms/chibios/drivers/ws2812_spi.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/platforms/chibios/drivers/ws2812_spi.c b/platforms/chibios/drivers/ws2812_spi.c index 589bf85c3..62722f466 100644 --- a/platforms/chibios/drivers/ws2812_spi.c +++ b/platforms/chibios/drivers/ws2812_spi.c | |||
| @@ -3,10 +3,6 @@ | |||
| 3 | 3 | ||
| 4 | /* Adapted from https://github.com/gamazeps/ws2812b-chibios-SPIDMA/ */ | 4 | /* Adapted from https://github.com/gamazeps/ws2812b-chibios-SPIDMA/ */ |
| 5 | 5 | ||
| 6 | #ifdef RGBW | ||
| 7 | # error "RGBW not supported" | ||
| 8 | #endif | ||
| 9 | |||
| 10 | // Define the spi your LEDs are plugged to here | 6 | // Define the spi your LEDs are plugged to here |
| 11 | #ifndef WS2812_SPI | 7 | #ifndef WS2812_SPI |
| 12 | # define WS2812_SPI SPID1 | 8 | # define WS2812_SPI SPID1 |
| @@ -74,8 +70,12 @@ | |||
| 74 | #endif | 70 | #endif |
| 75 | 71 | ||
| 76 | #define BYTES_FOR_LED_BYTE 4 | 72 | #define BYTES_FOR_LED_BYTE 4 |
| 77 | #define NB_COLORS 3 | 73 | #ifdef RGBW |
| 78 | #define BYTES_FOR_LED (BYTES_FOR_LED_BYTE * NB_COLORS) | 74 | # define WS2812_CHANNELS 4 |
| 75 | #else | ||
| 76 | # define WS2812_CHANNELS 3 | ||
| 77 | #endif | ||
| 78 | #define BYTES_FOR_LED (BYTES_FOR_LED_BYTE * WS2812_CHANNELS) | ||
| 79 | #define DATA_SIZE (BYTES_FOR_LED * RGBLED_NUM) | 79 | #define DATA_SIZE (BYTES_FOR_LED * RGBLED_NUM) |
| 80 | #define RESET_SIZE (1000 * WS2812_TRST_US / (2 * 1250)) | 80 | #define RESET_SIZE (1000 * WS2812_TRST_US / (2 * 1250)) |
| 81 | #define PREAMBLE_SIZE 4 | 81 | #define PREAMBLE_SIZE 4 |
| @@ -116,6 +116,9 @@ static void set_led_color_rgb(LED_TYPE color, int pos) { | |||
| 116 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE + j] = get_protocol_eq(color.g, j); | 116 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE + j] = get_protocol_eq(color.g, j); |
| 117 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 2 + j] = get_protocol_eq(color.r, j); | 117 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 2 + j] = get_protocol_eq(color.r, j); |
| 118 | #endif | 118 | #endif |
| 119 | #ifdef RGBW | ||
| 120 | for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 4 + j] = get_protocol_eq(color.w, j); | ||
| 121 | #endif | ||
| 119 | } | 122 | } |
| 120 | 123 | ||
| 121 | void ws2812_init(void) { | 124 | void ws2812_init(void) { |
