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/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/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 d246acfdde43..5665f64222c3 100644 --- a/keyboards/zsa/ergodox_ez/led_i2c.c +++ b/keyboards/zsa/ergodox_ez/rgblight_custom.c @@ -18,24 +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(LED_TYPE *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) @@ -53,7 +52,7 @@ void rgblight_call_driver(LED_TYPE *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 } @@ -62,4 +61,7 @@ void rgblight_call_driver(LED_TYPE *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, +};