summaryrefslogtreecommitdiff
path: root/keyboards/gopolar/gg86/keymaps/horrortroll/led
diff options
context:
space:
mode:
authorHorrorTroll <sonicvipduc@gmail.com>2022-07-17 02:38:22 +0700
committerGitHub <noreply@github.com>2022-07-16 12:38:22 -0700
commit92c3e6305bfd0870279048356c51e768e2c392a9 (patch)
tree3e9612cbe8619093c265fdb7768dc5ecaaff9689 /keyboards/gopolar/gg86/keymaps/horrortroll/led
parent4d443d921bea20758328668ae821ae5396a6c6e1 (diff)
[Keyboard] Gopolar GG86 (#15425)
* Added keyboard GG86 * Rebased, resolved issue and updated code * Delete 1000Hz on config * Resolved fix * Another resolved fix * Last resolved fix * Fixed LED position
Diffstat (limited to 'keyboards/gopolar/gg86/keymaps/horrortroll/led')
-rw-r--r--keyboards/gopolar/gg86/keymaps/horrortroll/led/cool_diagonal.c22
-rw-r--r--keyboards/gopolar/gg86/keymaps/horrortroll/led/custom_gradient.c74
-rw-r--r--keyboards/gopolar/gg86/keymaps/horrortroll/led/flower_blooming/flower_blooming.c27
-rw-r--r--keyboards/gopolar/gg86/keymaps/horrortroll/led/flower_blooming/flower_blooming.h20
-rw-r--r--keyboards/gopolar/gg86/keymaps/horrortroll/led/kitt.c68
-rw-r--r--keyboards/gopolar/gg86/keymaps/horrortroll/led/rainbow_reactive_simple/rainbow_reactive_simple.c25
-rw-r--r--keyboards/gopolar/gg86/keymaps/horrortroll/led/rainbow_reactive_simple/rainbow_reactive_simple.h45
-rw-r--r--keyboards/gopolar/gg86/keymaps/horrortroll/led/random_breath_rainbow.c55
8 files changed, 336 insertions, 0 deletions
diff --git a/keyboards/gopolar/gg86/keymaps/horrortroll/led/cool_diagonal.c b/keyboards/gopolar/gg86/keymaps/horrortroll/led/cool_diagonal.c
new file mode 100644
index 0000000000..2c518a5431
--- /dev/null
+++ b/keyboards/gopolar/gg86/keymaps/horrortroll/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/gopolar/gg86/keymaps/horrortroll/led/custom_gradient.c b/keyboards/gopolar/gg86/keymaps/horrortroll/led/custom_gradient.c
new file mode 100644
index 0000000000..fcedf777eb
--- /dev/null
+++ b/keyboards/gopolar/gg86/keymaps/horrortroll/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;
+} \ No newline at end of file
diff --git a/keyboards/gopolar/gg86/keymaps/horrortroll/led/flower_blooming/flower_blooming.c b/keyboards/gopolar/gg86/keymaps/horrortroll/led/flower_blooming/flower_blooming.c
new file mode 100644
index 0000000000..add83149cc
--- /dev/null
+++ b/keyboards/gopolar/gg86/keymaps/horrortroll/led/flower_blooming/flower_blooming.c
@@ -0,0 +1,27 @@
+/* Copyright 2022 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/>.
+ */
+
+#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/gopolar/gg86/keymaps/horrortroll/led/flower_blooming/flower_blooming.h b/keyboards/gopolar/gg86/keymaps/horrortroll/led/flower_blooming/flower_blooming.h
new file mode 100644
index 0000000000..941dab975a
--- /dev/null
+++ b/keyboards/gopolar/gg86/keymaps/horrortroll/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/gopolar/gg86/keymaps/horrortroll/led/kitt.c b/keyboards/gopolar/gg86/keymaps/horrortroll/led/kitt.c
new file mode 100644
index 0000000000..bfc32ce040
--- /dev/null
+++ b/keyboards/gopolar/gg86/keymaps/horrortroll/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 = 11;
+uint8_t led_first = 41;
+
+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); } \ No newline at end of file
diff --git a/keyboards/gopolar/gg86/keymaps/horrortroll/led/rainbow_reactive_simple/rainbow_reactive_simple.c b/keyboards/gopolar/gg86/keymaps/horrortroll/led/rainbow_reactive_simple/rainbow_reactive_simple.c
new file mode 100644
index 0000000000..ce3fff8ec5
--- /dev/null
+++ b/keyboards/gopolar/gg86/keymaps/horrortroll/led/rainbow_reactive_simple/rainbow_reactive_simple.c
@@ -0,0 +1,25 @@
+/* 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/>.
+ */
+
+#include "led/rainbow_reactive_simple/rainbow_reactive_simple.h"
+
+static HSV RAINBOW_REACTIVE_SIMPLE_math(HSV hsv, uint8_t i, uint8_t time, uint16_t offset) {
+ hsv.h = g_led_config.point[i].x - time;
+ hsv.v = scale8(255 - offset, hsv.v);
+ return hsv;
+}
+
+bool RAINBOW_REACTIVE_SIMPLE(effect_params_t* params) { return effect_rainbow_reactive(params, &RAINBOW_REACTIVE_SIMPLE_math); } \ No newline at end of file
diff --git a/keyboards/gopolar/gg86/keymaps/horrortroll/led/rainbow_reactive_simple/rainbow_reactive_simple.h b/keyboards/gopolar/gg86/keymaps/horrortroll/led/rainbow_reactive_simple/rainbow_reactive_simple.h
new file mode 100644
index 0000000000..5b610716e0
--- /dev/null
+++ b/keyboards/gopolar/gg86/keymaps/horrortroll/led/rainbow_reactive_simple/rainbow_reactive_simple.h
@@ -0,0 +1,45 @@
+/* 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/>.
+ */
+
+#pragma once
+
+typedef HSV (*rainbow_reactive_f)(HSV hsv, uint8_t i, uint8_t time, uint16_t offset);
+
+bool effect_rainbow_reactive(effect_params_t* params, rainbow_reactive_f effect_func) {
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4);
+ uint16_t max_tick = 65535 / rgb_matrix_config.speed;
+
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ uint16_t tick = max_tick;
+
+ // Reverse search to find most recent key hit
+ for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) {
+ if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
+ tick = g_last_hit_tracker.tick[j];
+ break;
+ }
+ }
+
+ uint16_t offset = scale16by8(tick, rgb_matrix_config.speed);
+ RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time, offset));
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ }
+
+ return led_max < DRIVER_LED_TOTAL;
+} \ No newline at end of file
diff --git a/keyboards/gopolar/gg86/keymaps/horrortroll/led/random_breath_rainbow.c b/keyboards/gopolar/gg86/keymaps/horrortroll/led/random_breath_rainbow.c
new file mode 100644
index 0000000000..e5f399cdd3
--- /dev/null
+++ b/keyboards/gopolar/gg86/keymaps/horrortroll/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;
+} \ No newline at end of file