From f7fd7f67bd1286a42326a6832627ef328252db0c Mon Sep 17 00:00:00 2001 From: Takeshi ISHII <2170248+mtei@users.noreply.github.com> Date: Thu, 21 Mar 2019 08:55:24 +0900 Subject: rgblight.c: add remap feature (#5243) * rgblight.c: add RGBLIGHT_LED_MAP support * add code to keyboards/helix/rev2/keymaps/five_rows/config.h to test rgblight.c:RGBLIGHT_LED_MAP * Test end. Revert "add code to keyboards/helix/rev2/keymaps/five_rows/config.h to test rgblight.c:RGBLIGHT_LED_MAP" This reverts commit e7488d6f7338460b533d7d19a09deccb011000bf. * update docs/feature_rgblight.md * led_map[] move to PROGMEM --- quantum/rgblight.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 119ca1b9e..3042ff11e 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -51,6 +51,10 @@ static inline int is_static_effect(uint8_t mode) { #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) +#ifdef RGBLIGHT_LED_MAP +const uint8_t led_map[] PROGMEM = RGBLIGHT_LED_MAP; +#endif + #ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT __attribute__ ((weak)) const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; @@ -665,10 +669,20 @@ void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val) { #ifndef RGBLIGHT_CUSTOM_DRIVER void rgblight_set(void) { if (rgblight_config.enable) { + LED_TYPE *ledp; + #ifdef RGBLIGHT_LED_MAP + LED_TYPE led0[RGBLED_NUM]; + for(uint8_t i = 0; i < RGBLED_NUM; i++) { + led0[i] = led[pgm_read_byte(&led_map[i])]; + } + ledp = led0; + #else + ledp = led; + #endif #ifdef RGBW - ws2812_setleds_rgbw(led, RGBLED_NUM); + ws2812_setleds_rgbw(ledp, RGBLED_NUM); #else - ws2812_setleds(led, RGBLED_NUM); + ws2812_setleds(ledp, RGBLED_NUM); #endif } else { for (uint8_t i = 0; i < RGBLED_NUM; i++) { -- cgit v1.2.3-24-g4f1b