aboutsummaryrefslogtreecommitdiff
path: root/users/drashna/rgb_matrix_stuff.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2020-03-31 16:26:43 -0700
committerGitHub <noreply@github.com>2020-03-31 16:26:43 -0700
commitc67e30459390982f4f1b47f46c62322f1fe9ba87 (patch)
treed3504649cb692e58823bc7589d1a032256d9b0c1 /users/drashna/rgb_matrix_stuff.c
parent8c80475fcc568e04f637ae973086b65a31b5254d (diff)
downloadqmk_firmware-c67e30459390982f4f1b47f46c62322f1fe9ba87.tar.gz
qmk_firmware-c67e30459390982f4f1b47f46c62322f1fe9ba87.zip
[Keymap] Drashna's Cleanup and RGB Divide (#8506)
* Enable External EEPROM on Planck Rev6 * Update KC_MAKE macro to use qmk cli util * Disable additional gradients for rgb matrix * Update analog code for newer methods * Update ergodox layout * Disable Grave Escape * Cleanup OLED code a bit * Remove old unicode code * Seperate RGB Matrix code from RGB Light code in userspace * Massive overhaul an generalization of personal OLED code Now lets hope I NEVER get a keyboard using a 128x32 in a normal orientation. * Super tiny cleanup * Enable Diablo layer on kyria * clang format pass * Additional OLED cleanup
Diffstat (limited to 'users/drashna/rgb_matrix_stuff.c')
-rw-r--r--users/drashna/rgb_matrix_stuff.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/users/drashna/rgb_matrix_stuff.c b/users/drashna/rgb_matrix_stuff.c
new file mode 100644
index 000000000..0914aab14
--- /dev/null
+++ b/users/drashna/rgb_matrix_stuff.c
@@ -0,0 +1,86 @@
1#include "drashna.h"
2
3#include "lib/lib8tion/lib8tion.h"
4extern led_config_t g_led_config;
5
6static uint32_t hypno_timer;
7#if defined(SPLIT_KEYBOARD) || defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_crkbd)
8# define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN_DUAL
9#else
10# define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN
11#endif
12
13void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type) {
14 HSV hsv = {hue, sat, val};
15 if (hsv.v > rgb_matrix_config.hsv.v) {
16 hsv.v = rgb_matrix_config.hsv.v;
17 }
18
19 switch (mode) {
20 case 1: // breathing
21 {
22 uint16_t time = scale16by8(g_rgb_counters.tick, speed / 8);
23 hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
24 RGB rgb = hsv_to_rgb(hsv);
25 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
26 if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
27 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
28 }
29 }
30 break;
31 }
32 default: // Solid Color
33 {
34 RGB rgb = hsv_to_rgb(hsv);
35 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
36 if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
37 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
38 }
39 }
40 break;
41 }
42 }
43}
44
45__attribute__((weak)) void rgb_matrix_indicator_keymap(void) {}
46
47void matrix_scan_rgb_matrix(void) {
48#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
49 if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_TYPING_HEATMAP && timer_elapsed32(hypno_timer) > 15000) {
50 rgb_matrix_mode_noeeprom(RGB_MATRIX_REST_MODE);
51 }
52#endif
53 rgb_matrix_indicator_keymap();
54}
55
56void keyboard_post_init_rgb_matrix(void) {
57#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
58 if (userspace_config.rgb_matrix_idle_anim) {
59 rgb_matrix_mode_noeeprom(RGB_MATRIX_REST_MODE);
60 }
61#endif
62}
63
64bool process_record_user_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
65#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
66 hypno_timer = timer_read32();
67 if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_REST_MODE) {
68 rgb_matrix_mode_noeeprom(RGB_MATRIX_TYPING_HEATMAP);
69 }
70#endif
71 switch (keycode) {
72 case RGB_IDL: // This allows me to use underglow as layer indication, or as normal
73#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
74 if (record->event.pressed) {
75 userspace_config.rgb_matrix_idle_anim ^= 1;
76 dprintf("RGB Matrix Idle Animation [EEPROM]: %u\n", userspace_config.rgb_matrix_idle_anim);
77 eeconfig_update_user(userspace_config.raw);
78 if (userspace_config.rgb_matrix_idle_anim) {
79 rgb_matrix_mode_noeeprom(RGB_MATRIX_TYPING_HEATMAP);
80 }
81 }
82#endif
83 break;
84 }
85 return true;
86}