aboutsummaryrefslogtreecommitdiff
path: root/keyboards/ibm
diff options
context:
space:
mode:
authorRyan <[email protected]>2024-10-06 19:01:07 +1100
committerGitHub <[email protected]>2024-10-06 21:01:07 +1300
commit208ebf54a905ce6e4e563a6811eca8c8dc8b17e1 (patch)
tree7bb6a8bdb5a641263c39236d0b655825ac37307b /keyboards/ibm
parent43e82ed5c72b7386ca91d1bd363ee092f77c1b9a (diff)
downloadqmk_firmware-208ebf54a905ce6e4e563a6811eca8c8dc8b17e1.tar.gz
qmk_firmware-208ebf54a905ce6e4e563a6811eca8c8dc8b17e1.zip
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 <[email protected]> --------- Co-authored-by: Dasky <[email protected]>
Diffstat (limited to 'keyboards/ibm')
-rw-r--r--keyboards/ibm/model_m/mschwingen/config.h1
-rw-r--r--keyboards/ibm/model_m/mschwingen/mschwingen.c65
2 files changed, 36 insertions, 30 deletions
diff --git a/keyboards/ibm/model_m/mschwingen/config.h b/keyboards/ibm/model_m/mschwingen/config.h
index b34d29649a..19fb3fcd6f 100644
--- a/keyboards/ibm/model_m/mschwingen/config.h
+++ b/keyboards/ibm/model_m/mschwingen/config.h
@@ -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
diff --git a/keyboards/ibm/model_m/mschwingen/mschwingen.c b/keyboards/ibm/model_m/mschwingen/mschwingen.c
index 7c0f1b2565..cb4854d8d1 100644
--- a/keyboards/ibm/model_m/mschwingen/mschwingen.c
+++ b/keyboards/ibm/model_m/mschwingen/mschwingen.c
@@ -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();
}
}