qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

rgb_matrix_user.inc (27833B)


      1 /*
      2 Copyright 2020 Evy Dekkers
      3 
      4 This program is free software: you can redistribute it and/or modify
      5 it under the terms of the GNU General Public License as published by
      6 the Free Software Foundation, either version 2 of the License, or
      7 (at your option) any later version.
      8 
      9 This program is distributed in the hope that it will be useful,
     10 but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 GNU General Public License for more details.
     13 
     14 You should have received a copy of the GNU General Public License
     15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16 */
     17 
     18 RGB_MATRIX_EFFECT(solid_esc)
     19 RGB_MATRIX_EFFECT(solid_f13)
     20 RGB_MATRIX_EFFECT(solid_clus)
     21 RGB_MATRIX_EFFECT(breathing_all)
     22 RGB_MATRIX_EFFECT(breathing_esc)
     23 RGB_MATRIX_EFFECT(breathing_f13)
     24 RGB_MATRIX_EFFECT(breathing_clus)
     25 RGB_MATRIX_EFFECT(band_val_all)
     26 RGB_MATRIX_EFFECT(band_val_esc)
     27 RGB_MATRIX_EFFECT(band_val_f13)
     28 RGB_MATRIX_EFFECT(band_val_clus)
     29 RGB_MATRIX_EFFECT(cycle_up_down_all)
     30 RGB_MATRIX_EFFECT(cycle_up_down_esc)
     31 RGB_MATRIX_EFFECT(cycle_up_down_f13)
     32 RGB_MATRIX_EFFECT(cycle_up_down_clus)
     33 RGB_MATRIX_EFFECT(cycle_out_in_dual_all)
     34 RGB_MATRIX_EFFECT(cycle_out_in_dual_esc)
     35 RGB_MATRIX_EFFECT(cycle_out_in_dual_f13)
     36 RGB_MATRIX_EFFECT(cycle_out_in_dual_clus)
     37 RGB_MATRIX_EFFECT(rainbow_moving_chevron_all)
     38 RGB_MATRIX_EFFECT(rainbow_moving_chevron_esc)
     39 RGB_MATRIX_EFFECT(rainbow_moving_chevron_f13)
     40 RGB_MATRIX_EFFECT(rainbow_moving_chevron_clus)
     41 RGB_MATRIX_EFFECT(cycle_pimwheel_all)
     42 RGB_MATRIX_EFFECT(cycle_pimwheel_esc)
     43 RGB_MATRIX_EFFECT(cycle_pimwheel_f13)
     44 RGB_MATRIX_EFFECT(cycle_pimwheel_clus)
     45 RGB_MATRIX_EFFECT(rainbow_beacon_all)
     46 RGB_MATRIX_EFFECT(rainbow_beacon_esc)
     47 RGB_MATRIX_EFFECT(rainbow_beacon_f13)
     48 RGB_MATRIX_EFFECT(rainbow_beacon_clus)
     49 RGB_MATRIX_EFFECT(raindrops_all)
     50 RGB_MATRIX_EFFECT(raindrops_esc)
     51 RGB_MATRIX_EFFECT(raindrops_f13)
     52 RGB_MATRIX_EFFECT(raindrops_clus)
     53 
     54 #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
     55 
     56 bool effect_runner_all(effect_params_t* params, i_f effect_func) {
     57     RGB_MATRIX_USE_LIMITS(led_min, led_max);
     58 
     59     uint8_t time = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed / 4, 1));
     60     for (uint8_t i = led_min; i < led_max; i++) {
     61         RGB_MATRIX_TEST_LED_FLAGS();
     62         rgb_t rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
     63         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
     64     }
     65     return led_max < RGB_MATRIX_LED_COUNT;
     66 }
     67 
     68 bool effect_runner_esc(effect_params_t* params, i_f effect_func) {
     69     RGB_MATRIX_USE_LIMITS(led_min, led_max);
     70 
     71     uint8_t time = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed / 4, 1));
     72     for (uint8_t i = led_min; i < led_max; i++) {
     73         RGB_MATRIX_TEST_LED_FLAGS();
     74         rgb_t rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
     75         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
     76     }
     77     for (uint8_t i = 1; i < 18; i++) {
     78         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
     79     }
     80     return led_max < RGB_MATRIX_LED_COUNT;
     81 }
     82 
     83 bool effect_runner_f13(effect_params_t* params, i_f effect_func) {
     84     RGB_MATRIX_USE_LIMITS(led_min, led_max);
     85     uint8_t time = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed / 4, 1));
     86     for (uint8_t i = led_min; i < led_max; i++) {
     87         RGB_MATRIX_TEST_LED_FLAGS();
     88         rgb_t rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
     89         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
     90         rgb_matrix_set_color(15, 0x00, 0x00, 0x00);
     91         rgb_matrix_set_color(16, 0x00, 0x00, 0x00);
     92         rgb_matrix_set_color(17, 0x00, 0x00, 0x00);
     93     }
     94     for (uint8_t i = 0; i < 14; i++) {
     95         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
     96     }
     97     return led_max < RGB_MATRIX_LED_COUNT;
     98 }
     99 
    100 bool effect_runner_clus(effect_params_t* params, i_f effect_func) {
    101     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    102 
    103     uint8_t time = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed / 4, 1));
    104     for (uint8_t i = led_min; i < led_max; i++) {
    105         RGB_MATRIX_TEST_LED_FLAGS();
    106         rgb_t rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
    107         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    108     }
    109     for (uint8_t i = 0; i < 15; i++) {
    110         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    111     }
    112     return led_max < RGB_MATRIX_LED_COUNT;
    113 }
    114 
    115 bool effect_runner_dx_dy_all(effect_params_t* params, dx_dy_f effect_func) {
    116     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    117 
    118     uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 2);
    119     for (uint8_t i = led_min; i < led_max; i++) {
    120         RGB_MATRIX_TEST_LED_FLAGS();
    121         int16_t dx  = g_led_config.point[i].x - k_rgb_matrix_center.x;
    122         int16_t dy  = g_led_config.point[i].y - k_rgb_matrix_center.y;
    123         rgb_t   rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, time));
    124         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    125     }
    126     return led_max < RGB_MATRIX_LED_COUNT;
    127 }
    128 
    129 bool effect_runner_dx_dy_esc(effect_params_t* params, dx_dy_f effect_func) {
    130     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    131 
    132     uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 2);
    133     for (uint8_t i = led_min; i < led_max; i++) {
    134         RGB_MATRIX_TEST_LED_FLAGS();
    135         int16_t dx  = g_led_config.point[i].x - k_rgb_matrix_center.x;
    136         int16_t dy  = g_led_config.point[i].y - k_rgb_matrix_center.y;
    137         rgb_t   rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, time));
    138         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    139     }
    140     for (uint8_t i = 1; i < 18; i++) {
    141         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    142     }
    143     return led_max < RGB_MATRIX_LED_COUNT;
    144 }
    145 
    146 bool effect_runner_dx_dy_f13(effect_params_t* params, dx_dy_f effect_func) {
    147     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    148 
    149     uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 2);
    150     for (uint8_t i = led_min; i < led_max; i++) {
    151         RGB_MATRIX_TEST_LED_FLAGS();
    152         int16_t dx  = g_led_config.point[i].x - k_rgb_matrix_center.x;
    153         int16_t dy  = g_led_config.point[i].y - k_rgb_matrix_center.y;
    154         rgb_t   rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, time));
    155         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    156         rgb_matrix_set_color(15, 0x00, 0x00, 0x00);
    157         rgb_matrix_set_color(16, 0x00, 0x00, 0x00);
    158         rgb_matrix_set_color(17, 0x00, 0x00, 0x00);
    159     }
    160     for (uint8_t i = 0; i < 14; i++) {
    161         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    162     }
    163     return led_max < RGB_MATRIX_LED_COUNT;
    164 }
    165 
    166 bool effect_runner_dx_dy_clus(effect_params_t* params, dx_dy_f effect_func) {
    167     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    168 
    169     uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 2);
    170     for (uint8_t i = led_min; i < led_max; i++) {
    171         RGB_MATRIX_TEST_LED_FLAGS();
    172         int16_t dx  = g_led_config.point[i].x - k_rgb_matrix_center.x;
    173         int16_t dy  = g_led_config.point[i].y - k_rgb_matrix_center.y;
    174         rgb_t   rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, time));
    175         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    176     }
    177     for (uint8_t i = 0; i < 15; i++) {
    178         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    179     }
    180     return led_max < RGB_MATRIX_LED_COUNT;
    181 }
    182 
    183 bool effect_runner_sin_cos_all(effect_params_t* params, sin_cos_i_f effect_func) {
    184     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    185 
    186     uint16_t time      = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4);
    187     int8_t   cos_value = cos8(time) - 128;
    188     int8_t   sin_value = sin8(time) - 128;
    189     for (uint8_t i = led_min; i < led_max; i++) {
    190         RGB_MATRIX_TEST_LED_FLAGS();
    191         rgb_t rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, cos_value, sin_value, i, time));
    192         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    193     }
    194     return led_max < RGB_MATRIX_LED_COUNT;
    195 }
    196 
    197 bool effect_runner_sin_cos_esc(effect_params_t* params, sin_cos_i_f effect_func) {
    198     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    199 
    200     uint16_t time      = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4);
    201     int8_t   cos_value = cos8(time) - 128;
    202     int8_t   sin_value = sin8(time) - 128;
    203     for (uint8_t i = led_min; i < led_max; i++) {
    204         RGB_MATRIX_TEST_LED_FLAGS();
    205         rgb_t rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, cos_value, sin_value, i, time));
    206         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    207     }
    208     for (uint8_t i = 1; i < 18; i++) {
    209         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    210     }
    211     return led_max < RGB_MATRIX_LED_COUNT;
    212 }
    213 
    214 bool effect_runner_sin_cos_f13(effect_params_t* params, sin_cos_i_f effect_func) {
    215     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    216 
    217     uint16_t time      = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4);
    218     int8_t   cos_value = cos8(time) - 128;
    219     int8_t   sin_value = sin8(time) - 128;
    220     for (uint8_t i = led_min; i < led_max; i++) {
    221         RGB_MATRIX_TEST_LED_FLAGS();
    222         rgb_t rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, cos_value, sin_value, i, time));
    223         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    224         rgb_matrix_set_color(15, 0x00, 0x00, 0x00);
    225         rgb_matrix_set_color(16, 0x00, 0x00, 0x00);
    226         rgb_matrix_set_color(17, 0x00, 0x00, 0x00);
    227     }
    228     for (uint8_t i = 0; i < 14; i++) {
    229         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    230     }
    231     return led_max < RGB_MATRIX_LED_COUNT;
    232 }
    233 
    234 bool effect_runner_sin_cos_clus(effect_params_t* params, sin_cos_i_f effect_func) {
    235     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    236 
    237     uint16_t time      = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4);
    238     int8_t   cos_value = cos8(time) - 128;
    239     int8_t   sin_value = sin8(time) - 128;
    240     for (uint8_t i = led_min; i < led_max; i++) {
    241         RGB_MATRIX_TEST_LED_FLAGS();
    242         rgb_t rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, cos_value, sin_value, i, time));
    243         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    244     }
    245     for (uint8_t i = 0; i < 15; i++) {
    246         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    247     }
    248     return led_max < RGB_MATRIX_LED_COUNT;
    249 }
    250 
    251 static void raindrops_set_color_all(int i, effect_params_t* params) {
    252     if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
    253     hsv_t hsv = {0, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v};
    254 
    255     // Take the shortest path between hues
    256     int16_t deltaH = ((rgb_matrix_config.hsv.h + 180) % 360 - rgb_matrix_config.hsv.h) / 4;
    257     if (deltaH > 127) {
    258         deltaH -= 256;
    259     } else if (deltaH < -127) {
    260         deltaH += 256;
    261     }
    262 
    263     hsv.h     = rgb_matrix_config.hsv.h + (deltaH * (rand() & 0x03));
    264     rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv);
    265     rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    266 }
    267 
    268 static void raindrops_set_color_esc(int i, effect_params_t* params) {
    269     if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
    270     hsv_t hsv = {0, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v};
    271 
    272     // Take the shortest path between hues
    273     int16_t deltaH = ((rgb_matrix_config.hsv.h + 180) % 360 - rgb_matrix_config.hsv.h) / 4;
    274     if (deltaH > 127) {
    275         deltaH -= 256;
    276     } else if (deltaH < -127) {
    277         deltaH += 256;
    278     }
    279 
    280     hsv.h     = rgb_matrix_config.hsv.h + (deltaH * (rand() & 0x03));
    281     rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv);
    282     rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    283     for (uint8_t i = 1; i < 18; i++) {
    284         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    285     }
    286 }
    287 
    288 static void raindrops_set_color_f13(int i, effect_params_t* params) {
    289     if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
    290     hsv_t hsv = {0, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v};
    291 
    292     // Take the shortest path between hues
    293     int16_t deltaH = ((rgb_matrix_config.hsv.h + 180) % 360 - rgb_matrix_config.hsv.h) / 4;
    294     if (deltaH > 127) {
    295         deltaH -= 256;
    296     } else if (deltaH < -127) {
    297         deltaH += 256;
    298     }
    299 
    300     hsv.h     = rgb_matrix_config.hsv.h + (deltaH * (rand() & 0x03));
    301     rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv);
    302     rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    303         rgb_matrix_set_color(15, 0x00, 0x00, 0x00);
    304         rgb_matrix_set_color(16, 0x00, 0x00, 0x00);
    305         rgb_matrix_set_color(17, 0x00, 0x00, 0x00);
    306     for (uint8_t i = 0; i < 14; i++) {
    307         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    308     }
    309 }
    310 
    311 static void raindrops_set_color_clus(int i, effect_params_t* params) {
    312     if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
    313     hsv_t hsv = {0, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v};
    314 
    315     // Take the shortest path between hues
    316     int16_t deltaH = ((rgb_matrix_config.hsv.h + 180) % 360 - rgb_matrix_config.hsv.h) / 4;
    317     if (deltaH > 127) {
    318         deltaH -= 256;
    319     } else if (deltaH < -127) {
    320         deltaH += 256;
    321     }
    322 
    323     hsv.h     = rgb_matrix_config.hsv.h + (deltaH * (rand() & 0x03));
    324     rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv);
    325     rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    326     for (uint8_t i = 0; i < 15; i++) {
    327         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    328     }
    329 }
    330 
    331 static hsv_t BAND_VAL_CUSTOM(hsv_t hsv, uint8_t i, uint8_t time) {
    332     int16_t v = hsv.v - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8;
    333     hsv.v     = scale8(v < 0 ? 0 : v, hsv.v);
    334     return hsv;
    335 }
    336 
    337 static hsv_t CYCLE_UP_DOWN_CUSTOM(hsv_t hsv, uint8_t i, uint8_t time) {
    338         hsv.h = g_led_config.point[i].y - time;
    339     return hsv;
    340 }
    341 
    342 static hsv_t CYCLE_OUT_IN_DUAL_CUSTOM(hsv_t hsv, int16_t dx, int16_t dy, uint8_t time) {
    343     dx           = (k_rgb_matrix_center.x / 2) - abs8(dx);
    344     uint8_t dist = sqrt16(dx * dx + dy * dy);
    345     hsv.h        = 3 * dist + time;
    346     return hsv;
    347 }
    348 
    349 static hsv_t RAINBOW_MOVING_CHEVRON_CUSTOM(hsv_t hsv, uint8_t i, uint8_t time) {
    350     hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time);
    351     return hsv;
    352 }
    353 
    354 static hsv_t CYCLE_PINWHEEL_CUSTOM(hsv_t hsv, int16_t dx, int16_t dy, uint8_t time) {
    355     hsv.h = atan2_8(dy, dx) + time;
    356     return hsv;
    357 }
    358 
    359 static hsv_t RAINBOW_BEACON_CUSTOM(hsv_t hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
    360     hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 2 * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * 2 * sin) / 128;
    361     return hsv;
    362 }
    363 
    364 
    365 
    366 // Solid ESC
    367 static bool solid_esc(effect_params_t* params) {
    368     hsv_t hsv = rgb_matrix_config.hsv;
    369     rgb_t rgb = hsv_to_rgb(hsv);
    370     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    371     for (uint8_t i = led_min ; i < led_max; i++) {
    372         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    373     }
    374     for (uint8_t i = 18 ; i < led_max; i++) {
    375         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    376         rgb_matrix_set_color(0, rgb.r, rgb.g, rgb.b);
    377     }
    378     return led_max < RGB_MATRIX_LED_COUNT;
    379 }
    380 
    381 // Solid F13
    382 static bool solid_f13(effect_params_t* params) {
    383     hsv_t hsv = rgb_matrix_config.hsv;
    384     rgb_t rgb = hsv_to_rgb(hsv);
    385     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    386     for (uint8_t i = led_min ; i < led_max; i++) {
    387         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    388     }
    389     for (uint8_t i = 18 ; i < led_max; i++) {
    390         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    391         rgb_matrix_set_color(14, rgb.r, rgb.g, rgb.b);
    392     }
    393     return led_max < RGB_MATRIX_LED_COUNT;
    394 }
    395 
    396 // Solid cluster
    397 static bool solid_clus(effect_params_t* params) {
    398     hsv_t hsv = rgb_matrix_config.hsv;
    399     rgb_t rgb = hsv_to_rgb(hsv);
    400     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    401     for (uint8_t i = led_min ; i < led_max; i++) {
    402         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    403     }
    404     for (uint8_t i = 15 ; i < led_max; i++) {
    405         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    406     }
    407     return led_max < RGB_MATRIX_LED_COUNT;
    408 }
    409 
    410 // Breathing all
    411 
    412 bool breathing_all(effect_params_t* params) {
    413     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    414 
    415     hsv_t    hsv  = rgb_matrix_config.hsv;
    416     uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8);
    417     hsv.v         = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
    418     rgb_t rgb     = rgb_matrix_hsv_to_rgb(hsv);
    419     for (uint8_t i = led_min; i < led_max; i++) {
    420         RGB_MATRIX_TEST_LED_FLAGS();
    421         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    422     }
    423     return led_max < RGB_MATRIX_LED_COUNT;
    424 }
    425 
    426 // Breathing ESC
    427 static bool breathing_esc(effect_params_t* params) {
    428     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    429 
    430     hsv_t    hsv  = rgb_matrix_config.hsv;
    431     uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8);
    432     hsv.v         = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
    433     rgb_t rgb     = rgb_matrix_hsv_to_rgb(hsv);
    434     for (uint8_t i = led_min ; i < led_max; i++) {
    435         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    436     }
    437     for (uint8_t i = 18; i < led_max; i++) {
    438         RGB_MATRIX_TEST_LED_FLAGS();
    439         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    440     }
    441         rgb_matrix_set_color(0, rgb.r, rgb.g, rgb.b);
    442     return led_max < RGB_MATRIX_LED_COUNT;
    443 }
    444 
    445 // Breathing F13
    446 static bool breathing_f13(effect_params_t* params) {
    447     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    448 
    449     hsv_t    hsv  = rgb_matrix_config.hsv;
    450     uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8);
    451     hsv.v         = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
    452     rgb_t rgb     = rgb_matrix_hsv_to_rgb(hsv);
    453     for (uint8_t i = led_min ; i < led_max; i++) {
    454         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    455     }
    456     for (uint8_t i = 18; i < led_max; i++) {
    457         RGB_MATRIX_TEST_LED_FLAGS();
    458         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    459     }
    460         rgb_matrix_set_color(14, rgb.r, rgb.g, rgb.b);
    461     return led_max < RGB_MATRIX_LED_COUNT;  
    462 }
    463 
    464 // Breathing cluster
    465 static bool breathing_clus(effect_params_t* params) {
    466     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    467 
    468     hsv_t    hsv  = rgb_matrix_config.hsv;
    469     uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8);
    470     hsv.v         = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
    471     rgb_t rgb     = rgb_matrix_hsv_to_rgb(hsv);
    472     for (uint8_t i = led_min ; i < led_max; i++) {
    473         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    474     }
    475     for (uint8_t i = 15; i < led_max; i++) {
    476         RGB_MATRIX_TEST_LED_FLAGS();
    477         rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
    478     }
    479     return led_max < RGB_MATRIX_LED_COUNT;
    480 }
    481 
    482 // Band Val all
    483 bool band_val_all(effect_params_t* params) { 
    484     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    485     for (uint8_t i = led_min ; i < led_max; i++) {
    486         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    487     }
    488     return effect_runner_all(params, &BAND_VAL_CUSTOM); 
    489 }
    490 
    491 // Band Val ESC
    492 bool band_val_esc(effect_params_t* params) { 
    493     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    494     for (uint8_t i = led_min ; i < led_max; i++) {
    495         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    496     }
    497     return effect_runner_esc(params, &BAND_VAL_CUSTOM); 
    498 }
    499 
    500 // Band Val F13
    501 bool band_val_f13(effect_params_t* params) {
    502     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    503     for (uint8_t i = led_min ; i < led_max; i++) {
    504         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    505     }
    506     return effect_runner_f13(params, &BAND_VAL_CUSTOM); 
    507 }
    508 
    509 // Band Val Cluster
    510 bool band_val_clus(effect_params_t* params) {
    511     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    512     for (uint8_t i = led_min ; i < led_max; i++) {
    513         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    514     }
    515     return effect_runner_clus(params, &BAND_VAL_CUSTOM); 
    516 }
    517 
    518 // Cycle Up Down All
    519 static bool cycle_up_down_all(effect_params_t* params) {
    520     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    521     for (uint8_t i = led_min ; i < led_max; i++) {
    522         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    523     }
    524     return effect_runner_all(params, &CYCLE_UP_DOWN_CUSTOM);
    525 }
    526 
    527 // Cycle Up Down ESC
    528 static bool cycle_up_down_esc(effect_params_t* params) {
    529     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    530     for (uint8_t i = led_min ; i < led_max; i++) {
    531         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    532     }
    533     return effect_runner_esc(params, &CYCLE_UP_DOWN_CUSTOM);
    534 }
    535 
    536 // Cycle up down F13
    537 static bool cycle_up_down_f13(effect_params_t* params) {
    538     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    539     for (uint8_t i = led_min ; i < led_max; i++) {
    540         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    541     }
    542     return effect_runner_f13(params, &CYCLE_UP_DOWN_CUSTOM);
    543 }
    544 
    545 // Cycle up down cluster
    546 static bool cycle_up_down_clus(effect_params_t* params) {
    547     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    548     for (uint8_t i = led_min ; i < led_max; i++) {
    549         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    550     }
    551     return effect_runner_clus(params, &CYCLE_UP_DOWN_CUSTOM);
    552 }
    553 
    554 // Cycle out in dual All
    555 static bool cycle_out_in_dual_all(effect_params_t* params) { 
    556     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    557     for (uint8_t i = led_min ; i < led_max; i++) {
    558         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    559     }
    560     return effect_runner_dx_dy_all(params, &CYCLE_OUT_IN_DUAL_CUSTOM); 
    561 }
    562 
    563 // Cycle out in dual ESC
    564 static bool cycle_out_in_dual_esc(effect_params_t* params) { 
    565     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    566     for (uint8_t i = led_min ; i < led_max; i++) {
    567         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    568     }
    569     return effect_runner_dx_dy_esc(params, &CYCLE_OUT_IN_DUAL_CUSTOM); 
    570 }
    571 
    572 // Cycle out in dual f13
    573 static bool cycle_out_in_dual_f13(effect_params_t* params) { 
    574     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    575     for (uint8_t i = led_min ; i < led_max; i++) {
    576         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    577     }
    578     return effect_runner_dx_dy_f13(params, &CYCLE_OUT_IN_DUAL_CUSTOM); 
    579 }
    580 
    581 // Cycle out in dual cluster
    582 static bool cycle_out_in_dual_clus(effect_params_t* params) { 
    583     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    584     for (uint8_t i = led_min ; i < led_max; i++) {
    585         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    586     }
    587     return effect_runner_dx_dy_clus(params, &CYCLE_OUT_IN_DUAL_CUSTOM); 
    588 }
    589 
    590 // Moving chevron all
    591 static bool rainbow_moving_chevron_all(effect_params_t* params) { 
    592     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    593     for (uint8_t i = led_min ; i < led_max; i++) {
    594         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    595     }
    596     return effect_runner_all(params, &RAINBOW_MOVING_CHEVRON_CUSTOM); 
    597 }
    598 
    599 // Moving chevron ESC
    600 static bool rainbow_moving_chevron_esc(effect_params_t* params) { 
    601     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    602     for (uint8_t i = led_min ; i < led_max; i++) {
    603         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    604     }
    605     return effect_runner_esc(params, &RAINBOW_MOVING_CHEVRON_CUSTOM); 
    606 }
    607 // Moving chevron F13
    608 static bool rainbow_moving_chevron_f13(effect_params_t* params) { 
    609     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    610     for (uint8_t i = led_min ; i < led_max; i++) {
    611         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    612     }
    613     return effect_runner_f13(params, &RAINBOW_MOVING_CHEVRON_CUSTOM); 
    614 }
    615 // Moving chevron cluster
    616 static bool rainbow_moving_chevron_clus(effect_params_t* params) { 
    617     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    618     for (uint8_t i = led_min ; i < led_max; i++) {
    619         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    620     }
    621     return effect_runner_clus(params, &RAINBOW_MOVING_CHEVRON_CUSTOM); 
    622 }
    623 
    624 // Moving cycle pimwheel all
    625 static bool cycle_pimwheel_all(effect_params_t* params) { 
    626     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    627     for (uint8_t i = led_min ; i < led_max; i++) {
    628         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    629     }
    630     return effect_runner_dx_dy_all(params, &CYCLE_PINWHEEL_CUSTOM); 
    631 }
    632 
    633 // Moving cycle pimwheel esc
    634 static bool cycle_pimwheel_esc(effect_params_t* params) { 
    635     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    636     for (uint8_t i = led_min ; i < led_max; i++) {
    637         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    638     }
    639     return effect_runner_dx_dy_esc(params, &CYCLE_PINWHEEL_CUSTOM); 
    640 }
    641 
    642 // Moving cycle pimwheel f13
    643 static bool cycle_pimwheel_f13(effect_params_t* params) { 
    644     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    645     for (uint8_t i = led_min ; i < led_max; i++) {
    646         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    647     }
    648     return effect_runner_dx_dy_f13(params, &CYCLE_PINWHEEL_CUSTOM); 
    649 }
    650 
    651 // Moving cycle pimwheel cluster
    652 static bool cycle_pimwheel_clus(effect_params_t* params) { 
    653     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    654     for (uint8_t i = led_min ; i < led_max; i++) {
    655         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    656     }
    657     return effect_runner_dx_dy_clus(params, &CYCLE_PINWHEEL_CUSTOM); 
    658 }
    659 
    660 // Moving rainbow beacon all
    661 static bool rainbow_beacon_all(effect_params_t* params) { 
    662     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    663     for (uint8_t i = led_min ; i < led_max; i++) {
    664         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    665     }
    666     return effect_runner_sin_cos_all(params, &RAINBOW_BEACON_CUSTOM); 
    667 }
    668 
    669 // Moving rainbow beacon esc
    670 static bool rainbow_beacon_esc(effect_params_t* params) { 
    671     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    672     for (uint8_t i = led_min ; i < led_max; i++) {
    673         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    674     }
    675     return effect_runner_sin_cos_esc(params, &RAINBOW_BEACON_CUSTOM); 
    676 }
    677 
    678 // Moving rainbow beacon f13
    679 static bool rainbow_beacon_f13(effect_params_t* params) { 
    680     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    681     for (uint8_t i = led_min ; i < led_max; i++) {
    682         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    683     }
    684     return effect_runner_sin_cos_f13(params, &RAINBOW_BEACON_CUSTOM); 
    685 }
    686 
    687 // Moving rainbow beacon cluster
    688 static bool rainbow_beacon_clus(effect_params_t* params) { 
    689     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    690     for (uint8_t i = led_min ; i < led_max; i++) {
    691         rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
    692     }
    693     return effect_runner_sin_cos_clus(params, &RAINBOW_BEACON_CUSTOM); 
    694 }
    695 
    696 // Raindrops all
    697 static bool raindrops_all(effect_params_t* params) { 
    698     if (!params->init) {
    699         // Change one LED every tick, make sure speed is not 0
    700         if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
    701             raindrops_set_color_all(rand() % RGB_MATRIX_LED_COUNT, params);
    702         }
    703         return false;
    704     }
    705 
    706     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    707     for (int i = led_min; i < led_max; i++) {
    708         raindrops_set_color_all(i, params);
    709     }
    710     return led_max < RGB_MATRIX_LED_COUNT;
    711 }
    712 
    713 // Raindrops ESC
    714 static bool raindrops_esc(effect_params_t* params) { 
    715     if (!params->init) {
    716         // Change one LED every tick, make sure speed is not 0
    717         if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
    718             raindrops_set_color_esc(rand() % RGB_MATRIX_LED_COUNT, params);
    719         }
    720         return false;
    721     }
    722 
    723     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    724     for (int i = led_min; i < led_max; i++) {
    725         raindrops_set_color_esc(i, params);
    726     }
    727     return led_max < RGB_MATRIX_LED_COUNT;
    728 }
    729 
    730 // Raindrops F13
    731 static bool raindrops_f13(effect_params_t* params) { 
    732     if (!params->init) {
    733         // Change one LED every tick, make sure speed is not 0
    734         if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
    735             raindrops_set_color_f13(rand() % RGB_MATRIX_LED_COUNT, params);
    736         }
    737         return false;
    738     }
    739 
    740     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    741     for (int i = led_min; i < led_max; i++) {
    742         raindrops_set_color_f13(i, params);
    743     }
    744     return led_max < RGB_MATRIX_LED_COUNT;
    745 }
    746 
    747 // Raindrops Cluster
    748 static bool raindrops_clus(effect_params_t* params) { 
    749     if (!params->init) {
    750         // Change one LED every tick, make sure speed is not 0
    751         if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
    752             raindrops_set_color_clus(rand() % RGB_MATRIX_LED_COUNT, params);
    753         }
    754         return false;
    755     }
    756 
    757     RGB_MATRIX_USE_LIMITS(led_min, led_max);
    758     for (int i = led_min; i < led_max; i++) {
    759         raindrops_set_color_clus(i, params);
    760     }
    761     return led_max < RGB_MATRIX_LED_COUNT;
    762 }
    763 
    764 #endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS