From 7338af5716e3ef0e120284413ae84b5f5a5e9678 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Mon, 19 Aug 2024 02:35:10 -0700 Subject: [PATCH 1/2] Fix issues with Ergodox EZ Shine LEDs --- keyboards/zsa/ergodox_ez/led_i2c.c | 3 +-- keyboards/zsa/ergodox_ez/m32u4/m32u4.c | 3 +-- keyboards/zsa/ergodox_ez/rules.mk | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/keyboards/zsa/ergodox_ez/led_i2c.c b/keyboards/zsa/ergodox_ez/led_i2c.c index d246acfdde43..e476ae0dda93 100644 --- a/keyboards/zsa/ergodox_ez/led_i2c.c +++ b/keyboards/zsa/ergodox_ez/led_i2c.c @@ -19,10 +19,9 @@ along with this program. If not, see . */ #ifdef RGBLIGHT_ENABLE - # include "ergodox_ez.h" -void rgblight_call_driver(LED_TYPE *led, uint8_t led_num) { +void rgblight_call_driver(rgb_led_t *led, uint8_t led_num) { uint16_t length = 0; uint8_t i = 0; uint8_t j = 0; diff --git a/keyboards/zsa/ergodox_ez/m32u4/m32u4.c b/keyboards/zsa/ergodox_ez/m32u4/m32u4.c index e899b5c332cf..c20248bce920 100644 --- a/keyboards/zsa/ergodox_ez/m32u4/m32u4.c +++ b/keyboards/zsa/ergodox_ez/m32u4/m32u4.c @@ -21,12 +21,11 @@ void keyboard_post_init_sub(void) { // (tied to Vcc for hardware convenience) setPinInput(B4); - // unused pins - C7, D4, D5, D7, E6 + // unused pins - C7, D4, D5, E6 // set as input with internal pull-up enabled setPinInputHigh(C7); setPinInputHigh(D4); setPinInputHigh(D5); - setPinInputHigh(D7); setPinInputHigh(E6); setPinOutput(ERGODOX_LED_1_PIN); diff --git a/keyboards/zsa/ergodox_ez/rules.mk b/keyboards/zsa/ergodox_ez/rules.mk index 363c32e629f7..0793612fea82 100644 --- a/keyboards/zsa/ergodox_ez/rules.mk +++ b/keyboards/zsa/ergodox_ez/rules.mk @@ -2,7 +2,7 @@ CUSTOM_MATRIX = lite #project specific files -SRC += matrix.c +SRC += matrix.c led_i2c.c I2C_DRIVER_REQUIRED = yes MOUSE_SHARED_EP = no From 80f09e6f7bdd355ade6d7364d926c3bb303578ab Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Mon, 19 Aug 2024 03:08:31 -0700 Subject: [PATCH 2/2] Get RGB Light working with newer driver model --- keyboards/zsa/ergodox_ez/info.json | 3 +++ keyboards/zsa/ergodox_ez/post_config.h | 1 + keyboards/zsa/ergodox_ez/post_rules.mk | 5 ++++ .../{led_i2c.c => rgblight_custom.c} | 23 +++++++++++-------- keyboards/zsa/ergodox_ez/rules.mk | 2 +- 5 files changed, 23 insertions(+), 11 deletions(-) rename keyboards/zsa/ergodox_ez/{led_i2c.c => rgblight_custom.c} (82%) diff --git a/keyboards/zsa/ergodox_ez/info.json b/keyboards/zsa/ergodox_ez/info.json index 787617c561a1..2a138ea976aa 100644 --- a/keyboards/zsa/ergodox_ez/info.json +++ b/keyboards/zsa/ergodox_ez/info.json @@ -80,6 +80,9 @@ "saturation_steps": 255, "sleep": true }, + "ws2812": { + "rgbw": true + }, "tapping": { "toggle": 1 }, diff --git a/keyboards/zsa/ergodox_ez/post_config.h b/keyboards/zsa/ergodox_ez/post_config.h index 49d9f9c85ca8..b8f06da2f408 100644 --- a/keyboards/zsa/ergodox_ez/post_config.h +++ b/keyboards/zsa/ergodox_ez/post_config.h @@ -38,6 +38,7 @@ along with this program. If not, see . // If not, then only define 15 # define RGBLIGHT_LED_COUNT 15 // Number of LEDs #endif +#define WS2812_LED_COUNT RGBLIGHT_LED_COUNT #ifndef ISSI_TIMEOUT # define ISSI_TIMEOUT 3 diff --git a/keyboards/zsa/ergodox_ez/post_rules.mk b/keyboards/zsa/ergodox_ez/post_rules.mk index c25a0b3a290b..fd68dc3c29c5 100644 --- a/keyboards/zsa/ergodox_ez/post_rules.mk +++ b/keyboards/zsa/ergodox_ez/post_rules.mk @@ -1 +1,6 @@ include keyboards/zsa/common/features.mk +ifeq ($(RGBLIGHT_ENABLE),yes) + RGBLIGHT_DRIVER = custom + WS2812_DRIVER_REQUIRED = yes + SRC += rgblight_custom.c +endif diff --git a/keyboards/zsa/ergodox_ez/led_i2c.c b/keyboards/zsa/ergodox_ez/rgblight_custom.c similarity index 82% rename from keyboards/zsa/ergodox_ez/led_i2c.c rename to keyboards/zsa/ergodox_ez/rgblight_custom.c index e476ae0dda93..5665f64222c3 100644 --- a/keyboards/zsa/ergodox_ez/led_i2c.c +++ b/keyboards/zsa/ergodox_ez/rgblight_custom.c @@ -18,23 +18,23 @@ 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" -void rgblight_call_driver(rgb_led_t *led, uint8_t led_num) { +void setleds_custom(rgb_led_t *led, uint16_t led_num) { uint16_t length = 0; - uint8_t i = 0; - uint8_t j = 0; -# ifdef RGBW - const uint8_t bytes_per_led = 4; + int i = 0; + int j = 0; +# ifdef WS2812_RGBW + int bytes_per_led = 4; # else - const uint8_t bytes_per_led = 3; + 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 = RGBLED_NUM / 2; + uint8_t half_led_num = WS2812_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) @@ -52,7 +52,7 @@ void rgblight_call_driver(rgb_led_t *led, uint8_t led_num) { data[j++] = data_byte[0]; data[j++] = data_byte[1]; data[j++] = data_byte[2]; -# ifdef RGBW +# ifdef WS2812_RGBW data[j++] = data_byte[3]; # endif } @@ -61,4 +61,7 @@ void rgblight_call_driver(rgb_led_t *led, uint8_t led_num) { ws2812_setleds(led, led_num); } -#endif // RGBLIGHT_ENABLE +const rgblight_driver_t rgblight_driver = { + .init = ws2812_init, + .setleds = setleds_custom, +}; diff --git a/keyboards/zsa/ergodox_ez/rules.mk b/keyboards/zsa/ergodox_ez/rules.mk index 0793612fea82..363c32e629f7 100644 --- a/keyboards/zsa/ergodox_ez/rules.mk +++ b/keyboards/zsa/ergodox_ez/rules.mk @@ -2,7 +2,7 @@ CUSTOM_MATRIX = lite #project specific files -SRC += matrix.c led_i2c.c +SRC += matrix.c I2C_DRIVER_REQUIRED = yes MOUSE_SHARED_EP = no