aboutsummaryrefslogtreecommitdiff
path: root/users/drashna/rgb/rgb_matrix_stuff.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/drashna/rgb/rgb_matrix_stuff.c')
-rw-r--r--users/drashna/rgb/rgb_matrix_stuff.c94
1 files changed, 63 insertions, 31 deletions
diff --git a/users/drashna/rgb/rgb_matrix_stuff.c b/users/drashna/rgb/rgb_matrix_stuff.c
index 97811092c..e6d631466 100644
--- a/users/drashna/rgb/rgb_matrix_stuff.c
+++ b/users/drashna/rgb/rgb_matrix_stuff.c
@@ -1,18 +1,5 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> 1// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * 2// SPDX-License-Identifier: GPL-2.0-or-later
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 3
17#include "drashna.h" 4#include "drashna.h"
18#include "rgb_matrix.h" 5#include "rgb_matrix.h"
@@ -29,27 +16,27 @@ void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode
29 16
30 switch (mode) { 17 switch (mode) {
31 case 1: // breathing 18 case 1: // breathing
32 { 19 {
33 uint16_t time = scale16by8(g_rgb_timer, speed / 8); 20 uint16_t time = scale16by8(g_rgb_timer, speed / 8);
34 hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); 21 hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
35 RGB rgb = hsv_to_rgb(hsv); 22 RGB rgb = hsv_to_rgb(hsv);
36 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { 23 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
37 if (HAS_FLAGS(g_led_config.flags[i], led_type)) { 24 if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
38 RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b); 25 RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b);
39 }
40 } 26 }
41 break;
42 } 27 }
28 break;
29 }
43 default: // Solid Color 30 default: // Solid Color
44 { 31 {
45 RGB rgb = hsv_to_rgb(hsv); 32 RGB rgb = hsv_to_rgb(hsv);
46 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { 33 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
47 if (HAS_FLAGS(g_led_config.flags[i], led_type)) { 34 if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
48 RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b); 35 RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b);
49 }
50 } 36 }
51 break;
52 } 37 }
38 break;
39 }
53 } 40 }
54} 41}
55 42
@@ -95,3 +82,48 @@ bool process_record_user_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
95 } 82 }
96 return true; 83 return true;
97} 84}
85
86__attribute__((weak)) bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) { return true; }
87void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
88 if (!rgb_matrix_indicators_advanced_keymap(led_min, led_max)) { return; }
89
90#if defined(RGBLIGHT_ENABLE)
91 if (!userspace_config.rgb_layer_change)
92#else
93 if (userspace_config.rgb_layer_change)
94#endif
95 {
96 switch (get_highest_layer(layer_state | default_layer_state)) {
97 case _DEFAULT_LAYER_1:
98 rgb_matrix_layer_helper(DEFAULT_LAYER_1_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
99 break;
100 case _DEFAULT_LAYER_2:
101 rgb_matrix_layer_helper(DEFAULT_LAYER_2_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
102 break;
103 case _DEFAULT_LAYER_3:
104 rgb_matrix_layer_helper(DEFAULT_LAYER_3_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
105 break;
106 case _DEFAULT_LAYER_4:
107 rgb_matrix_layer_helper(DEFAULT_LAYER_4_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
108 break;
109 case _GAMEPAD:
110 rgb_matrix_layer_helper(HSV_ORANGE, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
111 break;
112 case _DIABLO:
113 rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed * 8, LED_FLAG_MODIFIER, led_min, led_max);
114 break;
115 case _RAISE:
116 rgb_matrix_layer_helper(HSV_YELLOW, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
117 break;
118 case _LOWER:
119 rgb_matrix_layer_helper(HSV_GREEN, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
120 break;
121 case _ADJUST:
122 rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
123 break;
124 }
125 }
126}
127
128__attribute__((weak)) bool rgb_matrix_indicators_keymap(void) { return true; }
129void rgb_matrix_indicators_user(void) { rgb_matrix_indicators_keymap(); }