diff options
-rw-r--r-- | quantum/rgblight.c | 10 | ||||
-rw-r--r-- | quantum/rgblight.h | 33 |
2 files changed, 23 insertions, 20 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index b3f0f18d4..cc35b01ed 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
@@ -104,7 +104,7 @@ LED_TYPE led[RGBLED_NUM]; | |||
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | #ifdef RGBLIGHT_LAYERS | 106 | #ifdef RGBLIGHT_LAYERS |
107 | rgblight_segment_t const * const *rgblight_layers = NULL; | 107 | rgblight_segment_t const *const *rgblight_layers = NULL; |
108 | #endif | 108 | #endif |
109 | 109 | ||
110 | static uint8_t clipping_start_pos = 0; | 110 | static uint8_t clipping_start_pos = 0; |
@@ -638,11 +638,11 @@ bool rgblight_get_layer_state(uint8_t layer) { | |||
638 | static void rgblight_layers_write(void) { | 638 | static void rgblight_layers_write(void) { |
639 | uint8_t i = 0; | 639 | uint8_t i = 0; |
640 | // For each layer | 640 | // For each layer |
641 | for (const rgblight_segment_t * const *layer_ptr = rgblight_layers; i < RGBLIGHT_MAX_LAYERS; layer_ptr++, i++) { | 641 | for (const rgblight_segment_t *const *layer_ptr = rgblight_layers; i < RGBLIGHT_MAX_LAYERS; layer_ptr++, i++) { |
642 | if (!rgblight_get_layer_state(i)) { | 642 | if (!rgblight_get_layer_state(i)) { |
643 | continue; // Layer is disabled | 643 | continue; // Layer is disabled |
644 | } | 644 | } |
645 | const rgblight_segment_t * segment_ptr = pgm_read_ptr(layer_ptr); | 645 | const rgblight_segment_t *segment_ptr = pgm_read_ptr(layer_ptr); |
646 | if (segment_ptr == NULL) { | 646 | if (segment_ptr == NULL) { |
647 | break; // No more layers | 647 | break; // No more layers |
648 | } | 648 | } |
@@ -654,7 +654,7 @@ static void rgblight_layers_write(void) { | |||
654 | break; // No more segments | 654 | break; // No more segments |
655 | } | 655 | } |
656 | // Write segment.count LEDs | 656 | // Write segment.count LEDs |
657 | LED_TYPE * const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)]; | 657 | LED_TYPE *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)]; |
658 | for (LED_TYPE *led_ptr = &led[segment.index]; led_ptr < limit; led_ptr++) { | 658 | for (LED_TYPE *led_ptr = &led[segment.index]; led_ptr < limit; led_ptr++) { |
659 | sethsv(segment.hue, segment.sat, segment.val, led_ptr); | 659 | sethsv(segment.hue, segment.sat, segment.val, led_ptr); |
660 | } | 660 | } |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 40f267daa..97882c5b2 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
@@ -172,25 +172,28 @@ enum RGBLIGHT_EFFECT_MODE { | |||
172 | 172 | ||
173 | # ifdef RGBLIGHT_LAYERS | 173 | # ifdef RGBLIGHT_LAYERS |
174 | typedef struct { | 174 | typedef struct { |
175 | uint8_t index; // The first LED to light | 175 | uint8_t index; // The first LED to light |
176 | uint8_t count; // The number of LEDs to light | 176 | uint8_t count; // The number of LEDs to light |
177 | uint8_t hue; | 177 | uint8_t hue; |
178 | uint8_t sat; | 178 | uint8_t sat; |
179 | uint8_t val; | 179 | uint8_t val; |
180 | } rgblight_segment_t; | 180 | } rgblight_segment_t; |
181 | 181 | ||
182 | # define RGBLIGHT_END_SEGMENT_INDEX (255) | 182 | # define RGBLIGHT_END_SEGMENT_INDEX (255) |
183 | # define RGBLIGHT_END_SEGMENTS {RGBLIGHT_END_SEGMENT_INDEX, 0, 0, 0} | 183 | # define RGBLIGHT_END_SEGMENTS \ |
184 | { RGBLIGHT_END_SEGMENT_INDEX, 0, 0, 0 } | ||
184 | # define RGBLIGHT_MAX_LAYERS 8 | 185 | # define RGBLIGHT_MAX_LAYERS 8 |
185 | # define RGBLIGHT_LAYER_SEGMENTS(...) { __VA_ARGS__, RGBLIGHT_END_SEGMENTS } | 186 | # define RGBLIGHT_LAYER_SEGMENTS(...) \ |
186 | # define RGBLIGHT_LAYERS_LIST(...) { __VA_ARGS__, NULL } | 187 | { __VA_ARGS__, RGBLIGHT_END_SEGMENTS } |
188 | # define RGBLIGHT_LAYERS_LIST(...) \ | ||
189 | { __VA_ARGS__, NULL } | ||
187 | 190 | ||
188 | // Get/set enabled rgblight layers | 191 | // Get/set enabled rgblight layers |
189 | void rgblight_set_layer_state(uint8_t layer, bool enabled); | 192 | void rgblight_set_layer_state(uint8_t layer, bool enabled); |
190 | bool rgblight_get_layer_state(uint8_t layer); | 193 | bool rgblight_get_layer_state(uint8_t layer); |
191 | 194 | ||
192 | // Point this to an array of rgblight_segment_t arrays in keyboard_post_init_user to use rgblight layers | 195 | // Point this to an array of rgblight_segment_t arrays in keyboard_post_init_user to use rgblight layers |
193 | extern const rgblight_segment_t * const * rgblight_layers; | 196 | extern const rgblight_segment_t *const *rgblight_layers; |
194 | # endif | 197 | # endif |
195 | 198 | ||
196 | extern LED_TYPE led[RGBLED_NUM]; | 199 | extern LED_TYPE led[RGBLED_NUM]; |
@@ -320,19 +323,19 @@ void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); | |||
320 | # define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) | 323 | # define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) |
321 | void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b); | 324 | void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b); |
322 | 325 | ||
323 | #ifdef RGBLIGHT_USE_TIMER | 326 | # ifdef RGBLIGHT_USE_TIMER |
324 | void rgblight_task(void); | 327 | void rgblight_task(void); |
325 | void rgblight_timer_init(void); | 328 | void rgblight_timer_init(void); |
326 | void rgblight_timer_enable(void); | 329 | void rgblight_timer_enable(void); |
327 | void rgblight_timer_disable(void); | 330 | void rgblight_timer_disable(void); |
328 | void rgblight_timer_toggle(void); | 331 | void rgblight_timer_toggle(void); |
329 | #else | 332 | # else |
330 | #define rgblight_task() | 333 | # define rgblight_task() |
331 | #define rgblight_timer_init() | 334 | # define rgblight_timer_init() |
332 | #define rgblight_timer_enable() | 335 | # define rgblight_timer_enable() |
333 | #define rgblight_timer_disable() | 336 | # define rgblight_timer_disable() |
334 | #define rgblight_timer_toggle() | 337 | # define rgblight_timer_toggle() |
335 | #endif | 338 | # endif |
336 | 339 | ||
337 | # ifdef RGBLIGHT_SPLIT | 340 | # ifdef RGBLIGHT_SPLIT |
338 | # define RGBLIGHT_STATUS_CHANGE_MODE (1 << 0) | 341 | # define RGBLIGHT_STATUS_CHANGE_MODE (1 << 0) |