summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorTakeshi ISHII <2170248+mtei@users.noreply.github.com>2019-03-21 08:55:24 +0900
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-03-20 16:55:24 -0700
commitf7fd7f67bd1286a42326a6832627ef328252db0c (patch)
treeaf2be4e14b19d10ec58989fb3d46057009c79429 /quantum
parentd5fd8c4f1cf79de17528f7f40948640fa8bb8d7a (diff)
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
Diffstat (limited to 'quantum')
-rw-r--r--quantum/rgblight.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 119ca1b9ee..3042ff11ea 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++) {