summaryrefslogtreecommitdiff
path: root/keyboards/horrortroll/handwired_k552/keymaps/via/led
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/horrortroll/handwired_k552/keymaps/via/led')
-rw-r--r--keyboards/horrortroll/handwired_k552/keymaps/via/led/cool_diagonal.c22
-rw-r--r--keyboards/horrortroll/handwired_k552/keymaps/via/led/custom_gradient.c74
-rw-r--r--keyboards/horrortroll/handwired_k552/keymaps/via/led/diagonal.c22
-rw-r--r--keyboards/horrortroll/handwired_k552/keymaps/via/led/kitt.c68
-rw-r--r--keyboards/horrortroll/handwired_k552/keymaps/via/led/random_breath_rainbow.c55
5 files changed, 241 insertions, 0 deletions
diff --git a/keyboards/horrortroll/handwired_k552/keymaps/via/led/cool_diagonal.c b/keyboards/horrortroll/handwired_k552/keymaps/via/led/cool_diagonal.c
new file mode 100644
index 0000000000..2c518a5431
--- /dev/null
+++ b/keyboards/horrortroll/handwired_k552/keymaps/via/led/cool_diagonal.c
@@ -0,0 +1,22 @@
+/* Copyright 2021 HorrorTroll <https://github.com/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 <http://www.gnu.org/licenses/>.
+ */
+
+static HSV COOL_DIAGONAL_math(HSV hsv, uint8_t i, uint8_t time) {
+ hsv.h = (g_led_config.point[i].x / 4) - g_led_config.point[i].y - time;
+ return hsv;
+}
+
+bool COOL_DIAGONAL(effect_params_t* params) { return effect_runner_i(params, &COOL_DIAGONAL_math); } \ No newline at end of file
diff --git a/keyboards/horrortroll/handwired_k552/keymaps/via/led/custom_gradient.c b/keyboards/horrortroll/handwired_k552/keymaps/via/led/custom_gradient.c
new file mode 100644
index 0000000000..49e4a242fb
--- /dev/null
+++ b/keyboards/horrortroll/handwired_k552/keymaps/via/led/custom_gradient.c
@@ -0,0 +1,74 @@
+/* Copyright 2021 HorrorTroll <https://github.com/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 <http://www.gnu.org/licenses/>.
+ */
+
+extern HSV gradient_0;
+extern HSV gradient_100;
+extern bool reflected_gradient;
+
+static HSV INTERPOLATE_HSV(float step, HSV gradient_0, HSV gradient_100) {
+ uint8_t cw, ccw;
+ HSV color;
+
+ cw = (gradient_0.h >= gradient_100.h) ? 255 + gradient_100.h - gradient_0.h : gradient_100.h - gradient_0.h; // Hue range is 0 to 255.
+ ccw = (gradient_0.h >= gradient_100.h) ? gradient_0.h - gradient_100.h : 255 + gradient_0.h - gradient_100.h;
+
+ if( cw < ccw ) { // going clockwise
+ color.h = gradient_0.h + (uint8_t)(step * cw);
+ } else { // Going counter clockwise
+ color.h = gradient_0.h - (uint8_t)(step * ccw);
+ }
+
+ color.s = gradient_0.s + step * (gradient_100.s - gradient_0.s);
+
+ // Scale V with global RGB Matrix's V, so users can still control overall brightness with RGB_VAI & RGB_VAD0
+ color.v = round((gradient_0.v + step * (gradient_100.v - gradient_0.v)) * ((float)rgb_matrix_config.hsv.v / 255));
+
+ return color;
+}
+
+static HSV CUSTOM_GRADIENT_math(uint8_t led_x, uint8_t min_x, uint8_t max_x) {
+ float step = (float)led_x / (max_x - min_x);
+ float mid_gradient_pos = 0.5;
+
+ if( reflected_gradient ) {
+ if( step <= mid_gradient_pos ) {
+ return INTERPOLATE_HSV(step * (1/mid_gradient_pos), gradient_0, gradient_100);
+ } else {
+ return INTERPOLATE_HSV((step - mid_gradient_pos) * (1/(1-mid_gradient_pos)), gradient_100, gradient_0);
+ }
+
+ } else {
+ return INTERPOLATE_HSV(step, gradient_0, gradient_100);
+ }
+}
+
+static bool CUSTOM_GRADIENT(effect_params_t* params) {
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t min_x = 0; // X coordinate of the left-most LED
+ uint8_t max_x = 224; // X coordinate of the right-most LED
+
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+
+ HSV hsv_orig = CUSTOM_GRADIENT_math(g_led_config.point[i].x, min_x, max_x);
+ RGB rgb = hsv_to_rgb(hsv_orig);
+
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ }
+
+ return led_max < DRIVER_LED_TOTAL;
+}
diff --git a/keyboards/horrortroll/handwired_k552/keymaps/via/led/diagonal.c b/keyboards/horrortroll/handwired_k552/keymaps/via/led/diagonal.c
new file mode 100644
index 0000000000..19e3791bd6
--- /dev/null
+++ b/keyboards/horrortroll/handwired_k552/keymaps/via/led/diagonal.c
@@ -0,0 +1,22 @@
+/* Copyright 2021 HorrorTroll <https://github.com/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 <http://www.gnu.org/licenses/>.
+ */
+
+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/via/led/kitt.c b/keyboards/horrortroll/handwired_k552/keymaps/via/led/kitt.c
new file mode 100644
index 0000000000..823eb5839b
--- /dev/null
+++ b/keyboards/horrortroll/handwired_k552/keymaps/via/led/kitt.c
@@ -0,0 +1,68 @@
+/* Copyright 2021 HorrorTroll <https://github.com/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 <http://www.gnu.org/licenses/>.
+ */
+
+// variable for startup animation
+bool BASE_EFFECT_NOT_STARTED_YET = true;
+uint8_t base_effect_startup_counter = 255;
+
+uint8_t led_count = 10;
+uint8_t led_first = 7;
+
+static uint8_t time_to_led(uint8_t time, uint8_t led_behind) {
+ uint16_t led_time = led_count * time;
+ uint16_t step = ((2 * led_count + (led_time / 128)) - led_behind) % (2 * led_count);
+ uint8_t led;
+
+ if (step < led_count) {
+ led = step;
+ } else {
+ led = led_count - 1 - (step - led_count);
+ }
+
+ return led;
+}
+
+static HSV KITT_math(HSV hsv, uint8_t i, uint8_t time) {
+
+ // reset base effect startup
+ if (i == 0) {
+ BASE_EFFECT_NOT_STARTED_YET = true;
+ }
+
+ hsv.h = 0;
+ hsv.s = 255;
+
+ if (i >= led_first && i < led_first + led_count) {
+ uint8_t j = i - led_first;
+ if (j == time_to_led(time, 0)) {
+ hsv.v = hsv.v;
+ } else if (j == time_to_led(time, 1)) {
+ hsv.v = hsv.v/2;
+ } else if (j == time_to_led(time, 2)) {
+ hsv.v = hsv.v/4;
+ } else if (j == time_to_led(time, 3)) {
+ hsv.v = hsv.v/8;
+ } else {
+ hsv.v = 0;
+ }
+ } else {
+ hsv.v = 0;
+ }
+
+ return hsv;
+}
+
+bool KITT(effect_params_t* params) { return effect_runner_i(params, &KITT_math); }
diff --git a/keyboards/horrortroll/handwired_k552/keymaps/via/led/random_breath_rainbow.c b/keyboards/horrortroll/handwired_k552/keymaps/via/led/random_breath_rainbow.c
new file mode 100644
index 0000000000..041417477b
--- /dev/null
+++ b/keyboards/horrortroll/handwired_k552/keymaps/via/led/random_breath_rainbow.c
@@ -0,0 +1,55 @@
+/* Copyright 2021 HorrorTroll <https://github.com/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 <http://www.gnu.org/licenses/>.
+ */
+
+static uint8_t offset[DRIVER_LED_TOTAL];
+
+static void doRandom_breath_rainbow(int i, effect_params_t* params) {
+ if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
+ uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 6);
+
+ if (rand() * 50 == 1) {
+ if (rand() * 2 == 1) {
+ offset[i]++;
+ }
+ else {
+ offset[i]--;
+ }
+ }
+
+ //float val = (((float)sin8(time + offset[i]) / 256)/2.1) + .05;
+ HSV hsv = {0, 255, 255};
+ hsv.h = scale16by8(g_rgb_timer + offset[i], rgb_matrix_config.speed / 4) + (offset[i]*2);
+ hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
+ RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+}
+
+bool RANDOM_BREATH_RAINBOW(effect_params_t* params) {
+
+ if (!params->init) {
+ // Change one LED every tick, make sure speed is not 0
+ doRandom_breath_rainbow(rand() % DRIVER_LED_TOTAL, params);
+ return false;
+ }
+
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+
+ for (uint8_t i = led_min; i < led_max; i++) {
+ doRandom_breath_rainbow(i, params);
+ }
+
+ return led_max < DRIVER_LED_TOTAL;
+}