]> git.donarmstrong.com Git - qmk_firmware.git/blob - quantum/rgb_matrix.c
98baf5cb5808e325da587d1dc0a748ba68757d17
[qmk_firmware.git] / quantum / rgb_matrix.c
1 /* Copyright 2017 Jason Williams
2  * Copyright 2017 Jack Humbert
3  * Copyright 2018 Yiancar
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19
20 #include "rgb_matrix.h"
21 #include "progmem.h"
22 #include "config.h"
23 #include "eeprom.h"
24 #include <string.h>
25 #include <math.h>
26
27 #include "lib/lib8tion/lib8tion.h"
28
29 #ifndef RGB_MATRIX_CENTER
30   const point_t k_rgb_matrix_center = { 112, 32 };
31 #else
32   const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER;
33 #endif
34
35 // Generic effect runners
36 #include "rgb_matrix_runners/effect_runner_dx_dy_dist.h"
37 #include "rgb_matrix_runners/effect_runner_dx_dy.h"
38 #include "rgb_matrix_runners/effect_runner_i.h"
39 #include "rgb_matrix_runners/effect_runner_sin_cos_i.h"
40 #include "rgb_matrix_runners/effect_runner_reactive.h"
41 #include "rgb_matrix_runners/effect_runner_reactive_splash.h"
42
43 // ------------------------------------------
44 // -----Begin rgb effect includes macros-----
45 #define RGB_MATRIX_EFFECT(name)
46 #define RGB_MATRIX_CUSTOM_EFFECT_IMPLS
47
48 #include "rgb_matrix_animations/rgb_matrix_effects.inc"
49 #ifdef RGB_MATRIX_CUSTOM_KB
50     #include "rgb_matrix_kb.inc"
51 #endif
52 #ifdef RGB_MATRIX_CUSTOM_USER
53     #include "rgb_matrix_user.inc"
54 #endif
55
56 #undef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
57 #undef RGB_MATRIX_EFFECT
58 // -----End rgb effect includes macros-------
59 // ------------------------------------------
60
61 #ifndef RGB_DISABLE_AFTER_TIMEOUT
62   #define RGB_DISABLE_AFTER_TIMEOUT 0
63 #endif
64
65 #ifndef RGB_DISABLE_WHEN_USB_SUSPENDED
66   #define RGB_DISABLE_WHEN_USB_SUSPENDED false
67 #endif
68
69 #ifndef EECONFIG_RGB_MATRIX
70   #define EECONFIG_RGB_MATRIX EECONFIG_RGBLIGHT
71 #endif
72
73 #if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
74   #undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
75   #define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
76 #endif
77
78 #if !defined(RGB_MATRIX_HUE_STEP)
79   #define RGB_MATRIX_HUE_STEP 8
80 #endif
81
82 #if !defined(RGB_MATRIX_SAT_STEP)
83   #define RGB_MATRIX_SAT_STEP 16
84 #endif
85
86 #if !defined(RGB_MATRIX_VAL_STEP)
87   #define RGB_MATRIX_VAL_STEP 16
88 #endif
89
90 #if !defined(RGB_MATRIX_SPD_STEP)
91   #define RGB_MATRIX_SPD_STEP 16
92 #endif
93
94 #if !defined(RGB_MATRIX_STARTUP_MODE)
95   #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
96     #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT
97   #else
98     // fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace
99     #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_COLOR
100   #endif
101 #endif
102
103 bool g_suspend_state = false;
104
105 rgb_config_t rgb_matrix_config;
106
107 rgb_counters_t g_rgb_counters;
108 static uint32_t rgb_counters_buffer;
109
110 #ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
111 uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}};
112 #endif
113
114 #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
115   last_hit_t g_last_hit_tracker;
116   static last_hit_t last_hit_buffer;
117 #endif // RGB_MATRIX_KEYREACTIVE_ENABLED
118
119 uint32_t eeconfig_read_rgb_matrix(void) {
120   return eeprom_read_dword(EECONFIG_RGB_MATRIX);
121 }
122
123 void eeconfig_update_rgb_matrix(uint32_t val) {
124   eeprom_update_dword(EECONFIG_RGB_MATRIX, val);
125 }
126
127 void eeconfig_update_rgb_matrix_default(void) {
128   dprintf("eeconfig_update_rgb_matrix_default\n");
129   rgb_matrix_config.enable = 1;
130   rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE;
131   rgb_matrix_config.hue = 0;
132   rgb_matrix_config.sat = UINT8_MAX;
133   rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
134   rgb_matrix_config.speed = UINT8_MAX / 2;
135   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
136 }
137
138 void eeconfig_debug_rgb_matrix(void) {
139   dprintf("rgb_matrix_config eprom\n");
140   dprintf("rgb_matrix_config.enable = %d\n", rgb_matrix_config.enable);
141   dprintf("rgb_matrix_config.mode = %d\n", rgb_matrix_config.mode);
142   dprintf("rgb_matrix_config.hue = %d\n", rgb_matrix_config.hue);
143   dprintf("rgb_matrix_config.sat = %d\n", rgb_matrix_config.sat);
144   dprintf("rgb_matrix_config.val = %d\n", rgb_matrix_config.val);
145   dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed);
146 }
147
148 __attribute__ ((weak))
149 uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) {
150   return 0;
151 }
152
153 uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) {
154   uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i);
155   uint8_t led_index = g_led_config.matrix_co[row][column];
156   if (led_index != NO_LED) {
157     led_i[led_count] = led_index;
158     led_count++;
159   }
160   return led_count;
161 }
162
163 void rgb_matrix_update_pwm_buffers(void) {
164   rgb_matrix_driver.flush();
165 }
166
167 void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) {
168   rgb_matrix_driver.set_color(index, red, green, blue);
169 }
170
171 void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) {
172   rgb_matrix_driver.set_color_all(red, green, blue);
173 }
174
175 bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
176 #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
177   uint8_t led[LED_HITS_TO_REMEMBER];
178   uint8_t led_count = 0;
179
180 #if defined(RGB_MATRIX_KEYRELEASES)
181   if (!record->event.pressed) {
182     led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led);
183     g_rgb_counters.any_key_hit = 0;
184   }
185 #elif defined(RGB_MATRIX_KEYPRESSES)
186   if (record->event.pressed) {
187     led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led);
188     g_rgb_counters.any_key_hit = 0;
189   }
190 #endif // defined(RGB_MATRIX_KEYRELEASES)
191
192   if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) {
193     memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count);
194     memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count);
195     memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit
196     memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count);
197     last_hit_buffer.count--;
198   }
199
200   for(uint8_t i = 0; i < led_count; i++) {
201     uint8_t index = last_hit_buffer.count;
202     last_hit_buffer.x[index] = g_led_config.point[led[i]].x;
203     last_hit_buffer.y[index] = g_led_config.point[led[i]].y;
204     last_hit_buffer.index[index] = led[i];
205     last_hit_buffer.tick[index] = 0;
206     last_hit_buffer.count++;
207   }
208 #endif // RGB_MATRIX_KEYREACTIVE_ENABLED
209
210 #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)
211   if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) {
212     process_rgb_matrix_typing_heatmap(record);
213   }
214 #endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)
215
216   return true;
217 }
218
219 void rgb_matrix_test(void) {
220   // Mask out bits 4 and 5
221   // Increase the factor to make the test animation slower (and reduce to make it faster)
222   uint8_t factor = 10;
223   switch ( (g_rgb_counters.tick & (0b11 << factor)) >> factor )
224   {
225     case 0: {
226       rgb_matrix_set_color_all( 20, 0, 0 );
227       break;
228     }
229     case 1: {
230       rgb_matrix_set_color_all( 0, 20, 0 );
231       break;
232     }
233     case 2: {
234       rgb_matrix_set_color_all( 0, 0, 20 );
235       break;
236     }
237     case 3: {
238       rgb_matrix_set_color_all( 20, 20, 20 );
239       break;
240     }
241   }
242 }
243
244 static bool rgb_matrix_none(effect_params_t* params) {
245   if (!params->init) {
246     return false;
247   }
248
249   RGB_MATRIX_USE_LIMITS(led_min, led_max);
250   for (uint8_t i = led_min; i < led_max; i++) {
251     rgb_matrix_set_color(i, 0, 0, 0);
252   }
253   return led_max < DRIVER_LED_TOTAL;
254 }
255
256 static uint8_t rgb_last_enable = UINT8_MAX;
257 static uint8_t rgb_last_effect = UINT8_MAX;
258 static effect_params_t rgb_effect_params = { 0, 0xFF };
259 static rgb_task_states rgb_task_state = SYNCING;
260
261 static void rgb_task_timers(void) {
262   // Update double buffer timers
263   uint16_t deltaTime = timer_elapsed32(rgb_counters_buffer);
264   rgb_counters_buffer = timer_read32();
265   if (g_rgb_counters.any_key_hit < UINT32_MAX) {
266     if (UINT32_MAX - deltaTime < g_rgb_counters.any_key_hit) {
267       g_rgb_counters.any_key_hit = UINT32_MAX;
268     } else {
269       g_rgb_counters.any_key_hit += deltaTime;
270     }
271   }
272
273   // Update double buffer last hit timers
274 #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
275   uint8_t count = last_hit_buffer.count;
276   for (uint8_t i = 0; i < count; ++i) {
277     if (UINT16_MAX - deltaTime < last_hit_buffer.tick[i]) {
278       last_hit_buffer.count--;
279       continue;
280     }
281     last_hit_buffer.tick[i] += deltaTime;
282   }
283 #endif // RGB_MATRIX_KEYREACTIVE_ENABLED
284 }
285
286 static void rgb_task_sync(void) {
287   // next task
288   if (timer_elapsed32(g_rgb_counters.tick) >= RGB_MATRIX_LED_FLUSH_LIMIT)
289     rgb_task_state = STARTING;
290 }
291
292 static void rgb_task_start(void) {
293   // reset iter
294   rgb_effect_params.iter = 0;
295
296   // update double buffers
297   g_rgb_counters.tick = rgb_counters_buffer;
298 #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
299   g_last_hit_tracker = last_hit_buffer;
300 #endif // RGB_MATRIX_KEYREACTIVE_ENABLED
301
302   // next task
303   rgb_task_state = RENDERING;
304 }
305
306 static void rgb_task_render(uint8_t effect) {
307   bool rendering = false;
308   rgb_effect_params.init = (effect != rgb_last_effect) || (rgb_matrix_config.enable != rgb_last_enable);
309
310   // each effect can opt to do calculations
311   // and/or request PWM buffer updates.
312   switch (effect) {
313     case RGB_MATRIX_NONE:
314       rendering = rgb_matrix_none(&rgb_effect_params);
315       break;
316
317 // ---------------------------------------------
318 // -----Begin rgb effect switch case macros-----
319 #define RGB_MATRIX_EFFECT(name, ...) \
320     case RGB_MATRIX_##name: \
321       rendering = name(&rgb_effect_params); \
322       break;
323 #include "rgb_matrix_animations/rgb_matrix_effects.inc"
324 #undef RGB_MATRIX_EFFECT
325
326 #if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER)
327   #define RGB_MATRIX_EFFECT(name, ...) \
328     case RGB_MATRIX_CUSTOM_##name: \
329       rendering = name(&rgb_effect_params); \
330       break;
331   #ifdef RGB_MATRIX_CUSTOM_KB
332     #include "rgb_matrix_kb.inc"
333   #endif
334   #ifdef RGB_MATRIX_CUSTOM_USER
335     #include "rgb_matrix_user.inc"
336   #endif
337   #undef RGB_MATRIX_EFFECT
338 #endif
339 // -----End rgb effect switch case macros-------
340 // ---------------------------------------------
341
342     // Factory default magic value
343     case UINT8_MAX: {
344         rgb_matrix_test();
345         rgb_task_state = FLUSHING;
346       }
347       return;
348   }
349
350   rgb_effect_params.iter++;
351
352   // next task
353   if (!rendering) {
354     rgb_task_state = FLUSHING;
355     if (!rgb_effect_params.init && effect == RGB_MATRIX_NONE) {
356       // We only need to flush once if we are RGB_MATRIX_NONE
357       rgb_task_state = SYNCING;
358     }
359   }
360 }
361
362 static void rgb_task_flush(uint8_t effect) {
363   // update last trackers after the first full render so we can init over several frames
364   rgb_last_effect = effect;
365   rgb_last_enable = rgb_matrix_config.enable;
366
367   // update pwm buffers
368   rgb_matrix_update_pwm_buffers();
369
370   // next task
371   rgb_task_state = SYNCING;
372 }
373
374 void rgb_matrix_task(void) {
375   rgb_task_timers();
376
377   // Ideally we would also stop sending zeros to the LED driver PWM buffers
378   // while suspended and just do a software shutdown. This is a cheap hack for now.
379   bool suspend_backlight = ((g_suspend_state && RGB_DISABLE_WHEN_USB_SUSPENDED) || (RGB_DISABLE_AFTER_TIMEOUT > 0 && g_rgb_counters.any_key_hit > RGB_DISABLE_AFTER_TIMEOUT * 60 * 20));
380   uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode;
381
382   switch (rgb_task_state) {
383     case STARTING:
384       rgb_task_start();
385       break;
386     case RENDERING:
387       rgb_task_render(effect);
388       break;
389     case FLUSHING:
390       rgb_task_flush(effect);
391       break;
392     case SYNCING:
393       rgb_task_sync();
394       break;
395   }
396
397   if (!suspend_backlight) {
398     rgb_matrix_indicators();
399   }
400 }
401
402 void rgb_matrix_indicators(void) {
403   rgb_matrix_indicators_kb();
404   rgb_matrix_indicators_user();
405 }
406
407 __attribute__((weak))
408 void rgb_matrix_indicators_kb(void) {}
409
410 __attribute__((weak))
411 void rgb_matrix_indicators_user(void) {}
412
413 void rgb_matrix_init(void) {
414   rgb_matrix_driver.init();
415
416   // TODO: put the 1 second startup delay here?
417
418 #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
419   g_last_hit_tracker.count = 0;
420   for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) {
421     g_last_hit_tracker.tick[i] = UINT16_MAX;
422   }
423
424   last_hit_buffer.count = 0;
425   for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) {
426     last_hit_buffer.tick[i] = UINT16_MAX;
427   }
428 #endif // RGB_MATRIX_KEYREACTIVE_ENABLED
429
430   if (!eeconfig_is_enabled()) {
431     dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n");
432     eeconfig_init();
433     eeconfig_update_rgb_matrix_default();
434   }
435
436   rgb_matrix_config.raw = eeconfig_read_rgb_matrix();
437   rgb_matrix_config.speed = UINT8_MAX / 2; //EECONFIG needs to be increased to support this
438   if (!rgb_matrix_config.mode) {
439     dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n");
440     eeconfig_update_rgb_matrix_default();
441     rgb_matrix_config.raw = eeconfig_read_rgb_matrix();
442   }
443   eeconfig_debug_rgb_matrix(); // display current eeprom values
444 }
445
446 void rgb_matrix_set_suspend_state(bool state) {
447   g_suspend_state = state;
448 }
449
450 void rgb_matrix_toggle(void) {
451   rgb_matrix_config.enable ^= 1;
452   rgb_task_state = STARTING;
453   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
454 }
455
456 void rgb_matrix_enable(void) {
457   rgb_matrix_enable_noeeprom();
458   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
459 }
460
461 void rgb_matrix_enable_noeeprom(void) {
462   if (!rgb_matrix_config.enable)
463     rgb_task_state = STARTING;
464   rgb_matrix_config.enable = 1;
465 }
466
467 void rgb_matrix_disable(void) {
468   rgb_matrix_disable_noeeprom();
469   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
470 }
471
472 void rgb_matrix_disable_noeeprom(void) {
473   if (rgb_matrix_config.enable)
474     rgb_task_state = STARTING;
475   rgb_matrix_config.enable = 0;
476 }
477
478 void rgb_matrix_step(void) {
479   rgb_matrix_config.mode++;
480   if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX)
481     rgb_matrix_config.mode = 1;
482   rgb_task_state = STARTING;
483   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
484 }
485
486 void rgb_matrix_step_reverse(void) {
487   rgb_matrix_config.mode--;
488   if (rgb_matrix_config.mode < 1)
489     rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1;
490   rgb_task_state = STARTING;
491   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
492 }
493
494 void rgb_matrix_increase_hue(void) {
495   rgb_matrix_config.hue += RGB_MATRIX_HUE_STEP;
496   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
497 }
498
499 void rgb_matrix_decrease_hue(void) {
500   rgb_matrix_config.hue -= RGB_MATRIX_HUE_STEP;
501   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
502 }
503
504 void rgb_matrix_increase_sat(void) {
505   rgb_matrix_config.sat = qadd8(rgb_matrix_config.sat, RGB_MATRIX_SAT_STEP);
506   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
507 }
508
509 void rgb_matrix_decrease_sat(void) {
510   rgb_matrix_config.sat = qsub8(rgb_matrix_config.sat, RGB_MATRIX_SAT_STEP);
511   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
512 }
513
514 void rgb_matrix_increase_val(void) {
515   rgb_matrix_config.val = qadd8(rgb_matrix_config.val, RGB_MATRIX_VAL_STEP);
516   if (rgb_matrix_config.val > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
517     rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
518   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
519 }
520
521 void rgb_matrix_decrease_val(void) {
522   rgb_matrix_config.val = qsub8(rgb_matrix_config.val, RGB_MATRIX_VAL_STEP);
523   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
524 }
525
526 void rgb_matrix_increase_speed(void) {
527   rgb_matrix_config.speed = qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP);
528   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this
529 }
530
531 void rgb_matrix_decrease_speed(void) {
532   rgb_matrix_config.speed = qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP);
533   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this
534 }
535
536 led_flags_t rgb_matrix_get_flags(void) {
537   return rgb_effect_params.flags;
538 }
539
540 void rgb_matrix_set_flags(led_flags_t flags) {
541   rgb_effect_params.flags = flags;
542 }
543
544 void rgb_matrix_mode(uint8_t mode) {
545   rgb_matrix_config.mode = mode;
546   rgb_task_state = STARTING;
547   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
548 }
549
550 void rgb_matrix_mode_noeeprom(uint8_t mode) {
551   rgb_matrix_config.mode = mode;
552 }
553
554 uint8_t rgb_matrix_get_mode(void) {
555   return rgb_matrix_config.mode;
556 }
557
558 void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
559   rgb_matrix_sethsv_noeeprom(hue, sat, val);
560   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
561 }
562
563 void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) {
564   rgb_matrix_config.hue = hue;
565   rgb_matrix_config.sat = sat;
566   rgb_matrix_config.val = val;
567   if (rgb_matrix_config.val > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
568     rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
569 }