WS2812 API rework (#24364)
* Begin WS2812 API rework * Move RGBW conversion, clean up color.h, fix RGBW for AVR bitbang * Formatting & update PS2AVRGB I2C driver (untested) * Tested ARM bitbang RGB+RGBW * Tested ARM SPI RGB - RGBW not working * Tested ARM PWM RGB+RGBW * Tested RP2040 PIO driver RGB+RGBW * Update RGBLight * Formatting * Fix BM60HSRGB rev2 * Fix oddforge/vea * Fix 1k and XD002 RGBLite * Fix model_m/mschwingen * Fix handwired/promethium * Rename `WS2812_LED_TOTAL` for BM60HSRGB * Fix work_louder boards * Fix dawn60 * Fix rgbkb/pan * Fix neson_design/700e and n6 * Fix ergodox_ez/shine * ergodox_ez/shine: invert indices for left half * Fix matrix/abelx * Fix matrix/m20add * Remove custom rgblight driver for matrix/noah - should be done with lighting layers * Fix LED indexes for RGBLight split * Rename `convert_rgb_to_rgbw()` to `ws2812_rgb_to_rgbw()` * Update WS2812 API docs * `ergodox_ez/shine`: simplify LED index calculation * LED/RGB Matrix: Add weak function for LED index resolution * Bandaid fix for RGB Matrix splits not using WS2812 * `steelseries/prime_plus`: redo custom RGBLight driver * Update keyboards/steelseries/prime_plus/rgblight_custom.c Co-authored-by: Dasky <32983009+daskygit@users.noreply.github.com> --------- Co-authored-by: Dasky <32983009+daskygit@users.noreply.github.com>
This commit is contained in:
parent
43e82ed5c7
commit
208ebf54a9
61 changed files with 638 additions and 661 deletions
|
|
@ -932,7 +932,7 @@ ifeq ($(strip $(WS2812_DRIVER_REQUIRED)), yes)
|
|||
|
||||
OPT_DEFS += -DWS2812_$(strip $(shell echo $(WS2812_DRIVER) | tr '[:lower:]' '[:upper:]'))
|
||||
|
||||
SRC += ws2812_$(strip $(WS2812_DRIVER)).c
|
||||
SRC += ws2812.c ws2812_$(strip $(WS2812_DRIVER)).c
|
||||
|
||||
ifeq ($(strip $(PLATFORM)), CHIBIOS)
|
||||
ifeq ($(strip $(WS2812_DRIVER)), pwm)
|
||||
|
|
|
|||
|
|
@ -241,13 +241,44 @@ Using a complementary timer output (`TIMx_CHyN`) is possible only for advanced-c
|
|||
|
||||
## API {#api}
|
||||
|
||||
### `void ws2812_setleds(rgb_led_t *ledarray, uint16_t number_of_leds)` {#api-ws2812-setleds}
|
||||
### `void ws2812_init(void)` {#api-ws2812-init}
|
||||
|
||||
Send RGB data to the WS2812 LED chain.
|
||||
Initialize the LED driver. This function should be called first.
|
||||
|
||||
#### Arguments {#api-ws2812-setleds-arguments}
|
||||
---
|
||||
|
||||
- `rgb_led_t *ledarray`
|
||||
A pointer to the LED array.
|
||||
- `uint16_t number_of_leds`
|
||||
The length of the LED array.
|
||||
### `void ws2812_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)` {#api-ws2812-set-color}
|
||||
|
||||
Set the color of a single LED. This function does not immediately update the LEDs; call `ws2812_flush()` after you are finished.
|
||||
|
||||
#### Arguments {#api-ws2812-set-color-arguments}
|
||||
|
||||
- `int index`
|
||||
The LED index in the WS2812 chain.
|
||||
- `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 ws812_set_color_all(uint8_t red, uint8_t green, uint8_t blue)` {#api-ws2812-set-color-all}
|
||||
|
||||
Set the color of all LEDs.
|
||||
|
||||
#### Arguments {#api-ws2812-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 ws2812_flush(void)` {#api-ws2812-flush}
|
||||
|
||||
Flush the PWM values to the LED chain.
|
||||
|
|
|
|||
15
drivers/ws2812.c
Normal file
15
drivers/ws2812.c
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2024 QMK
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "ws2812.h"
|
||||
|
||||
#if defined(WS2812_RGBW)
|
||||
void ws2812_rgb_to_rgbw(ws2812_led_t *led) {
|
||||
// Determine lowest value in all three colors, put that into
|
||||
// the white channel and then shift all colors by that amount
|
||||
led->w = MIN(led->r, MIN(led->g, led->b));
|
||||
led->r -= led->w;
|
||||
led->g -= led->w;
|
||||
led->b -= led->w;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "quantum/color.h"
|
||||
#include "util.h"
|
||||
|
||||
/*
|
||||
* The WS2812 datasheets define T1H 900ns, T0H 350ns, T1L 350ns, T0L 900ns. Hence, by default, these
|
||||
|
|
@ -62,17 +62,36 @@
|
|||
# define WS2812_LED_COUNT RGB_MATRIX_LED_COUNT
|
||||
#endif
|
||||
|
||||
void ws2812_init(void);
|
||||
#define WS2812_BYTE_ORDER_RGB 0
|
||||
#define WS2812_BYTE_ORDER_GRB 1
|
||||
#define WS2812_BYTE_ORDER_BGR 2
|
||||
|
||||
/* User Interface
|
||||
*
|
||||
* Input:
|
||||
* ledarray: An array of GRB data describing the LED colors
|
||||
* number_of_leds: The number of LEDs to write
|
||||
*
|
||||
* The functions will perform the following actions:
|
||||
* - Set the data-out pin as output
|
||||
* - Send out the LED data
|
||||
* - Wait 50us to reset the LEDs
|
||||
*/
|
||||
void ws2812_setleds(rgb_led_t *ledarray, uint16_t number_of_leds);
|
||||
#ifndef WS2812_BYTE_ORDER
|
||||
# define WS2812_BYTE_ORDER WS2812_BYTE_ORDER_GRB
|
||||
#endif
|
||||
|
||||
typedef struct PACKED ws2812_led_t {
|
||||
#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB)
|
||||
uint8_t g;
|
||||
uint8_t r;
|
||||
uint8_t b;
|
||||
#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_RGB)
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_BGR)
|
||||
uint8_t b;
|
||||
uint8_t g;
|
||||
uint8_t r;
|
||||
#endif
|
||||
#ifdef WS2812_RGBW
|
||||
uint8_t w;
|
||||
#endif
|
||||
} ws2812_led_t;
|
||||
|
||||
void ws2812_init(void);
|
||||
void ws2812_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void ws2812_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void ws2812_flush(void);
|
||||
|
||||
void ws2812_rgb_to_rgbw(ws2812_led_t *led);
|
||||
|
|
|
|||
|
|
@ -32,3 +32,5 @@
|
|||
#define USB_INTR_ENABLE_BIT PCIE
|
||||
#define USB_INTR_PENDING_BIT PCIF
|
||||
#define USB_INTR_VECTOR SIG_PIN_CHANGE
|
||||
|
||||
#define WS2812_LED_COUNT 1
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ static inline void rgblite_init(void) {
|
|||
}
|
||||
|
||||
static inline void rgblite_setrgb(RGB rgb) {
|
||||
rgb_led_t leds[RGBLIGHT_LED_COUNT] = {{.r = rgb.r, .g = rgb.g, .b = rgb.b}};
|
||||
ws2812_setleds(leds, RGBLIGHT_LED_COUNT);
|
||||
ws2812_set_color_all(rgb.r, rgb.g, rgb.b);
|
||||
ws2812_flush();
|
||||
}
|
||||
|
||||
static void rgblite_increase_hue(void) {
|
||||
|
|
|
|||
|
|
@ -33,8 +33,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#ifdef ERGODOX_LED_30
|
||||
// If using 30 LEDs, then define that many
|
||||
# define WS2812_LED_COUNT 30
|
||||
# define RGBLIGHT_LED_COUNT 30 // Number of LEDs
|
||||
#else
|
||||
// If not, then only define 15
|
||||
# define WS2812_LED_COUNT 15
|
||||
# define RGBLIGHT_LED_COUNT 15 // Number of LEDs
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,47 +21,55 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "ergodox_ez.h"
|
||||
#include "ws2812.h"
|
||||
|
||||
void setleds_custom(rgb_led_t *led, uint16_t led_num) {
|
||||
uint16_t length = 0;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
# ifdef WS2812_RGBW
|
||||
int bytes_per_led = 4;
|
||||
# else
|
||||
int bytes_per_led = 3;
|
||||
# endif
|
||||
# if defined(ERGODOX_LED_30)
|
||||
// prevent right-half code from trying to bitbang all 30
|
||||
// so with 30 LEDs, we count from 29 to 15 here, and the
|
||||
// other half does 0 to 14.
|
||||
uint8_t half_led_num = RGBLIGHT_LED_COUNT / 2;
|
||||
length = half_led_num * bytes_per_led;
|
||||
uint8_t data[length];
|
||||
for (i = half_led_num + half_led_num - 1; i >= half_led_num; --i)
|
||||
# elif defined(ERGODOX_LED_15_MIRROR)
|
||||
length = led_num * bytes_per_led;
|
||||
uint8_t data[length];
|
||||
for (i = 0; i < led_num; ++i)
|
||||
# else // ERGDOX_LED_15 non-mirrored
|
||||
length = led_num * bytes_per_led;
|
||||
uint8_t data[length];
|
||||
for (i = led_num - 1; i >= 0; --i)
|
||||
# endif
|
||||
{
|
||||
uint8_t *data_byte = (uint8_t *)(led + i);
|
||||
data[j++] = data_byte[0];
|
||||
data[j++] = data_byte[1];
|
||||
data[j++] = data_byte[2];
|
||||
#ifdef WS2812_RGBW
|
||||
data[j++] = data_byte[3];
|
||||
#endif
|
||||
}
|
||||
i2c_transmit(0x84, data, sizeof(data), ERGODOX_EZ_I2C_TIMEOUT);
|
||||
#define WS2812_I2C_ADDRESS_LEFT 0x84
|
||||
|
||||
ws2812_setleds(led, led_num);
|
||||
#if defined(ERGODOX_LED_30)
|
||||
# define WS2812_LED_COUNT_LEFT (RGBLIGHT_LED_COUNT / 2)
|
||||
ws2812_led_t ws2812_leds_left[WS2812_LED_COUNT_LEFT];
|
||||
#else
|
||||
# define WS2812_LED_COUNT_LEFT RGBLIGHT_LED_COUNT
|
||||
ws2812_led_t ws2812_leds_left[WS2812_LED_COUNT_LEFT];
|
||||
#endif
|
||||
|
||||
void set_color_left(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
ws2812_leds_left[index].r = red;
|
||||
ws2812_leds_left[index].g = green;
|
||||
ws2812_leds_left[index].b = blue;
|
||||
#if defined(WS2812_RGBW)
|
||||
ws2812_rgb_to_rgbw(&ws2812_leds_left[index]);
|
||||
#endif
|
||||
}
|
||||
|
||||
void set_color_custom(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
#if defined(ERGODOX_LED_30)
|
||||
if (index < WS2812_LED_COUNT_LEFT) {
|
||||
ws2812_set_color(index, red, green, blue);
|
||||
} else {
|
||||
set_color_left(RGBLIGHT_LED_COUNT - index - 1, red, green, blue);
|
||||
}
|
||||
#elif defined(ERGODOX_LED_15_MIRROR)
|
||||
ws2812_set_color(index, red, green, blue);
|
||||
set_color_left(index, red, green, blue);
|
||||
#else
|
||||
ws2812_set_color(index, red, green, blue);
|
||||
set_color_left(WS2812_LED_COUNT_LEFT - index - 1, red, green, blue);
|
||||
#endif
|
||||
}
|
||||
|
||||
void set_color_all_custom(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
for (int i = 0; i < RGBLIGHT_LED_COUNT; i++) {
|
||||
set_color_custom(i, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
void flush_custom(void) {
|
||||
i2c_transmit(WS2812_I2C_ADDRESS_LEFT, (uint8_t *)ws2812_leds_left, sizeof(ws2812_leds_left), ERGODOX_EZ_I2C_TIMEOUT);
|
||||
ws2812_flush();
|
||||
}
|
||||
|
||||
const rgblight_driver_t rgblight_driver = {
|
||||
.init = ws2812_init,
|
||||
.setleds = setleds_custom,
|
||||
.init = ws2812_init,
|
||||
.set_color = set_color_custom,
|
||||
.set_color_all = set_color_all_custom,
|
||||
.flush = flush_custom,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ enum led_sequence {
|
|||
};
|
||||
|
||||
# define RGBSPS_NUM LED_TOTAL
|
||||
# define WS2812_LED_COUNT RGBSPS_NUM
|
||||
#endif
|
||||
|
||||
/* PS/2 mouse */
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
#include "ws2812.h"
|
||||
#include "rgbsps.h"
|
||||
|
||||
rgb_led_t led[RGBSPS_NUM];
|
||||
|
||||
void keyboard_pre_init_kb(void) {
|
||||
ws2812_init();
|
||||
|
||||
|
|
@ -11,9 +9,7 @@ void keyboard_pre_init_kb(void) {
|
|||
}
|
||||
|
||||
void rgbsps_set(uint8_t index, uint8_t r, uint8_t g, uint8_t b) {
|
||||
led[index].r = r;
|
||||
led[index].g = g;
|
||||
led[index].b = b;
|
||||
ws2812_set_color(index, r, g, b);
|
||||
}
|
||||
|
||||
void rgbsps_setall(uint8_t r, uint8_t g, uint8_t b) {
|
||||
|
|
@ -27,7 +23,7 @@ void rgbsps_turnoff(void) {
|
|||
}
|
||||
|
||||
void rgbsps_send(void) {
|
||||
ws2812_setleds(led, RGBSPS_NUM);
|
||||
ws2812_flush();
|
||||
}
|
||||
|
||||
void rgbsps_sethsv(uint8_t index, uint16_t hue, uint8_t sat, uint8_t val) {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@
|
|||
# define MODELM_LED_SCROLLOCK MODELM_LED3
|
||||
# define MODELM_LED_NUMLOCK MODELM_LED1
|
||||
#elif defined(KEYBOARD_ibm_model_m_mschwingen_led_ws2812)
|
||||
# define WS2812_LED_COUNT 3
|
||||
#else
|
||||
# error one of MODELM_LEDS_FFC, MODELM_LEDS_WIRED or MODELM_LEDS_WS2812 must be set!
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -39,27 +39,10 @@ static uint8_t isRecording = 0;
|
|||
# if RGBLIGHT_LED_COUNT < 3
|
||||
# error we need at least 3 RGB LEDs!
|
||||
# endif
|
||||
static rgb_led_t led[RGBLIGHT_LED_COUNT] = {{255, 255, 255}, {255, 255, 255}, {255, 255, 255}};
|
||||
|
||||
# define BRIGHT 32
|
||||
# define DIM 6
|
||||
|
||||
static const rgb_led_t black = {.r = 0, .g = 0, .b = 0};
|
||||
|
||||
static const __attribute__((unused)) rgb_led_t green = {.r = 0, .g = BRIGHT, .b = 0};
|
||||
static const __attribute__((unused)) rgb_led_t lgreen = {.r = 0, .g = DIM, .b = 0};
|
||||
|
||||
static const __attribute__((unused)) rgb_led_t red = {.r = BRIGHT, .g = 0, .b = 0};
|
||||
static const __attribute__((unused)) rgb_led_t lred = {.r = DIM, .g = 0, .b = 0};
|
||||
|
||||
static const __attribute__((unused)) rgb_led_t blue = {.r = 0, .g = 0, .b = BRIGHT};
|
||||
static const __attribute__((unused)) rgb_led_t lblue = {.r = 0, .g = 0, .b = DIM};
|
||||
|
||||
static const __attribute__((unused)) rgb_led_t turq = {.r = 0, .g = BRIGHT, .b = BRIGHT};
|
||||
static const __attribute__((unused)) rgb_led_t lturq = {.r = 0, .g = DIM, .b = DIM};
|
||||
|
||||
static const __attribute__((unused)) rgb_led_t white = {.r = BRIGHT, .g = BRIGHT, .b = BRIGHT};
|
||||
|
||||
static led_t led_state;
|
||||
static uint8_t layer;
|
||||
static uint8_t default_layer;
|
||||
|
|
@ -81,17 +64,15 @@ void sleep_led_enable(void) {
|
|||
suspend_active = true;
|
||||
gpio_write_pin_low(MODELM_STATUS_LED);
|
||||
#ifdef KEYBOARD_ibm_model_m_mschwingen_led_ws2812
|
||||
led[0] = black;
|
||||
led[1] = black;
|
||||
led[2] = black;
|
||||
ws2812_setleds(led, RGBLIGHT_LED_COUNT);
|
||||
ws2812_set_color_all(0, 0, 0);
|
||||
ws2812_flush();
|
||||
#endif
|
||||
}
|
||||
|
||||
void keyboard_pre_init_kb(void) {
|
||||
#ifdef KEYBOARD_ibm_model_m_mschwingen_led_ws2812
|
||||
ws2812_init();
|
||||
ws2812_setleds(led, RGBLIGHT_LED_COUNT);
|
||||
ws2812_flush();
|
||||
#else
|
||||
/* Set status LEDs pins to output and Low (on) */
|
||||
gpio_set_pin_output(MODELM_LED_CAPSLOCK);
|
||||
|
|
@ -121,35 +102,59 @@ void keyboard_pre_init_kb(void) {
|
|||
#ifdef KEYBOARD_ibm_model_m_mschwingen_led_ws2812
|
||||
static void led_update_rgb(void) {
|
||||
if (isRecording && blink_state) {
|
||||
led[0] = white;
|
||||
ws2812_set_color(0, BRIGHT, BRIGHT, BRIGHT);
|
||||
} else {
|
||||
switch (default_layer) {
|
||||
case 0:
|
||||
led[0] = led_state.num_lock ? blue : lblue;
|
||||
if (led_state.num_lock) {
|
||||
ws2812_set_color(0, 0, 0, BRIGHT);
|
||||
} else {
|
||||
ws2812_set_color(0, 0, 0, DIM);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
led[0] = led_state.num_lock ? green : black;
|
||||
if (led_state.num_lock) {
|
||||
ws2812_set_color(0, 0, BRIGHT, 0);
|
||||
} else {
|
||||
ws2812_set_color(0, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
led[1] = led_state.caps_lock ? green : black;
|
||||
if (led_state.caps_lock) {
|
||||
ws2812_set_color(1, 0, BRIGHT, 0);
|
||||
} else {
|
||||
ws2812_set_color(1, 0, 0, 0);
|
||||
}
|
||||
|
||||
switch (layer) {
|
||||
case 0:
|
||||
case 1:
|
||||
default:
|
||||
led[2] = led_state.scroll_lock ? green : black;
|
||||
if (led_state.scroll_lock) {
|
||||
ws2812_set_color(2, 0, BRIGHT, 0);
|
||||
} else {
|
||||
ws2812_set_color(2, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
led[2] = led_state.scroll_lock ? red : lred;
|
||||
if (led_state.scroll_lock) {
|
||||
ws2812_set_color(2, BRIGHT, 0, 0);
|
||||
} else {
|
||||
ws2812_set_color(2, DIM, 0, 0);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
led[2] = led_state.scroll_lock ? turq : lturq;
|
||||
if (led_state.scroll_lock) {
|
||||
ws2812_set_color(2, 0, BRIGHT, BRIGHT);
|
||||
} else {
|
||||
ws2812_set_color(2, 0, DIM, DIM);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!suspend_active) {
|
||||
ws2812_setleds(led, RGBLIGHT_LED_COUNT);
|
||||
ws2812_flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -209,6 +209,10 @@ const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = {
|
|||
// 71 70 69
|
||||
{ 0, C3_7 }, { 0, C2_7 }, { 0, C1_7 },
|
||||
};
|
||||
|
||||
int led_matrix_led_index(int index) {
|
||||
return index;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ST7565_ENABLE
|
||||
|
|
|
|||
|
|
@ -125,4 +125,8 @@ const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {
|
|||
{0, CB7_CA1, CB9_CA1, CB8_CA1}, // Down
|
||||
{0, CB7_CA7, CB9_CA7, CB8_CA7}, // Right
|
||||
};
|
||||
|
||||
int rgb_matrix_led_index(int index) {
|
||||
return index;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -126,4 +126,8 @@ const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {
|
|||
{0, CB7_CA1, CB9_CA1, CB8_CA1}, // Down
|
||||
{0, CB7_CA7, CB9_CA7, CB8_CA7}, // Right
|
||||
};
|
||||
|
||||
int rgb_matrix_led_index(int index) {
|
||||
return index;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@
|
|||
// Underglow LEDs are WS2812, but someone might want to use RGBLIGHT for them;
|
||||
// don't use those LEDs in RGB Matrix in that case.
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
# define WS2812_LED_TOTAL 0
|
||||
# define WS2812_LED_COUNT 0
|
||||
#else
|
||||
# define WS2812_LED_TOTAL 6
|
||||
# define WS2812_LED_COUNT 6
|
||||
#endif
|
||||
|
||||
#define RGB_MATRIX_LED_COUNT (IS31FL3733_LED_COUNT + WS2812_LED_TOTAL)
|
||||
#define RGB_MATRIX_LED_COUNT (IS31FL3733_LED_COUNT + WS2812_LED_COUNT)
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ led_config_t g_led_config = {
|
|||
{ 18, 48 }, { 30, 48 }, { 45, 48 }, { 60, 48 }, { 75, 48 }, { 90, 48 }, { 105, 48 }, { 120, 48 }, { 135, 48 }, { 150, 48 }, { 165, 48 }, { 191, 48 }, { 210, 48 },
|
||||
// Ctrl, GUI, Alt, Space, RAlt, FN, Left, Down, Right
|
||||
{ 3, 64 }, { 22, 64 }, { 33, 64 }, { 101, 64 }, { 135, 64 }, { 153, 64 }, { 195, 64 }, { 210, 64 }, { 225, 64 }
|
||||
# if WS2812_LED_TOTAL > 0
|
||||
# if WS2812_LED_COUNT > 0
|
||||
,{ 28, 40}, { 62, 40}, { 96, 40}, {130, 40}, {164, 40}, {198, 40}
|
||||
# endif
|
||||
}, {
|
||||
|
|
@ -124,7 +124,7 @@ led_config_t g_led_config = {
|
|||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 4,
|
||||
// Ctrl, GUI, Alt, Space, RAlt, FN, Left, Down, Right
|
||||
1, 1, 1, 4, 1, 1, 1, 1, 1
|
||||
# if WS2812_LED_TOTAL > 0
|
||||
# if WS2812_LED_COUNT > 0
|
||||
,2, 2, 2, 2, 2, 2
|
||||
# endif
|
||||
}
|
||||
|
|
@ -147,10 +147,6 @@ bool rgb_matrix_indicators_kb(void) {
|
|||
// Custom RGB Matrix driver that combines IS31FL3733 and WS2812
|
||||
// ==========================================================================
|
||||
|
||||
# if WS2812_LED_TOTAL > 0
|
||||
rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
|
||||
# endif
|
||||
|
||||
static void rgb_matrix_driver_init(void) {
|
||||
i2c_init();
|
||||
is31fl3733_init(0);
|
||||
|
|
@ -164,31 +160,25 @@ static void rgb_matrix_driver_init(void) {
|
|||
|
||||
static void rgb_matrix_driver_flush(void) {
|
||||
is31fl3733_update_pwm_buffers(0);
|
||||
# if WS2812_LED_TOTAL > 0
|
||||
ws2812_setleds(rgb_matrix_ws2812_array, WS2812_LED_TOTAL);
|
||||
# if WS2812_LED_COUNT > 0
|
||||
ws2812_flush();
|
||||
# endif
|
||||
}
|
||||
|
||||
static void rgb_matrix_driver_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
if (index < IS31FL3733_LED_COUNT) {
|
||||
is31fl3733_set_color(index, red, green, blue);
|
||||
# if WS2812_LED_COUNT > 0
|
||||
} else {
|
||||
# if WS2812_LED_TOTAL > 0
|
||||
rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].r = red;
|
||||
rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].g = green;
|
||||
rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].b = blue;
|
||||
ws2812_set_color(index - IS31FL3733_LED_COUNT, red, green, blue);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
static void rgb_matrix_driver_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
is31fl3733_set_color_all(red, green, blue);
|
||||
# if WS2812_LED_TOTAL > 0
|
||||
for (uint8_t i = 0; i < WS2812_LED_TOTAL; i++) {
|
||||
rgb_matrix_ws2812_array[i].r = red;
|
||||
rgb_matrix_ws2812_array[i].g = green;
|
||||
rgb_matrix_ws2812_array[i].b = blue;
|
||||
}
|
||||
# if WS2812_LED_COUNT > 0
|
||||
ws2812_set_color_all(red, green, blue);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@
|
|||
// Underglow LEDs are WS2812, but someone might want to use RGBLIGHT for them;
|
||||
// don't use those LEDs in RGB Matrix in that case.
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
# define WS2812_LED_TOTAL 0
|
||||
# define WS2812_LED_COUNT 0
|
||||
#else
|
||||
# define WS2812_LED_TOTAL 6
|
||||
# define WS2812_LED_COUNT 6
|
||||
#endif
|
||||
|
||||
#define RGB_MATRIX_LED_COUNT (IS31FL3733_LED_COUNT + WS2812_LED_TOTAL)
|
||||
#define RGB_MATRIX_LED_COUNT (IS31FL3733_LED_COUNT + WS2812_LED_COUNT)
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ led_config_t g_led_config = { {
|
|||
{ 3, 48 }, { 22, 48 }, { 33, 48 }, { 48, 48 }, { 63, 48 }, { 78, 48 }, { 93, 48 }, { 108, 48 }, { 123, 48 }, { 138, 48 }, { 153, 48 }, { 168, 48 }, { 194, 48 }, { 213, 48 },
|
||||
// Ctrl, GUI, Alt, Space, RAlt, FN, Left, Down, Right
|
||||
{ 3, 64 }, { 22, 64 }, { 33, 64 }, { 101, 64 }, { 135, 64 }, { 153, 64 }, { 195, 64 }, { 210, 64 }, { 225, 64 }
|
||||
# if WS2812_LED_TOTAL > 0
|
||||
# if WS2812_LED_COUNT > 0
|
||||
,{ 28, 40}, { 62, 40}, { 96, 40}, {130, 40}, {164, 40}, {198, 40}
|
||||
# endif
|
||||
}, {
|
||||
|
|
@ -126,7 +126,7 @@ led_config_t g_led_config = { {
|
|||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 4,
|
||||
// Ctrl, GUI, Alt, Space, RAlt, FN, Left, Down, Right
|
||||
1, 1, 1, 4, 1, 1, 1, 1, 1
|
||||
# if WS2812_LED_TOTAL > 0
|
||||
# if WS2812_LED_COUNT > 0
|
||||
,2, 2, 2, 2, 2, 2
|
||||
# endif
|
||||
} };
|
||||
|
|
@ -147,10 +147,6 @@ bool rgb_matrix_indicators_kb(void) {
|
|||
// Custom RGB Matrix driver that combines IS31FL3733 and WS2812
|
||||
// ==========================================================================
|
||||
|
||||
# if WS2812_LED_TOTAL > 0
|
||||
rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
|
||||
# endif
|
||||
|
||||
static void rgb_matrix_driver_init(void) {
|
||||
i2c_init();
|
||||
is31fl3733_init(0);
|
||||
|
|
@ -164,31 +160,25 @@ static void rgb_matrix_driver_init(void) {
|
|||
|
||||
static void rgb_matrix_driver_flush(void) {
|
||||
is31fl3733_update_pwm_buffers(0);
|
||||
# if WS2812_LED_TOTAL > 0
|
||||
ws2812_setleds(rgb_matrix_ws2812_array, WS2812_LED_TOTAL);
|
||||
# if WS2812_LED_COUNT > 0
|
||||
ws2812_flush();
|
||||
# endif
|
||||
}
|
||||
|
||||
static void rgb_matrix_driver_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
if (index < IS31FL3733_LED_COUNT) {
|
||||
is31fl3733_set_color(index, red, green, blue);
|
||||
# if WS2812_LED_COUNT > 0
|
||||
} else {
|
||||
# if WS2812_LED_TOTAL > 0
|
||||
rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].r = red;
|
||||
rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].g = green;
|
||||
rgb_matrix_ws2812_array[index - IS31FL3733_LED_COUNT].b = blue;
|
||||
ws2812_set_color(index - IS31FL3733_LED_COUNT, red, green, blue);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
static void rgb_matrix_driver_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
is31fl3733_set_color_all(red, green, blue);
|
||||
# if WS2812_LED_TOTAL > 0
|
||||
for (uint8_t i = 0; i < WS2812_LED_TOTAL; i++) {
|
||||
rgb_matrix_ws2812_array[i].r = red;
|
||||
rgb_matrix_ws2812_array[i].g = green;
|
||||
rgb_matrix_ws2812_array[i].b = blue;
|
||||
}
|
||||
# if WS2812_LED_COUNT > 0
|
||||
ws2812_set_color_all(red, green, blue);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@
|
|||
// Underglow LEDs are WS2812, but someone might want to use RGBLIGHT for them;
|
||||
// don't use those LEDs in RGB Matrix in that case.
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
# define WS2812_LED_TOTAL 0
|
||||
# define WS2812_LED_COUNT 0
|
||||
#else
|
||||
# define WS2812_LED_TOTAL 6
|
||||
# define WS2812_LED_COUNT 6
|
||||
#endif
|
||||
|
||||
#define RGB_MATRIX_LED_COUNT (IS31FL3733_LED_COUNT + WS2812_LED_TOTAL)
|
||||
#define RGB_MATRIX_LED_COUNT (IS31FL3733_LED_COUNT + WS2812_LED_COUNT)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue