]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/ergodox/keymaps/narze/visualizer.c
Add narze keymaps for Ergodox & Planck with SuperDuper mode implementation (#1883)
[qmk_firmware.git] / keyboards / ergodox / keymaps / narze / visualizer.c
1 /*
2 Copyright 2017 Fred Sundvik
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "simple_visualizer.h"
19 #include "util.h"
20
21 // Copied from keymap.c
22 enum ergodox_layers {
23   _QWERTY,
24   _COLEMAK,
25   _QWOC,
26   _LOWER,
27   _RAISE,
28   _PLOVER,
29 // Intermediate layers for SuperDuper (Combo keys does not work on Infinity yet)
30   _SUPER,
31   _DUPER,
32   _SUPERDUPER,
33   _MOUSE,
34   _ADJUST,
35   _MDIA,
36   _SYMB,
37 };
38
39 // This function should be implemented by the keymap visualizer
40 // Don't change anything else than state->target_lcd_color and state->layer_text as that's the only thing
41 // that the simple_visualizer assumes that you are updating
42 // Also make sure that the buffer passed to state->layer_text remains valid until the previous animation is
43 // stopped. This can be done by either double buffering it or by using constant strings
44 static void get_visualizer_layer_and_color(visualizer_state_t* state) {
45     uint8_t saturation = 255;
46
47     uint8_t layer = biton32(state->status.layer);
48     state->target_lcd_color = LCD_COLOR(layer << 2, saturation, 0xFF);
49
50     switch(layer) {
51         case _QWERTY:
52             state->layer_text = "QWERTY";
53             break;
54         case _COLEMAK:
55             state->layer_text = "COLEMAK";
56             break;
57         case _QWOC:
58             state->layer_text = "QWERTY on COLEMAK";
59             break;
60         case _LOWER:
61             state->layer_text = "LOWER";
62             break;
63         case _RAISE:
64             state->layer_text = "RAISE";
65             break;
66         case _PLOVER:
67             state->layer_text = "PLOVER";
68             break;
69         case _SUPERDUPER:
70             state->layer_text = "SUPERDUPER";
71             break;
72         case _SUPER:
73             state->layer_text = "SUPER";
74             break;
75         case _DUPER:
76             state->layer_text = "DUPER";
77             break;
78         case _MOUSE:
79             state->layer_text = "MOUSE";
80             break;
81         case _ADJUST:
82             state->layer_text = "ADJUST";
83             break;
84         case _MDIA:
85             state->layer_text = "MDIA";
86             break;
87         case _SYMB:
88             state->layer_text = "SYMB";
89             break;
90         default:
91             state->layer_text = "NONE";
92             break;
93     }
94 }