From f7cf40fa77164d7be9358ce83f7f5939d71b38bc Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 18 Mar 2024 22:03:27 +1100 Subject: [PATCH] Add init function to RGBLight driver struct (#23076) --- drivers/led/apa102.c | 10 +- drivers/ws2812.h | 2 + keyboards/1k/keymaps/default/keymap.c | 1 + keyboards/1k/keymaps/default/rgblite.h | 4 + .../ergodox_ez/glow/keymaps/default/keymap.c | 200 ++++++++++++++++++ .../ergodox_ez/glow/keymaps/default/rules.mk | 2 + .../ergodox_ez/keymaps/default_glow/keymap.c | 1 - .../ergodox_ez/keymaps/default_glow/rules.mk | 4 - .../ergodox_ez/keymaps/rgb_layer/keymap.c | 37 ++-- keyboards/ergodox_ez/keymaps/testing/keymap.c | 27 +-- keyboards/ergodox_ez/rules.mk | 3 +- .../{led_i2c.c => shine/rgblight_custom.c} | 9 +- keyboards/ergodox_ez/shine/rules.mk | 1 + keyboards/handwired/promethium/rgbsps.c | 7 + keyboards/ibm/model_m/mschwingen/mschwingen.c | 1 + keyboards/kprepublic/bm60hsrgb/rev2/rev2.c | 1 + .../kprepublic/bm60hsrgb_iso/rev2/rev2.c | 1 + .../kprepublic/bm60hsrgb_poker/rev2/rev2.c | 1 + keyboards/matrix/abelx/abelx.c | 1 + keyboards/matrix/noah/noah.c | 1 + keyboards/neson_design/700e/700e.c | 1 + keyboards/neson_design/n6/n6.c | 1 + keyboards/neson_design/nico/nico.c | 1 + keyboards/oddforge/vea/ws2812_custom.c | 6 - keyboards/rgbkb/pan/pan.c | 4 +- keyboards/wilba_tech/wt_rgb_backlight.c | 3 + keyboards/work_louder/rgb_functions.c | 2 + keyboards/xelus/dawn60/rev1_qmk/rev1_qmk.c | 2 +- .../xd002/keymaps/multilayer_rgb/keymap.c | 1 + .../xd002/keymaps/multilayer_rgb/rgblite.h | 10 +- .../xiudi/xd002/keymaps/rgb_lite/keymap.c | 1 + .../xiudi/xd002/keymaps/rgb_lite/rgblite.h | 8 +- platforms/avr/drivers/ws2812_bitbang.c | 4 +- platforms/avr/drivers/ws2812_i2c.c | 6 - .../drivers/vendor/RP/RP2040/ws2812_vendor.c | 11 +- platforms/chibios/drivers/ws2812_bitbang.c | 6 - platforms/chibios/drivers/ws2812_pwm.c | 6 - platforms/chibios/drivers/ws2812_spi.c | 6 - quantum/rgb_matrix/rgb_matrix_drivers.c | 1 + quantum/rgblight/rgblight.c | 2 + quantum/rgblight/rgblight_drivers.c | 2 + quantum/rgblight/rgblight_drivers.h | 1 + 42 files changed, 306 insertions(+), 93 deletions(-) create mode 100644 keyboards/ergodox_ez/glow/keymaps/default/keymap.c create mode 100644 keyboards/ergodox_ez/glow/keymaps/default/rules.mk delete mode 100644 keyboards/ergodox_ez/keymaps/default_glow/keymap.c delete mode 100644 keyboards/ergodox_ez/keymaps/default_glow/rules.mk rename keyboards/ergodox_ez/{led_i2c.c => shine/rgblight_custom.c} (95%) diff --git a/drivers/led/apa102.c b/drivers/led/apa102.c index d6d4327495..b171b07b12 100644 --- a/drivers/led/apa102.c +++ b/drivers/led/apa102.c @@ -67,7 +67,9 @@ static void apa102_send_byte(uint8_t byte) { } static void apa102_start_frame(void) { - apa102_init(); + gpio_write_pin_low(APA102_DI_PIN); + gpio_write_pin_low(APA102_CI_PIN); + for (uint16_t i = 0; i < 4; i++) { apa102_send_byte(0); } @@ -103,7 +105,8 @@ static void apa102_end_frame(uint16_t num_leds) { apa102_send_byte(0); } - apa102_init(); + gpio_write_pin_low(APA102_DI_PIN); + gpio_write_pin_low(APA102_CI_PIN); } static void apa102_send_frame(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness) { @@ -116,9 +119,6 @@ static void apa102_send_frame(uint8_t red, uint8_t green, uint8_t blue, uint8_t void apa102_init(void) { gpio_set_pin_output(APA102_DI_PIN); gpio_set_pin_output(APA102_CI_PIN); - - gpio_write_pin_low(APA102_DI_PIN); - gpio_write_pin_low(APA102_CI_PIN); } void apa102_setleds(rgb_led_t *start_led, uint16_t num_leds) { diff --git a/drivers/ws2812.h b/drivers/ws2812.h index 134de51c50..993cce8ce4 100644 --- a/drivers/ws2812.h +++ b/drivers/ws2812.h @@ -62,6 +62,8 @@ # define WS2812_LED_COUNT RGB_MATRIX_LED_COUNT #endif +void ws2812_init(void); + /* User Interface * * Input: diff --git a/keyboards/1k/keymaps/default/keymap.c b/keyboards/1k/keymaps/default/keymap.c index b64d4d8c76..3261a9f922 100644 --- a/keyboards/1k/keymaps/default/keymap.c +++ b/keyboards/1k/keymaps/default/keymap.c @@ -21,5 +21,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } void keyboard_post_init_user(void) { + rgblite_init(); rgblite_increase_hue(); } diff --git a/keyboards/1k/keymaps/default/rgblite.h b/keyboards/1k/keymaps/default/rgblite.h index 9a7761e30d..2e0b898699 100644 --- a/keyboards/1k/keymaps/default/rgblite.h +++ b/keyboards/1k/keymaps/default/rgblite.h @@ -6,6 +6,10 @@ #include "ws2812.h" #include "color.h" +static inline void rgblite_init(void) { + ws2812_init(); +} + 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); diff --git a/keyboards/ergodox_ez/glow/keymaps/default/keymap.c b/keyboards/ergodox_ez/glow/keymaps/default/keymap.c new file mode 100644 index 0000000000..94d68cb870 --- /dev/null +++ b/keyboards/ergodox_ez/glow/keymaps/default/keymap.c @@ -0,0 +1,200 @@ +#include QMK_KEYBOARD_H +#include "version.h" + +enum layers { + BASE, // default layer + SYMB, // symbols + MDIA, // media keys +}; + +enum custom_keycodes { + VRSN = SAFE_RANGE, +}; + +// clang-format off +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Keymap 0: Basic layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | = | 1 | 2 | 3 | 4 | 5 | LEFT | | RIGHT| 6 | 7 | 8 | 9 | 0 | - | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | Del | Q | W | E | R | T | L1 | | L1 | Y | U | I | O | P | \ | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | BkSp | A | S | D | F | G |------| |------| H | J | K | L |; / L2|' / Cmd | + * |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------| + * | LShift |Z/Ctrl| X | C | V | B | | | | N | M | , | . |//Ctrl| RShift | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | App | LGui | | Alt |Ctrl/Esc| + * ,------|------|------| |------+--------+------. + * | | | Home | | PgUp | | | + * | Space|Backsp|------| |------| Tab |Enter | + * | |ace | End | | PgDn | | | + * `--------------------' `----------------------' + */ +[BASE] = LAYOUT_ergodox_pretty( + // left hand + KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, + KC_DEL, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB), TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, + KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN), GUI_T(KC_QUOT), + KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO), MEH_T(KC_NO), KC_N, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLSH), KC_RSFT, + LT(SYMB,KC_GRV), KC_QUOT, LALT(KC_LSFT), KC_LEFT, KC_RGHT, KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, TT(SYMB), + ALT_T(KC_APP), KC_LGUI, KC_LALT, CTL_T(KC_ESC), + KC_HOME, KC_PGUP, + KC_SPC, KC_BSPC, KC_END, KC_PGDN, KC_TAB, KC_ENT +), +/* Keymap 1: Symbol Layer + * + * ,---------------------------------------------------. ,--------------------------------------------------. + * |Version | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 | + * |---------+------+------+------+------+------+------| |------+------+------+------+------+------+--------| + * | | ! | @ | { | } | | | | | | Up | 7 | 8 | 9 | * | F12 | + * |---------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | # | $ | ( | ) | ` |------| |------| Down | 4 | 5 | 6 | + | | + * |---------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | \ | | + * `---------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | EPRM | | | | | | | . | 0 | = | | + * `-----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * |Animat| | |Toggle|Solid | + * ,------|------|------| |------+------+------. + * |Bright|Bright| | | |Hue- |Hue+ | + * |ness- |ness+ |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +[SYMB] = LAYOUT_ergodox_pretty( + // left hand + VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, + KC_TRNS, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, KC_TRNS, KC_TRNS, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12, + KC_TRNS, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS, + KC_TRNS, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS, + EE_CLR, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_DOT, KC_0, KC_EQL, KC_TRNS, + RGB_MOD, KC_TRNS, RGB_TOG, RGB_M_P, + KC_TRNS, KC_TRNS, + RGB_VAD, RGB_VAI, KC_TRNS, KC_TRNS, RGB_HUD, RGB_HUI +), +/* Keymap 2: Media and mouse keys + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | | | MsUp | | | | | | | | | | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | | | | | | | Prev | Next | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | |Brwser| + * | | |------| |------| |Back | + * | | | | | | | | + * `--------------------' `--------------------' + */ +[MDIA] = LAYOUT_ergodox_pretty( + // left hand + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, + + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_WBAK +), +}; +// clang-format on + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { + switch (keycode) { + case VRSN: + SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); + return false; + } + } + return true; +} + +// Runs just one time when the keyboard initializes. +void keyboard_post_init_user(void) { +#ifdef RGBLIGHT_COLOR_LAYER_0 + rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0); +#endif +}; + +// Runs whenever there is a layer state change. +layer_state_t layer_state_set_user(layer_state_t state) { + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + + uint8_t layer = get_highest_layer(state); + switch (layer) { + case 0: +#ifdef RGBLIGHT_COLOR_LAYER_0 + rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0); +#endif + break; + case 1: + ergodox_right_led_1_on(); +#ifdef RGBLIGHT_COLOR_LAYER_1 + rgblight_setrgb(RGBLIGHT_COLOR_LAYER_1); +#endif + break; + case 2: + ergodox_right_led_2_on(); +#ifdef RGBLIGHT_COLOR_LAYER_2 + rgblight_setrgb(RGBLIGHT_COLOR_LAYER_2); +#endif + break; + case 3: + ergodox_right_led_3_on(); +#ifdef RGBLIGHT_COLOR_LAYER_3 + rgblight_setrgb(RGBLIGHT_COLOR_LAYER_3); +#endif + break; + case 4: + ergodox_right_led_1_on(); + ergodox_right_led_2_on(); +#ifdef RGBLIGHT_COLOR_LAYER_4 + rgblight_setrgb(RGBLIGHT_COLOR_LAYER_4); +#endif + break; + case 5: + ergodox_right_led_1_on(); + ergodox_right_led_3_on(); +#ifdef RGBLIGHT_COLOR_LAYER_5 + rgblight_setrgb(RGBLIGHT_COLOR_LAYER_5); +#endif + break; + case 6: + ergodox_right_led_2_on(); + ergodox_right_led_3_on(); +#ifdef RGBLIGHT_COLOR_LAYER_6 + rgblight_setrgb(RGBLIGHT_COLOR_LAYER_6); +#endif + break; + case 7: + ergodox_right_led_1_on(); + ergodox_right_led_2_on(); + ergodox_right_led_3_on(); +#ifdef RGBLIGHT_COLOR_LAYER_7 + rgblight_setrgb(RGBLIGHT_COLOR_LAYER_7); +#endif + break; + default: + break; + } + + return state; +}; diff --git a/keyboards/ergodox_ez/glow/keymaps/default/rules.mk b/keyboards/ergodox_ez/glow/keymaps/default/rules.mk new file mode 100644 index 0000000000..1a840036e2 --- /dev/null +++ b/keyboards/ergodox_ez/glow/keymaps/default/rules.mk @@ -0,0 +1,2 @@ +RGBLIGHT_ENABLE = no +RGB_MATRIX_ENABLE = yes diff --git a/keyboards/ergodox_ez/keymaps/default_glow/keymap.c b/keyboards/ergodox_ez/keymaps/default_glow/keymap.c deleted file mode 100644 index 526c364029..0000000000 --- a/keyboards/ergodox_ez/keymaps/default_glow/keymap.c +++ /dev/null @@ -1 +0,0 @@ -// Placeholder. See ../default/keymap.c for details diff --git a/keyboards/ergodox_ez/keymaps/default_glow/rules.mk b/keyboards/ergodox_ez/keymaps/default_glow/rules.mk deleted file mode 100644 index 20bac4ab9d..0000000000 --- a/keyboards/ergodox_ez/keymaps/default_glow/rules.mk +++ /dev/null @@ -1,4 +0,0 @@ -RGBLIGHT_ENABLE = no -RGB_MATRIX_ENABLE = yes # enable later - -SRC += keymaps/default/keymap.c diff --git a/keyboards/ergodox_ez/keymaps/rgb_layer/keymap.c b/keyboards/ergodox_ez/keymaps/rgb_layer/keymap.c index 6ed204a357..b033c0ca1c 100644 --- a/keyboards/ergodox_ez/keymaps/rgb_layer/keymap.c +++ b/keyboards/ergodox_ez/keymaps/rgb_layer/keymap.c @@ -151,6 +151,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), }; +#ifdef RGBLIGHT_ENABLE void eeconfig_init_user(void) { rgblight_enable(); rgblight_sethsv(HSV_CYAN); @@ -158,7 +159,7 @@ void eeconfig_init_user(void) { user_config.rgb_layer_change = true; eeconfig_update_user(user_config.raw); } - +#endif bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { @@ -168,21 +169,17 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { eeconfig_init(); } return false; - break; case VRSN: if (record->event.pressed) { SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); } return false; - break; +#ifdef RGBLIGHT_ENABLE case RGB_SLD: if (record->event.pressed) { - #ifdef RGBLIGHT_ENABLE rgblight_mode(1); - #endif } return false; - break; case RGB_LYR: // This allows me to use underglow as layer indication, or as normal if (record->event.pressed) { user_config.rgb_layer_change ^= 1; // Toggles the status @@ -191,7 +188,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { layer_state_set(layer_state); // then immediately update the layer color } } - return false; break; + return false; case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // For any of the RGB codes (see quantum_keycodes.h, L400 for reference) if (record->event.pressed) { //This disables layer indication, as it's assumed that if you're changing this ... you want that disabled if (user_config.rgb_layer_change) { // only if this is enabled @@ -199,11 +196,13 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { eeconfig_update_user(user_config.raw); // write the setings to EEPROM } } - return true; break; + return true; +#endif } return true; } +#ifdef RGBLIGHT_ENABLE void matrix_init_user(void) { // Call the keymap level matrix init. @@ -217,11 +216,7 @@ void matrix_init_user(void) { rgblight_mode_noeeprom(1); } } - -// Runs constantly in the background, in a loop. -void matrix_scan_user(void) { - -}; +#endif layer_state_t layer_state_set_user(layer_state_t state) { ergodox_board_led_off(); @@ -231,39 +226,55 @@ layer_state_t layer_state_set_user(layer_state_t state) { switch (get_highest_layer(state)) { case SYMB: ergodox_right_led_1_on(); +#ifdef RGBLIGHT_ENABLE if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_RED); rgblight_mode_noeeprom(1); } +#endif break; case MDIA: ergodox_right_led_2_on(); +#ifdef RGBLIGHT_ENABLE if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_GREEN); rgblight_mode_noeeprom(1); } +#endif break; case 3: ergodox_right_led_3_on(); +#ifdef RGBLIGHT_ENABLE if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_BLUE); rgblight_mode_noeeprom(1); } +#endif break; case 4: ergodox_right_led_1_on(); ergodox_right_led_2_on(); +#ifdef RGBLIGHT_ENABLE if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_ORANGE); rgblight_mode_noeeprom(1); } +#endif break; case 5: ergodox_right_led_1_on(); ergodox_right_led_3_on(); +#ifdef RGBLIGHT_ENABLE if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_YELLOW); rgblight_mode_noeeprom(1); } +#endif break; case 6: ergodox_right_led_2_on(); ergodox_right_led_3_on(); +#ifdef RGBLIGHT_ENABLE if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_PINK); rgblight_mode_noeeprom(1); } +#endif break; case 7: ergodox_right_led_1_on(); ergodox_right_led_2_on(); ergodox_right_led_3_on(); +#ifdef RGBLIGHT_ENABLE if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_WHITE); rgblight_mode_noeeprom(1); } +#endif break; default: // for any other layers, or the default layer +#ifdef RGBLIGHT_ENABLE if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_CYAN); rgblight_mode_noeeprom(1); } +#endif break; } return state; diff --git a/keyboards/ergodox_ez/keymaps/testing/keymap.c b/keyboards/ergodox_ez/keymaps/testing/keymap.c index ef8ca63e3b..ee07f264b9 100644 --- a/keyboards/ergodox_ez/keymaps/testing/keymap.c +++ b/keyboards/ergodox_ez/keymaps/testing/keymap.c @@ -29,7 +29,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; void matrix_init_user(void) { -#ifdef RGBLIGHT_COLOR_LAYER_0 +#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_0) rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0); #endif }; @@ -42,19 +42,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { eeconfig_init(); } return false; - break; case VRSN: if (record->event.pressed) { SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); } return false; - break; +#ifdef RGBLIGHT_ENABLE case RGB_SLD: if (record->event.pressed) { rgblight_mode(1); } return false; - break; +#endif } return true; @@ -70,48 +69,50 @@ layer_state_t layer_state_set_user(layer_state_t state) { ergodox_right_led_3_off(); switch (layer) { case 0: - #ifdef RGBLIGHT_COLOR_LAYER_0 + #ifdef RGBLIGHT_ENABLE + #ifdef RGBLIGHT_COLOR_LAYER_0 rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0); - #else + #else rgblight_init(); + #endif #endif break; case 1: ergodox_right_led_1_on(); - #ifdef RGBLIGHT_COLOR_LAYER_1 + #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_1) rgblight_setrgb(RGBLIGHT_COLOR_LAYER_1); #endif break; case 2: ergodox_right_led_2_on(); - #ifdef RGBLIGHT_COLOR_LAYER_2 + #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_2) rgblight_setrgb(RGBLIGHT_COLOR_LAYER_2); #endif break; case 3: ergodox_right_led_3_on(); - #ifdef RGBLIGHT_COLOR_LAYER_3 + #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_3) rgblight_setrgb(RGBLIGHT_COLOR_LAYER_3); #endif break; case 4: ergodox_right_led_1_on(); ergodox_right_led_2_on(); - #ifdef RGBLIGHT_COLOR_LAYER_4 + #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_4) rgblight_setrgb(RGBLIGHT_COLOR_LAYER_4); #endif break; case 5: ergodox_right_led_1_on(); ergodox_right_led_3_on(); - #ifdef RGBLIGHT_COLOR_LAYER_5 + #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_5) rgblight_setrgb(RGBLIGHT_COLOR_LAYER_5); #endif break; case 6: ergodox_right_led_2_on(); ergodox_right_led_3_on(); - #ifdef RGBLIGHT_COLOR_LAYER_6 + #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_6) rgblight_setrgb(RGBLIGHT_COLOR_LAYER_6); #endif break; @@ -119,7 +120,7 @@ layer_state_t layer_state_set_user(layer_state_t state) { ergodox_right_led_1_on(); ergodox_right_led_2_on(); ergodox_right_led_3_on(); - #ifdef RGBLIGHT_COLOR_LAYER_7 + #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_7) rgblight_setrgb(RGBLIGHT_COLOR_LAYER_6); #endif break; diff --git a/keyboards/ergodox_ez/rules.mk b/keyboards/ergodox_ez/rules.mk index bba3bd86ae..68f785f3cc 100644 --- a/keyboards/ergodox_ez/rules.mk +++ b/keyboards/ergodox_ez/rules.mk @@ -19,8 +19,7 @@ SWAP_HANDS_ENABLE= no # Allow swapping hands of keyboard RGB_MATRIX_ENABLE = no # enable later # project specific files -SRC += matrix.c \ - led_i2c.c +SRC += matrix.c I2C_DRIVER_REQUIRED = yes # Disable unsupported hardware diff --git a/keyboards/ergodox_ez/led_i2c.c b/keyboards/ergodox_ez/shine/rgblight_custom.c similarity index 95% rename from keyboards/ergodox_ez/led_i2c.c rename to keyboards/ergodox_ez/shine/rgblight_custom.c index 80dabf4815..feac50cba0 100644 --- a/keyboards/ergodox_ez/led_i2c.c +++ b/keyboards/ergodox_ez/shine/rgblight_custom.c @@ -18,10 +18,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifdef RGBLIGHT_ENABLE - -# include "ergodox_ez.h" -# include "ws2812.h" +#include "ergodox_ez.h" +#include "ws2812.h" void setleds_custom(rgb_led_t *led, uint16_t led_num) { uint16_t length = 0; @@ -64,7 +62,6 @@ void setleds_custom(rgb_led_t *led, uint16_t led_num) { } const rgblight_driver_t rgblight_driver = { + .init = ws2812_init, .setleds = setleds_custom, }; - -#endif // RGBLIGHT_ENABLE diff --git a/keyboards/ergodox_ez/shine/rules.mk b/keyboards/ergodox_ez/shine/rules.mk index b035c36850..4ab494d1aa 100644 --- a/keyboards/ergodox_ez/shine/rules.mk +++ b/keyboards/ergodox_ez/shine/rules.mk @@ -1,2 +1,3 @@ RGBLIGHT_ENABLE = yes WS2812_DRIVER_REQUIRED = yes +SRC += rgblight_custom.c diff --git a/keyboards/handwired/promethium/rgbsps.c b/keyboards/handwired/promethium/rgbsps.c index 957726e775..7dc26f4a5e 100644 --- a/keyboards/handwired/promethium/rgbsps.c +++ b/keyboards/handwired/promethium/rgbsps.c @@ -1,8 +1,15 @@ +#include "keyboard.h" #include "ws2812.h" #include "rgbsps.h" rgb_led_t led[RGBSPS_NUM]; +void keyboard_pre_init_kb(void) { + ws2812_init(); + + keyboard_pre_init_user(); +} + void rgbsps_set(uint8_t index, uint8_t r, uint8_t g, uint8_t b) { led[index].r = r; led[index].g = g; diff --git a/keyboards/ibm/model_m/mschwingen/mschwingen.c b/keyboards/ibm/model_m/mschwingen/mschwingen.c index 03dfcdc2f2..6a8a0ec8fc 100644 --- a/keyboards/ibm/model_m/mschwingen/mschwingen.c +++ b/keyboards/ibm/model_m/mschwingen/mschwingen.c @@ -90,6 +90,7 @@ void sleep_led_enable(void) { void keyboard_pre_init_kb(void) { #ifdef KEYBOARD_ibm_model_m_mschwingen_led_ws2812 + ws2812_init(); ws2812_setleds(led, RGBLIGHT_LED_COUNT); #else /* Set status LEDs pins to output and Low (on) */ diff --git a/keyboards/kprepublic/bm60hsrgb/rev2/rev2.c b/keyboards/kprepublic/bm60hsrgb/rev2/rev2.c index 3ee74755fa..5bd23a12b8 100644 --- a/keyboards/kprepublic/bm60hsrgb/rev2/rev2.c +++ b/keyboards/kprepublic/bm60hsrgb/rev2/rev2.c @@ -154,6 +154,7 @@ rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL]; static void rgb_matrix_driver_init(void) { i2c_init(); is31fl3733_init(0); + ws2812_init(); for (uint8_t index = 0; index < IS31FL3733_LED_COUNT; index++) { bool enabled = true; is31fl3733_set_led_control_register(index, enabled, enabled, enabled); diff --git a/keyboards/kprepublic/bm60hsrgb_iso/rev2/rev2.c b/keyboards/kprepublic/bm60hsrgb_iso/rev2/rev2.c index e7641bf4e5..794dea5176 100644 --- a/keyboards/kprepublic/bm60hsrgb_iso/rev2/rev2.c +++ b/keyboards/kprepublic/bm60hsrgb_iso/rev2/rev2.c @@ -154,6 +154,7 @@ rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL]; static void rgb_matrix_driver_init(void) { i2c_init(); is31fl3733_init(0); + ws2812_init(); for (uint8_t index = 0; index < IS31FL3733_LED_COUNT; index++) { bool enabled = true; is31fl3733_set_led_control_register(index, enabled, enabled, enabled); diff --git a/keyboards/kprepublic/bm60hsrgb_poker/rev2/rev2.c b/keyboards/kprepublic/bm60hsrgb_poker/rev2/rev2.c index 5cb6d850c9..3586dc8e80 100644 --- a/keyboards/kprepublic/bm60hsrgb_poker/rev2/rev2.c +++ b/keyboards/kprepublic/bm60hsrgb_poker/rev2/rev2.c @@ -150,6 +150,7 @@ rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL]; static void rgb_matrix_driver_init(void) { i2c_init(); is31fl3733_init(0); + ws2812_init(); for (uint8_t index = 0; index < IS31FL3733_LED_COUNT; index++) { bool enabled = true; is31fl3733_set_led_control_register(index, enabled, enabled, enabled); diff --git a/keyboards/matrix/abelx/abelx.c b/keyboards/matrix/abelx/abelx.c index 0a3071a402..ee7ffde134 100644 --- a/keyboards/matrix/abelx/abelx.c +++ b/keyboards/matrix/abelx/abelx.c @@ -79,6 +79,7 @@ void setleds_custom(rgb_led_t *start_led, uint16_t num_leds) } const rgblight_driver_t rgblight_driver = { + .init = ws2812_init, .setleds = setleds_custom, }; diff --git a/keyboards/matrix/noah/noah.c b/keyboards/matrix/noah/noah.c index b5c52f9952..a01d1b11bc 100644 --- a/keyboards/matrix/noah/noah.c +++ b/keyboards/matrix/noah/noah.c @@ -55,6 +55,7 @@ void setleds_custom(rgb_led_t *ledarray, uint16_t num_leds) { } const rgblight_driver_t rgblight_driver = { + .init = ws2812_init, .setleds = setleds_custom, }; #endif diff --git a/keyboards/neson_design/700e/700e.c b/keyboards/neson_design/700e/700e.c index 31f88a71f9..a9bcbee288 100644 --- a/keyboards/neson_design/700e/700e.c +++ b/keyboards/neson_design/700e/700e.c @@ -355,6 +355,7 @@ void setleds_custom(rgb_led_t *start_led, uint16_t num_leds) } const rgblight_driver_t rgblight_driver = { + .init = ws2812_init, .setleds = setleds_custom, }; diff --git a/keyboards/neson_design/n6/n6.c b/keyboards/neson_design/n6/n6.c index b878b9368d..f257735acc 100644 --- a/keyboards/neson_design/n6/n6.c +++ b/keyboards/neson_design/n6/n6.c @@ -350,6 +350,7 @@ void setleds_custom(rgb_led_t *start_led, uint16_t num_leds) } const rgblight_driver_t rgblight_driver = { + .init = ws2812_init, .setleds = setleds_custom, }; diff --git a/keyboards/neson_design/nico/nico.c b/keyboards/neson_design/nico/nico.c index bf8eeb87dd..0738a3ee98 100644 --- a/keyboards/neson_design/nico/nico.c +++ b/keyboards/neson_design/nico/nico.c @@ -84,6 +84,7 @@ void setleds_custom(rgb_led_t *start_led, uint16_t num_leds) } const rgblight_driver_t rgblight_driver = { + .init = ws2812_init, .setleds = setleds_custom, }; #endif \ No newline at end of file diff --git a/keyboards/oddforge/vea/ws2812_custom.c b/keyboards/oddforge/vea/ws2812_custom.c index f52c8d06a8..a037b88b3e 100644 --- a/keyboards/oddforge/vea/ws2812_custom.c +++ b/keyboards/oddforge/vea/ws2812_custom.c @@ -23,12 +23,6 @@ void ws2812_init(void) { // Setleds for standard RGB void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) { - static bool s_init = false; - if (!s_init) { - ws2812_init(); - s_init = true; - } - i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(rgb_led_t) * (leds >> 1), WS2812_I2C_TIMEOUT); i2c_transmit(WS2812_I2C_ADDRESS_RIGHT, (uint8_t *)ledarray+(sizeof(rgb_led_t) * (leds >> 1)), sizeof(rgb_led_t) * (leds - (leds >> 1)), WS2812_I2C_TIMEOUT); } diff --git a/keyboards/rgbkb/pan/pan.c b/keyboards/rgbkb/pan/pan.c index d175be3641..191ff1ac1f 100644 --- a/keyboards/rgbkb/pan/pan.c +++ b/keyboards/rgbkb/pan/pan.c @@ -24,8 +24,6 @@ // LED color buffer rgb_led_t rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT]; -static void init(void) {} - static void flush(void) { ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT); } @@ -56,7 +54,7 @@ static void setled_all(uint8_t r, uint8_t g, uint8_t b) { } const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, + .init = ws2812_init, .flush = flush, .set_color = setled, .set_color_all = setled_all, diff --git a/keyboards/wilba_tech/wt_rgb_backlight.c b/keyboards/wilba_tech/wt_rgb_backlight.c index cf36288705..d03d189b29 100644 --- a/keyboards/wilba_tech/wt_rgb_backlight.c +++ b/keyboards/wilba_tech/wt_rgb_backlight.c @@ -2237,6 +2237,9 @@ void backlight_init_drivers(void) is31fl3733_update_led_control_registers( 0 ); is31fl3733_update_led_control_registers( 1 ); #else +#if defined(RGB_BACKLIGHT_DAWN60) + ws2812_init(); +#endif // Init the #1 driver is31fl3731_init( 0 ); // Init the #2 driver (if used) diff --git a/keyboards/work_louder/rgb_functions.c b/keyboards/work_louder/rgb_functions.c index 9b39555971..36f9da013e 100644 --- a/keyboards/work_louder/rgb_functions.c +++ b/keyboards/work_louder/rgb_functions.c @@ -20,11 +20,13 @@ #undef WS2812_DI_PIN #define WS2812_DI_PIN RGBLIGHT_DI_PIN +#define ws2812_init ws2812_rgb_init #define ws2812_setleds ws2812_rgb_setleds #include "ws2812_bitbang.c" const rgblight_driver_t rgblight_driver = { + .init = ws2812_init, .setleds = ws2812_setleds, }; #endif diff --git a/keyboards/xelus/dawn60/rev1_qmk/rev1_qmk.c b/keyboards/xelus/dawn60/rev1_qmk/rev1_qmk.c index 6b8f91bc2f..a153a7cf83 100644 --- a/keyboards/xelus/dawn60/rev1_qmk/rev1_qmk.c +++ b/keyboards/xelus/dawn60/rev1_qmk/rev1_qmk.c @@ -155,7 +155,7 @@ static void init(void) { is31fl3731_update_led_control_registers(1); //RGB Underglow ws2812 - + ws2812_init(); } static void flush(void) { diff --git a/keyboards/xiudi/xd002/keymaps/multilayer_rgb/keymap.c b/keyboards/xiudi/xd002/keymaps/multilayer_rgb/keymap.c index 4ae28fd91b..d74678d76a 100644 --- a/keyboards/xiudi/xd002/keymaps/multilayer_rgb/keymap.c +++ b/keyboards/xiudi/xd002/keymaps/multilayer_rgb/keymap.c @@ -169,5 +169,6 @@ layer_state_t layer_state_set_user(layer_state_t state) { // default color void keyboard_post_init_user(void) { + rgblite_init(); rgblite_setrgb(RGB_GREEN); } diff --git a/keyboards/xiudi/xd002/keymaps/multilayer_rgb/rgblite.h b/keyboards/xiudi/xd002/keymaps/multilayer_rgb/rgblite.h index 1fa6f899b9..103b228d33 100644 --- a/keyboards/xiudi/xd002/keymaps/multilayer_rgb/rgblite.h +++ b/keyboards/xiudi/xd002/keymaps/multilayer_rgb/rgblite.h @@ -3,7 +3,11 @@ #include "ws2812.h" #include "color.h" -static inline void rgblite_setrgb(uint8_t _r, uint8_t _g, uint8_t _b) { - rgb_led_t leds[RGBLED_NUM] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}}; - ws2812_setleds(leds, RGBLED_NUM); +static inline void rgblite_init(void) { + ws2812_init(); +} + +static inline void rgblite_setrgb(uint8_t _r, uint8_t _g, uint8_t _b) { + rgb_led_t leds[RGBLIGHT_LED_COUNT] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}}; + ws2812_setleds(leds, RGBLIGHT_LED_COUNT); } diff --git a/keyboards/xiudi/xd002/keymaps/rgb_lite/keymap.c b/keyboards/xiudi/xd002/keymaps/rgb_lite/keymap.c index a795ca8a6d..aac4dc6fde 100644 --- a/keyboards/xiudi/xd002/keymaps/rgb_lite/keymap.c +++ b/keyboards/xiudi/xd002/keymaps/rgb_lite/keymap.c @@ -27,5 +27,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } void keyboard_post_init_user(void) { + rgblite_init(); rgblite_increase_hue(); } diff --git a/keyboards/xiudi/xd002/keymaps/rgb_lite/rgblite.h b/keyboards/xiudi/xd002/keymaps/rgb_lite/rgblite.h index 15ee0c0f6b..0bb0582415 100644 --- a/keyboards/xiudi/xd002/keymaps/rgb_lite/rgblite.h +++ b/keyboards/xiudi/xd002/keymaps/rgb_lite/rgblite.h @@ -3,9 +3,13 @@ #include "ws2812.h" #include "color.h" +static inline void rgblite_init(void) { + ws2812_init(); +} + static inline void rgblite_setrgb(uint8_t _r, uint8_t _g, uint8_t _b) { - rgb_led_t leds[RGBLED_NUM] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}}; - ws2812_setleds(leds, RGBLED_NUM); + rgb_led_t leds[RGBLIGHT_LED_COUNT] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}}; + ws2812_setleds(leds, RGBLIGHT_LED_COUNT); } static void rgblite_increase_hue(void) { diff --git a/platforms/avr/drivers/ws2812_bitbang.c b/platforms/avr/drivers/ws2812_bitbang.c index 116053591f..be127e501c 100644 --- a/platforms/avr/drivers/ws2812_bitbang.c +++ b/platforms/avr/drivers/ws2812_bitbang.c @@ -37,9 +37,11 @@ static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t masklo, uint8_t maskhi); -void ws2812_setleds(rgb_led_t *ledarray, uint16_t number_of_leds) { +void ws2812_init(void) { DDRx_ADDRESS(WS2812_DI_PIN) |= pinmask(WS2812_DI_PIN); +} +void ws2812_setleds(rgb_led_t *ledarray, uint16_t number_of_leds) { uint8_t masklo = ~(pinmask(WS2812_DI_PIN)) & PORTx_ADDRESS(WS2812_DI_PIN); uint8_t maskhi = pinmask(WS2812_DI_PIN) | PORTx_ADDRESS(WS2812_DI_PIN); diff --git a/platforms/avr/drivers/ws2812_i2c.c b/platforms/avr/drivers/ws2812_i2c.c index f52a037b8e..60b466c32a 100644 --- a/platforms/avr/drivers/ws2812_i2c.c +++ b/platforms/avr/drivers/ws2812_i2c.c @@ -19,11 +19,5 @@ void ws2812_init(void) { // Setleds for standard RGB void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) { - static bool s_init = false; - if (!s_init) { - ws2812_init(); - s_init = true; - } - i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(rgb_led_t) * leds, WS2812_I2C_TIMEOUT); } diff --git a/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c b/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c index 799d96b3c6..95a827e4b8 100644 --- a/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c +++ b/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c @@ -177,7 +177,7 @@ static void ws2812_dma_callback(void* p, uint32_t ct) { osalSysUnlockFromISR(); } -bool ws2812_init(void) { +void ws2812_init(void) { uint pio_idx = pio_get_index(pio); /* Get PIOx peripheral out of reset state. */ hal_lld_peripheral_unreset(pio_idx == 0 ? RESETS_ALLREG_PIO0 : RESETS_ALLREG_PIO1); @@ -196,7 +196,7 @@ bool ws2812_init(void) { STATE_MACHINE = pio_claim_unused_sm(pio, true); if (STATE_MACHINE < 0) { dprintln("ERROR: Failed to acquire state machine for WS2812 output!"); - return false; + return; } uint offset = pio_add_program(pio, &ws2812_program); @@ -246,8 +246,6 @@ bool ws2812_init(void) { DMA_CTRL_TRIG_TREQ_SEL(pio == pio0 ? STATE_MACHINE : STATE_MACHINE + 8) | DMA_CTRL_TRIG_PRIORITY(RP_DMA_PRIORITY_WS2812); // clang-format on - - return true; } static inline void sync_ws2812_transfer(void) { @@ -269,11 +267,6 @@ static inline void sync_ws2812_transfer(void) { } void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) { - static bool is_initialized = false; - if (unlikely(!is_initialized)) { - is_initialized = ws2812_init(); - } - sync_ws2812_transfer(); for (int i = 0; i < leds; i++) { diff --git a/platforms/chibios/drivers/ws2812_bitbang.c b/platforms/chibios/drivers/ws2812_bitbang.c index 1ed87c4381..9ed6bacd5a 100644 --- a/platforms/chibios/drivers/ws2812_bitbang.c +++ b/platforms/chibios/drivers/ws2812_bitbang.c @@ -82,12 +82,6 @@ void ws2812_init(void) { // Setleds for standard RGB void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) { - static bool s_init = false; - if (!s_init) { - ws2812_init(); - s_init = true; - } - // this code is very time dependent, so we need to disable interrupts chSysLock(); diff --git a/platforms/chibios/drivers/ws2812_pwm.c b/platforms/chibios/drivers/ws2812_pwm.c index e0b3bfd5b5..7dc3414ead 100644 --- a/platforms/chibios/drivers/ws2812_pwm.c +++ b/platforms/chibios/drivers/ws2812_pwm.c @@ -389,12 +389,6 @@ void ws2812_write_led_rgbw(uint16_t led_number, uint8_t r, uint8_t g, uint8_t b, // Setleds for standard RGB void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) { - static bool s_init = false; - if (!s_init) { - ws2812_init(); - s_init = true; - } - for (uint16_t i = 0; i < leds; i++) { #ifdef RGBW ws2812_write_led_rgbw(i, ledarray[i].r, ledarray[i].g, ledarray[i].b, ledarray[i].w); diff --git a/platforms/chibios/drivers/ws2812_spi.c b/platforms/chibios/drivers/ws2812_spi.c index 01162f07f4..5b990ccaa0 100644 --- a/platforms/chibios/drivers/ws2812_spi.c +++ b/platforms/chibios/drivers/ws2812_spi.c @@ -188,12 +188,6 @@ void ws2812_init(void) { } void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) { - static bool s_init = false; - if (!s_init) { - ws2812_init(); - s_init = true; - } - for (uint8_t i = 0; i < leds; i++) { set_led_color_rgb(ledarray[i], i); } diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 729dcdb439..4370996d0e 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -151,6 +151,7 @@ rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_COUNT]; bool ws2812_dirty = false; static void init(void) { + ws2812_init(); ws2812_dirty = false; } diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index 530cb04688..28b58feea6 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -247,6 +247,8 @@ void rgblight_init(void) { rgblight_mode_noeeprom(rgblight_config.mode); } + rgblight_driver.init(); + is_rgblight_initialized = true; } diff --git a/quantum/rgblight/rgblight_drivers.c b/quantum/rgblight/rgblight_drivers.c index 45b60e1a5f..8902b8f842 100644 --- a/quantum/rgblight/rgblight_drivers.c +++ b/quantum/rgblight/rgblight_drivers.c @@ -7,6 +7,7 @@ # include "ws2812.h" const rgblight_driver_t rgblight_driver = { + .init = ws2812_init, .setleds = ws2812_setleds, }; @@ -14,6 +15,7 @@ const rgblight_driver_t rgblight_driver = { # include "apa102.h" const rgblight_driver_t rgblight_driver = { + .init = apa102_init, .setleds = apa102_setleds, }; diff --git a/quantum/rgblight/rgblight_drivers.h b/quantum/rgblight/rgblight_drivers.h index f7125a6f3d..af28b918e1 100644 --- a/quantum/rgblight/rgblight_drivers.h +++ b/quantum/rgblight/rgblight_drivers.h @@ -7,6 +7,7 @@ #include "color.h" typedef struct { + void (*init)(void); void (*setleds)(rgb_led_t *ledarray, uint16_t number_of_leds); } rgblight_driver_t;