rgb_matrix_kb.inc (1783B)
1 // Step 1. 2 // Declare custom effects using the RGB_MATRIX_EFFECT macro 3 // (note the lack of semicolon after the macro!) 4 RGB_MATRIX_EFFECT(startup_animation_dots) 5 RGB_MATRIX_EFFECT(startup_animation_solid) 6 7 // Step 2. 8 // Define effects inside the `RGB_MATRIX_CUSTOM_EFFECT_IMPLS` ifdef block 9 #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 10 11 #include "eeprom.h" 12 #include "eeconfig.h" 13 14 static void startup_animation_setleds(effect_params_t* params, bool dots) { 15 uint8_t factor = 5; 16 hsv_t hsv = rgb_matrix_config.hsv; 17 rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv); 18 if (dots) { 19 rgb_matrix_set_color_all(0, 0, 0); 20 } 21 int32_t num = (g_rgb_timer & (0b11111 << factor)) >> factor; 22 23 if (num == 17 || num == 18 || num == 19 || 24 num == 20 || num == 21) { 25 if (dots == true) { 26 for (int i = 0; i < 28; i++) { 27 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 28 } 29 } 30 return; 31 } else if (num == 0 || num == 1 || num == 2) { 32 return; 33 } else if (num >= 22) { 34 eeconfig_read_rgb_matrix(&rgb_matrix_config); 35 rgb_matrix_mode_noeeprom(rgb_matrix_config.mode); 36 return; 37 } 38 39 int32_t num2 = (27/2) + num - 2; 40 int32_t num1 = 27 - num2; 41 #ifdef CONSOLE_ENABLE 42 uprintf("num: %u\n", num); 43 uprintf("num1: %u\n", num1); 44 uprintf("num2: %u\n", num2); 45 #endif 46 rgb_matrix_set_color(num1, rgb.r, rgb.g, rgb.b); 47 rgb_matrix_set_color(num2, rgb.r, rgb.g, rgb.b); 48 } 49 50 static bool startup_animation_dots(effect_params_t* params) { 51 startup_animation_setleds(params, true); 52 return false; 53 } 54 static bool startup_animation_solid(effect_params_t* params) { 55 startup_animation_setleds(params, false); 56 return false; 57 } 58 59 #endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS