Skip to content

Commit

Permalink
Get RGB Light working with newer driver model
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna committed Aug 19, 2024
1 parent 7338af5 commit 80f09e6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
3 changes: 3 additions & 0 deletions keyboards/zsa/ergodox_ez/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
"saturation_steps": 255,
"sleep": true
},
"ws2812": {
"rgbw": true
},
"tapping": {
"toggle": 1
},
Expand Down
1 change: 1 addition & 0 deletions keyboards/zsa/ergodox_ez/post_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// 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
Expand Down
5 changes: 5 additions & 0 deletions keyboards/zsa/ergodox_ez/post_rules.mk
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#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)
Expand All @@ -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
}
Expand All @@ -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,
};
2 changes: 1 addition & 1 deletion keyboards/zsa/ergodox_ez/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 80f09e6

Please sign in to comment.