1
0
Fork 0

[Keyboard] Fix RGBKB Pan Rev1 Encoder RGB handling (#13781)

This commit is contained in:
Drashna Jaelre 2021-07-31 06:09:47 -07:00 committed by GitHub
parent fb6c66a14b
commit e755c5fe1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 76 additions and 26 deletions

View file

@ -17,8 +17,54 @@
#include "quantum.h"
#include "rgb_matrix_types.h"
#if defined RGB_MATRIX_ENABLE
# if defined(KEYBOARD_rgbkb_pan_rev1)
# include "ws2812.h"
// LED color buffer
LED_TYPE rgb_matrix_ws2812_array[DRIVER_LED_TOTAL];
static void init(void) {}
static void flush(void) {
// Assumes use of RGB_DI_PIN
ws2812_setleds(rgb_matrix_ws2812_array, DRIVER_LED_TOTAL);
}
// Set an led in the buffer to a color
static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) {
# if defined(RGB_ENCODERS) || defined(STAGGERED_RGB_ENCODERS)
if (i == 0 || i == 1) { // if encoder LEDs, change LEDs
rgb_matrix_ws2812_array[i].r = g;
rgb_matrix_ws2812_array[i].g = b;
rgb_matrix_ws2812_array[i].b = r;
} else
# endif
{
rgb_matrix_ws2812_array[i].r = r;
rgb_matrix_ws2812_array[i].g = g;
rgb_matrix_ws2812_array[i].b = b;
}
# ifdef RGBW
convert_rgb_to_rgbw(&rgb_matrix_ws2812_array[i]);
# endif
}
static void setled_all(uint8_t r, uint8_t g, uint8_t b) {
for (int i = 0; i < sizeof(rgb_matrix_ws2812_array) / sizeof(rgb_matrix_ws2812_array[0]); i++) {
setled(i, r, g, b);
}
}
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
.flush = flush,
.set_color = setled,
.set_color_all = setled_all,
};
# endif
// clang-format off
led_config_t g_led_config = { {
{ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 },
{ 0, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15 },
@ -85,4 +131,5 @@
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
# endif
} };
// clang-format on
#endif

View file

@ -1,2 +1,5 @@
# The default configuration is a atmega32a
DEFAULT_FOLDER = rgbkb/pan/rev1/32a
RGB_MATRIX_DRIVER = custom
WS2812_DRIVER_REQUIRED := yes