diff options
author | Ryan <[email protected]> | 2024-10-06 19:01:07 +1100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-10-06 21:01:07 +1300 |
commit | 208ebf54a905ce6e4e563a6811eca8c8dc8b17e1 (patch) | |
tree | 7bb6a8bdb5a641263c39236d0b655825ac37307b /keyboards/neson_design | |
parent | 43e82ed5c72b7386ca91d1bd363ee092f77c1b9a (diff) | |
download | qmk_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/neson_design')
-rw-r--r-- | keyboards/neson_design/700e/700e.c | 61 | ||||
-rw-r--r-- | keyboards/neson_design/700e/config.h | 1 | ||||
-rw-r--r-- | keyboards/neson_design/n6/config.h | 1 | ||||
-rw-r--r-- | keyboards/neson_design/n6/n6.c | 61 |
4 files changed, 69 insertions, 55 deletions
diff --git a/keyboards/neson_design/700e/700e.c b/keyboards/neson_design/700e/700e.c index c6ba94c834..cee22cf78d 100644 --- a/keyboards/neson_design/700e/700e.c +++ b/keyboards/neson_design/700e/700e.c @@ -18,9 +18,11 @@ */ #include "quantum.h" -#include "i2c_master.h" -#include "drivers/led/issi/is31fl3731.h" -#include "ws2812.h" + +#ifdef RGBLIGHT_ENABLE +# include "i2c_master.h" +# include "drivers/led/issi/is31fl3731.h" +# include "ws2812.h" enum { SELF_TESTING, @@ -67,7 +69,6 @@ enum { #endif #define ST_RIGHT_END (ST_RIGHT_BEGIN+ST_RIGHT_SIZE-1) -#ifdef RGBLIGHT_ENABLE typedef struct { uint8_t state; @@ -295,7 +296,6 @@ void matrix_init_kb(void) gpio_set_pin_output(LED_CAPS_LOCK_PIN); gpio_write_pin_low(LED_CAPS_LOCK_PIN); - is31fl3731_init_drivers(); update_ticks(); matrix_init_user(); @@ -313,17 +313,10 @@ void housekeeping_task_kb(void) } else if (rgb_state.state == CAPS_ALERT) { if (rgb_state.alert) { is31fl3731_set_color_all(ALERM_LED_R, ALERM_LED_G, ALERM_LED_B); - rgb_led_t leds[4]; - for (int i = 0; i < 4; i++) { - leds[i].r = ALERM_LED_G; - leds[i].g = ALERM_LED_R; - leds[i].b = ALERM_LED_B; - } - ws2812_setleds(leds, 4); + ws2812_set_color_all(ALERM_LED_G, ALERM_LED_R, ALERM_LED_B); } else { is31fl3731_set_color_all(0, 0, 0); - rgb_led_t leds[4] = {0}; - ws2812_setleds(leds, 4); + ws2812_set_color_all(0, 0, 0); } if (timer_elapsed(rgb_state.ticks) > ALERT_INTERVAL) { @@ -333,28 +326,40 @@ void housekeeping_task_kb(void) } is31fl3731_flush(); + ws2812_flush(); } -void setleds_custom(rgb_led_t *start_led, uint16_t num_leds) -{ - if (rgb_state.state != NORMAL) return; +void init_custom(void) { + is31fl3731_init_drivers(); + ws2812_init(); +} - for (uint8_t i = 0; i < IS31FL3731_LED_COUNT; i++) { - is31fl3731_set_color(i, start_led[i].r, start_led[i].g, start_led[i].b); +void set_color_custom(int index, uint8_t red, uint8_t green, uint8_t blue) { + if (index < IS31FL3731_LED_COUNT) { + is31fl3731_set_color(index, red, green, blue); + } else if (index < IS31FL3731_LED_COUNT + WS2812_LED_COUNT) { + ws2812_set_color(index - IS31FL3731_LED_COUNT, green, red, blue); } - rgb_led_t leds[4]; - for (int i = 0; i < 4; i++) { - leds[i].r = start_led[IS31FL3731_LED_COUNT+i].g; - leds[i].g = start_led[IS31FL3731_LED_COUNT+i].r; - leds[i].b = start_led[IS31FL3731_LED_COUNT+i].b; +} + +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); } - //ws2812_setleds(start_led+IS31FL3731_LED_COUNT, 4); - ws2812_setleds(leds, 4); +} + +void flush_custom(void) { + if (rgb_state.state != NORMAL) return; + + is31fl3731_flush(); + ws2812_flush(); } const rgblight_driver_t rgblight_driver = { - .init = ws2812_init, - .setleds = setleds_custom, + .init = init_custom, + .set_color = set_color_custom, + .set_color_all = set_color_all_custom, + .flush = flush_custom, }; bool led_update_kb(led_t led_state) diff --git a/keyboards/neson_design/700e/config.h b/keyboards/neson_design/700e/config.h index d92c9deb5d..2c2d02cad1 100644 --- a/keyboards/neson_design/700e/config.h +++ b/keyboards/neson_design/700e/config.h @@ -21,5 +21,6 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC #define IS31FL3731_LED_COUNT 64 +#define WS2812_LED_COUNT 4 #define USB_SUSPEND_WAKEUP_DELAY 1000 diff --git a/keyboards/neson_design/n6/config.h b/keyboards/neson_design/n6/config.h index 92aa189fae..dd67c11851 100644 --- a/keyboards/neson_design/n6/config.h +++ b/keyboards/neson_design/n6/config.h @@ -21,3 +21,4 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC #define IS31FL3731_LED_COUNT 64 +#define WS2812_LED_COUNT 1 diff --git a/keyboards/neson_design/n6/n6.c b/keyboards/neson_design/n6/n6.c index ef5035dcde..03bb88c40b 100644 --- a/keyboards/neson_design/n6/n6.c +++ b/keyboards/neson_design/n6/n6.c @@ -18,9 +18,11 @@ */ #include "quantum.h" -#include "i2c_master.h" -#include "drivers/led/issi/is31fl3731.h" -#include "ws2812.h" + +#ifdef RGBLIGHT_ENABLE +# include "i2c_master.h" +# include "drivers/led/issi/is31fl3731.h" +# include "ws2812.h" enum { SELF_TESTING, @@ -67,7 +69,6 @@ enum { #endif #define ST_RIGHT_END (ST_RIGHT_BEGIN+ST_RIGHT_SIZE-1) -#ifdef RGBLIGHT_ENABLE extern rgblight_config_t rgblight_config; typedef struct { @@ -299,8 +300,6 @@ void matrix_init_kb(void) gpio_set_pin_output(LED_CAPS_LOCK_PIN); gpio_write_pin_low(LED_CAPS_LOCK_PIN); - is31fl3731_init_drivers(); - update_ticks(); matrix_init_user(); } @@ -310,22 +309,12 @@ void housekeeping_task_kb(void) if (rgb_state.state == SELF_TESTING) { self_testing(); } else if (rgb_state.state == CAPS_ALERT) { - //gold 0xFF, 0xD9, 0x00 - rgb_led_t led = { - .r = 0xFF, - //.g = 0xD9, - .g = 0xA5, - .b = 0x00, - }; if (rgb_state.alert) { - is31fl3731_set_color_all(led.r, led.g, led.b); - ws2812_setleds(&led, 1); + is31fl3731_set_color_all(0xFF, 0xA5, 0x00); + ws2812_set_color_all(0xFF, 0xA5, 0x00); } else { - led.r = 0; - led.g = 0; - led.b = 0; is31fl3731_set_color_all(0, 0, 0); - ws2812_setleds(&led, 1); + ws2812_set_color_all(0, 0, 0); } if (timer_elapsed(rgb_state.ticks) > ALERT_INTERVAL) { @@ -337,19 +326,37 @@ void housekeeping_task_kb(void) is31fl3731_flush(); } -void setleds_custom(rgb_led_t *start_led, uint16_t num_leds) -{ - if (rgb_state.state != NORMAL) return; +void init_custom(void) { + is31fl3731_init_drivers(); + ws2812_init(); +} - for (uint8_t i = 0; i < IS31FL3731_LED_COUNT; i++) { - is31fl3731_set_color(i, start_led[i].r, start_led[i].g, start_led[i].b); +void set_color_custom(int index, uint8_t red, uint8_t green, uint8_t blue) { + if (index < IS31FL3731_LED_COUNT) { + is31fl3731_set_color(index, red, green, blue); + } else if (index < IS31FL3731_LED_COUNT + WS2812_LED_COUNT) { + ws2812_set_color(index - IS31FL3731_LED_COUNT, red, green, blue); } - ws2812_setleds(start_led+IS31FL3731_LED_COUNT, 1); +} + +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) { + if (rgb_state.state != NORMAL) return; + + is31fl3731_flush(); + ws2812_flush(); } const rgblight_driver_t rgblight_driver = { - .init = ws2812_init, - .setleds = setleds_custom, + .init = init_custom, + .set_color = set_color_custom, + .set_color_all = set_color_all_custom, + .flush = flush_custom, }; bool led_update_kb(led_t led_state) |