rgb_matrix_kb.inc (2365B)
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(indicator_gradient) 19 RGB_MATRIX_EFFECT(indicator_cycle_all) 20 RGB_MATRIX_EFFECT(indicator_static) 21 22 #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS 23 24 static bool indicator_static(effect_params_t* params) { 25 hsv_t hsv = rgb_matrix_config.hsv; 26 rgb_t rgb = hsv_to_rgb(hsv); 27 RGB_MATRIX_USE_LIMITS(led_min, led_max); 28 for (uint8_t i = led_min; i < 74; i++) { 29 rgb_matrix_set_color(i, 0x00, 0x00, 0x00); 30 } 31 for (uint8_t i = 74; i < led_max; i++) { 32 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 33 } 34 return rgb_matrix_check_finished_leds(led_max); 35 } 36 37 bool effect_runner_indicator(effect_params_t* params, i_f effect_func) { 38 RGB_MATRIX_USE_LIMITS(led_min, led_max); 39 40 uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 16); 41 for (uint8_t i = led_min; i < led_max; i++) { 42 if (i < 74) { 43 rgb_matrix_set_color(i, 0x00, 0x00, 0x00); 44 } else { 45 RGB_MATRIX_TEST_LED_FLAGS(); 46 rgb_t rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, (i - 74), time)); 47 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 48 } 49 } 50 return rgb_matrix_check_finished_leds(led_max); 51 } 52 53 static hsv_t indicator_gradient_math(hsv_t hsv, uint8_t i, uint8_t time) { 54 hsv.h = g_led_config.point[i].x - time; 55 return hsv; 56 } 57 58 bool indicator_gradient(effect_params_t* params) { return effect_runner_indicator(params, &indicator_gradient_math); } 59 60 static hsv_t indicator_cycle_all_math(hsv_t hsv, uint8_t i, uint8_t time) { 61 hsv.h = time; 62 return hsv; 63 } 64 65 bool indicator_cycle_all(effect_params_t* params) { return effect_runner_indicator(params, &indicator_cycle_all_math); } 66 67 #endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS