mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-12-25 10:59:54 +00:00
a29ca1e7f1
* Gets RGB working on a split keyboard with IS31FL3733. Currently needs small tweak to re-enable WS2812 * Added helper function * Trying to integrate the function * Moved functionality into a macro * Swapped conditional for a macro everywhere * Tidying up * More code cleanup * Documentation updates * Fixed formatting via linter * Switching to a function from a macro * Fixed compile error * Fixing WS2812 behavior. UNTESTED. * Updated documentation about the driver addresses. * Fixed code for WS2812 * Trying to add in LED_MATRIX support * Updated effects for LED matrix * Updated third-party effect defines. * Ran format-c on modified files * Apply suggestions from code review Co-authored-by: Ryan <fauxpark@gmail.com> * Move to static inline. Avoids issues with gcc v8+ * Move helper function for LED_matrix to static inline to avoid issues with gcc v8+ Co-authored-by: Vlad Kvitnevskiy <vladkvit@outlook.com> Co-authored-by: Ryan <fauxpark@gmail.com>
68 lines
2.3 KiB
C++
68 lines
2.3 KiB
C++
/*
|
|
Copyright 2020 Evy Dekkers
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
RGB_MATRIX_EFFECT(indicator_gradient)
|
|
RGB_MATRIX_EFFECT(indicator_cycle_all)
|
|
RGB_MATRIX_EFFECT(indicator_static)
|
|
|
|
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
|
|
|
static bool indicator_static(effect_params_t* params) {
|
|
HSV hsv = rgb_matrix_config.hsv;
|
|
RGB rgb = hsv_to_rgb(hsv);
|
|
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
|
for (uint8_t i = led_min; i < 74; i++) {
|
|
rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
|
|
}
|
|
for (uint8_t i = 74; i < led_max; i++) {
|
|
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
|
}
|
|
return rgb_matrix_check_finished_leds(led_max);
|
|
}
|
|
|
|
bool effect_runner_indicator(effect_params_t* params, i_f effect_func) {
|
|
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
|
|
|
uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 16);
|
|
for (uint8_t i = led_min; i < led_max; i++) {
|
|
if (i < 74) {
|
|
rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
|
|
} else {
|
|
RGB_MATRIX_TEST_LED_FLAGS();
|
|
RGB rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, (i - 74), time));
|
|
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
|
}
|
|
}
|
|
return rgb_matrix_check_finished_leds(led_max);
|
|
}
|
|
|
|
static HSV indicator_gradient_math(HSV hsv, uint8_t i, uint8_t time) {
|
|
hsv.h = g_led_config.point[i].x - time;
|
|
return hsv;
|
|
}
|
|
|
|
bool indicator_gradient(effect_params_t* params) { return effect_runner_indicator(params, &indicator_gradient_math); }
|
|
|
|
static HSV indicator_cycle_all_math(HSV hsv, uint8_t i, uint8_t time) {
|
|
hsv.h = time;
|
|
return hsv;
|
|
}
|
|
|
|
bool indicator_cycle_all(effect_params_t* params) { return effect_runner_indicator(params, &indicator_cycle_all_math); }
|
|
|
|
#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|