aboutsummaryrefslogtreecommitdiff
path: root/users/spidey3/layer_rgb.c
diff options
context:
space:
mode:
authorspidey3 <josh@windowoffire.com>2020-03-23 00:11:41 -0400
committerGitHub <noreply@github.com>2020-03-22 21:11:41 -0700
commit7e0dc5376f2d57a1b24831c4e25699a2cf2326af (patch)
tree141dd6fdbd2c9fac18b6d10c823187bd2a04b497 /users/spidey3/layer_rgb.c
parent6d1af6384227c941d817fee6f7e49537fc78cf2d (diff)
downloadqmk_firmware-7e0dc5376f2d57a1b24831c4e25699a2cf2326af.tar.gz
qmk_firmware-7e0dc5376f2d57a1b24831c4e25699a2cf2326af.zip
[Keymap] Add spidey3 keymap for 75_ansi, and a spidey3 userspace (#8470)
* First cut at Josh Diamond's KBD75 customizations. Includes: * My unique keymap with ChromeOS specific keys * Use RGB underglow to indicate Caps Lock * Some unicode bindings * Some changes to make debugging easier * Updated spidey3 to be applicable to all 75_ansi boards * Sadly, ChromeOS doesn't pay attention to most consumer codes * Add mac layer; fix flakeyness in CAPS_LOCK underglow. * Make layers.json match the keymap (to the extent possible) * Major cleanup; fix broken debug persistence * Cleanup some whitespace issues * Fix incorrect log message. * Rework layer indication to user RGBLIGHT_LAYERS * Update layouts/community/75_ansi/spidey3/keymap.c Co-Authored-By: Drashna Jaelre <drashna@live.com> * Rename users/spidey3/rgblight.c to layer_rgb.c per suggestion * Refactor to use set_single_persistant_default_layer(). * Use dprint/f to make logging more elegant. * Update users/spidey3/config.h Co-Authored-By: Drashna Jaelre <drashna@live.com> * Update users/spidey3/config.h Co-Authored-By: Drashna Jaelre <drashna@live.com> * Update layouts/community/75_ansi/spidey3/rules.mk Co-Authored-By: Ryan <fauxpark@gmail.com> * Update users/spidey3/spidey3.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update users/spidey3/layer_rgb.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update users/spidey3/init.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Changes from code review Co-authored-by: Joshua Diamond <jdiamond@Deep-Thought.local> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'users/spidey3/layer_rgb.c')
-rw-r--r--users/spidey3/layer_rgb.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/users/spidey3/layer_rgb.c b/users/spidey3/layer_rgb.c
new file mode 100644
index 000000000..d80eb20a3
--- /dev/null
+++ b/users/spidey3/layer_rgb.c
@@ -0,0 +1,81 @@
1#include QMK_KEYBOARD_H
2
3#include "spidey3.h"
4#include "velocikey.h"
5
6uint32_t rgb_mode;
7uint16_t rgb_hue;
8uint8_t rgb_sat;
9uint8_t rgb_val;
10bool rgb_saved = 0;
11
12void spidey_swirl(void) {
13 dprint("SPIDEY3: Setting Spidey Swirl!\n");
14 rgblight_enable();
15 rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL);
16 rgblight_sethsv(213, 255, 128);
17#ifdef VELOCIKEY_ENABLE
18 if (!velocikey_enabled())
19 velocikey_toggle();
20#endif
21}
22
23void eeconfig_init_user_rgb(void)
24{
25 spidey_swirl();
26}
27
28const rgblight_segment_t PROGMEM _capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS( {0, 2, HSV_AZURE}, {14, 2, HSV_AZURE} );
29const rgblight_segment_t PROGMEM _layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS( {7, 1, HSV_PURPLE} );
30const rgblight_segment_t PROGMEM _layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS( {9, 2, HSV_GREEN} );
31
32// Now define the array of layers. Later layers take precedence
33const rgblight_segment_t* const PROGMEM _rgb_layers[] = RGBLIGHT_LAYERS_LIST( _capslock_layer, _layer1_layer, _layer2_layer );
34const uint8_t PROGMEM _n_rgb_layers = sizeof(_rgb_layers) / sizeof(_rgb_layers[0]) - 1;
35
36void do_rgb_layers(layer_state_t state, uint8_t start, uint8_t end) {
37 dprint("SPIDEY3: do_rgb_layers()\n");
38 for (uint8_t i=start; i<end; i++) {
39 bool is_on = layer_state_cmp(state, i);
40 dprintf(" layer[%d]=%u\n", i, is_on);
41 rgblight_set_layer_state(i, is_on);
42 }
43}
44
45void keyboard_post_init_user_rgb(void) {
46 do_rgb_layers(default_layer_state, 1u, RGB_LAYER_BASE_REGULAR);
47 do_rgb_layers(layer_state, RGB_LAYER_BASE_REGULAR, _n_rgb_layers);
48 // Enable the LED layers
49 rgblight_layers = _rgb_layers;
50}
51
52layer_state_t default_layer_state_set_user_rgb(layer_state_t state) {
53 dprint("SPIDEY3: default_layer_state_set_user_rgb()\n");
54 do_rgb_layers(state, 1u, RGB_LAYER_BASE_REGULAR);
55 return state;
56}
57
58layer_state_t layer_state_set_user_rgb(layer_state_t state) {
59 dprint("SPIDEY3: layer_state_set_user_rgb()\n");
60 do_rgb_layers(state, RGB_LAYER_BASE_REGULAR, _n_rgb_layers);
61 return state;
62}
63
64bool led_update_user_rgb(led_t led_state) {
65 dprintf("SPIDEY3: caps_lock=%u\n", led_state.caps_lock);
66 rgblight_set_layer_state(0, led_state.caps_lock);
67 return true;
68}
69
70bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
71
72 switch (keycode) {
73 case SPI_GLO:
74 if (record->event.pressed) {
75 spidey_swirl();
76 }
77 break;
78 }
79
80 return true;
81}