From 724aa3a4b256ccb058e4ef86c882167635d6815d Mon Sep 17 00:00:00 2001 From: HorrorTroll Date: Fri, 30 Dec 2022 08:04:01 +0700 Subject: Refactor entire Handwired K552 keyboard (#18066) --- .../keymaps/default/led/cool_diagonal.c | 2 +- .../keymaps/default/led/custom_gradient.c | 2 +- .../handwired_k552/keymaps/default/led/diagonal.c | 22 ------------------ .../default/led/flower_blooming/flower_blooming.c | 27 ++++++++++++++++++++++ .../default/led/flower_blooming/flower_blooming.h | 20 ++++++++++++++++ .../handwired_k552/keymaps/default/led/kitt.c | 2 +- .../keymaps/default/led/random_breath_rainbow.c | 2 +- 7 files changed, 51 insertions(+), 26 deletions(-) delete mode 100644 keyboards/horrortroll/handwired_k552/keymaps/default/led/diagonal.c create mode 100644 keyboards/horrortroll/handwired_k552/keymaps/default/led/flower_blooming/flower_blooming.c create mode 100644 keyboards/horrortroll/handwired_k552/keymaps/default/led/flower_blooming/flower_blooming.h (limited to 'keyboards/horrortroll/handwired_k552/keymaps/default/led') diff --git a/keyboards/horrortroll/handwired_k552/keymaps/default/led/cool_diagonal.c b/keyboards/horrortroll/handwired_k552/keymaps/default/led/cool_diagonal.c index 2c518a5431..a5bf960d45 100644 --- a/keyboards/horrortroll/handwired_k552/keymaps/default/led/cool_diagonal.c +++ b/keyboards/horrortroll/handwired_k552/keymaps/default/led/cool_diagonal.c @@ -1,4 +1,4 @@ -/* Copyright 2021 HorrorTroll +/* Copyright 2022 HorrorTroll * * 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 diff --git a/keyboards/horrortroll/handwired_k552/keymaps/default/led/custom_gradient.c b/keyboards/horrortroll/handwired_k552/keymaps/default/led/custom_gradient.c index 0d7acd7e8b..af6173d250 100644 --- a/keyboards/horrortroll/handwired_k552/keymaps/default/led/custom_gradient.c +++ b/keyboards/horrortroll/handwired_k552/keymaps/default/led/custom_gradient.c @@ -1,4 +1,4 @@ -/* Copyright 2021 HorrorTroll +/* Copyright 2022 HorrorTroll * * 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 diff --git a/keyboards/horrortroll/handwired_k552/keymaps/default/led/diagonal.c b/keyboards/horrortroll/handwired_k552/keymaps/default/led/diagonal.c deleted file mode 100644 index 19e3791bd6..0000000000 --- a/keyboards/horrortroll/handwired_k552/keymaps/default/led/diagonal.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2021 HorrorTroll - * - * 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 . - */ - -static HSV DIAGONAL_math(HSV hsv, uint8_t i, uint8_t time) { - hsv.h = g_led_config.point[i].x - g_led_config.point[i].y - time; - return hsv; -} - -bool DIAGONAL(effect_params_t* params) { return effect_runner_i(params, &DIAGONAL_math); } diff --git a/keyboards/horrortroll/handwired_k552/keymaps/default/led/flower_blooming/flower_blooming.c b/keyboards/horrortroll/handwired_k552/keymaps/default/led/flower_blooming/flower_blooming.c new file mode 100644 index 0000000000..add83149cc --- /dev/null +++ b/keyboards/horrortroll/handwired_k552/keymaps/default/led/flower_blooming/flower_blooming.c @@ -0,0 +1,27 @@ +/* Copyright 2022 HorrorTroll + * + * 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 . + */ + +#include "led/flower_blooming/flower_blooming.h" + +static HSV FLOWER_BLOOMING_math(HSV hsv, uint8_t i, uint8_t time) { + if (g_led_config.point[i].y > k_rgb_matrix_center.y) + hsv.h = g_led_config.point[i].x * 3 - g_led_config.point[i].y * 3 + time; + else + hsv.h = g_led_config.point[i].x * 3 - g_led_config.point[i].y * 3 - time; + return hsv; +} + +bool FLOWER_BLOOMING(effect_params_t* params) { return effect_runner_bloom(params, &FLOWER_BLOOMING_math); } diff --git a/keyboards/horrortroll/handwired_k552/keymaps/default/led/flower_blooming/flower_blooming.h b/keyboards/horrortroll/handwired_k552/keymaps/default/led/flower_blooming/flower_blooming.h new file mode 100644 index 0000000000..941dab975a --- /dev/null +++ b/keyboards/horrortroll/handwired_k552/keymaps/default/led/flower_blooming/flower_blooming.h @@ -0,0 +1,20 @@ +#pragma once + +typedef HSV (*flower_blooming_f)(HSV hsv, uint8_t i, uint8_t time); + +bool effect_runner_bloom(effect_params_t* params, flower_blooming_f effect_func) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); + + uint8_t time = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed / 10, 1)); + for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); + if (g_led_config.point[i].y > k_rgb_matrix_center.y) { + RGB bgr = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time)); + rgb_matrix_set_color(i, bgr.b, bgr.g, bgr.r); + } else { + RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time)); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + } + return rgb_matrix_check_finished_leds(led_max); +} diff --git a/keyboards/horrortroll/handwired_k552/keymaps/default/led/kitt.c b/keyboards/horrortroll/handwired_k552/keymaps/default/led/kitt.c index 823eb5839b..dadbe48223 100644 --- a/keyboards/horrortroll/handwired_k552/keymaps/default/led/kitt.c +++ b/keyboards/horrortroll/handwired_k552/keymaps/default/led/kitt.c @@ -1,4 +1,4 @@ -/* Copyright 2021 HorrorTroll +/* Copyright 2022 HorrorTroll * * 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 diff --git a/keyboards/horrortroll/handwired_k552/keymaps/default/led/random_breath_rainbow.c b/keyboards/horrortroll/handwired_k552/keymaps/default/led/random_breath_rainbow.c index 29c447c61a..ba1ca55faf 100644 --- a/keyboards/horrortroll/handwired_k552/keymaps/default/led/random_breath_rainbow.c +++ b/keyboards/horrortroll/handwired_k552/keymaps/default/led/random_breath_rainbow.c @@ -1,4 +1,4 @@ -/* Copyright 2021 HorrorTroll +/* Copyright 2022 HorrorTroll * * 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 -- cgit v1.2.3