]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/hadron/ver2/keymaps/default/keymap.c
Add user-overridable callback for cancelling UCIS input (#5564)
[qmk_firmware.git] / keyboards / hadron / ver2 / keymaps / default / keymap.c
1 #include QMK_KEYBOARD_H
2 #ifdef USE_I2C
3 #include "i2c.h"
4 #endif
5 #ifdef SSD1306OLED
6 #include "ssd1306.h"
7 #endif
8 extern keymap_config_t keymap_config;
9
10 //Following line allows macro to read current RGB settings
11 extern rgblight_config_t rgblight_config;
12
13 // Each layer gets a name for readability, which is then used in the keymap matrix below.
14 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
15 // Layer names don't all need to be of the same length, obviously, and you can also skip them
16 // entirely and just use numbers.
17 #define _QWERTY 0
18 #define _COLEMAK 1
19 #define _DVORAK 2
20 #define _LOWER 3
21 #define _RAISE 4
22 #define _MOUSECURSOR 8
23 #define _ADJUST 16
24
25 enum preonic_keycodes {
26   QWERTY = SAFE_RANGE,
27   COLEMAK,
28   DVORAK,
29   LOWER,
30   RAISE,
31   BACKLIT,
32   RGBLED_TOGGLE,
33   RGBLED_STEP_MODE,
34   RGBLED_INCREASE_HUE,
35   RGBLED_DECREASE_HUE,
36   RGBLED_INCREASE_SAT,
37   RGBLED_DECREASE_SAT,
38   RGBLED_INCREASE_VAL,
39   RGBLED_DECREASE_VAL,
40 };
41
42 enum macro_keycodes {
43   KC_DEMOMACRO,
44 };
45
46 // Custom macros
47 #define CTL_ESC     CTL_T(KC_ESC)               // Tap for Esc, hold for Ctrl
48 #define CTL_TTAB    CTL_T(KC_TAB)               // Tap for Esc, hold for Ctrl
49 #define CTL_ENT     CTL_T(KC_ENT)               // Tap for Enter, hold for Ctrl
50 #define SFT_ENT     SFT_T(KC_ENT)               // Tap for Enter, hold for Shift
51 // Requires KC_TRNS/_______ for the trigger key in the destination layer
52 #define LT_MC(kc)   LT(_MOUSECURSOR, kc)        // L-ayer T-ap M-ouse C-ursor
53 #define LT_RAI(kc)  LT(_RAISE, kc)              // L-ayer T-ap to Raise
54 #define DEMOMACRO   M(KC_DEMOMACRO)            // Sample for macros
55
56
57 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
58
59 /* Qwerty
60  * ,------+------+------+------+------+------------------------------------------------.
61  * | Esc  |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |  F7  |  F8  |  F9  |  F10 |  DEL |
62  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
63  * | Tab  |   Q  |   W  |   E  |   R  |   T  |   7  |   8  |   9  |   Y  |   U  |   I  |   O  |   P  | Bksp |
64  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
65  * | CAPS |   A  |   S  |   D  |   F  |   G  |   4  |   5  |   6  |   H  |   J  |   K  |   L  | ;/Nav|  '   |
66  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
67  * | Shift|   Z  |   X  |   C  |   V  |   B  |   1  |   2  |   3  |   N  |   M  |   ,  |   .  |   /  |Ctl/Et|
68  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
69  * |  `   | Ctrl | Alt  | GUI  |Lower |Space |   0  |   .  |   =  |Space |Raise | Left | Down |  Up  |Right |
70  * `--------------------------------------------------------------------------------------------------------'
71  */
72 [_QWERTY] = LAYOUT(
73   KC_ESC,   KC_F1,    KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,    KC_F9,   KC_F10,  KC_DEL,\
74   KC_TAB,   KC_Q,     KC_W,    KC_E,    KC_R,    KC_T,    KC_P7,   KC_P8,   KC_P9,    KC_Y,    KC_U,    KC_I,   KC_O,    KC_P,     KC_BSPC, \
75   KC_CAPS,  KC_A,     KC_S,    KC_D,    KC_F,    KC_G,    KC_P4,   KC_P5,   KC_P6,    KC_H,    KC_J,    KC_K,   KC_L,LT_MC(KC_SCLN), KC_QUOT, \
76   KC_LSFT,  KC_Z,     KC_X,    KC_C,    KC_V,    KC_B,    KC_P1,   KC_P2,   KC_P3,    KC_N,    KC_M,    KC_COMM,KC_DOT,  KC_SLSH,  CTL_ENT, \
77   KC_GRV,   KC_LCTRL, KC_LGUI, KC_LALT, LOWER,   KC_SPC,  KC_P0,   KC_DOT,  KC_EQL,  KC_SPC,   RAISE,   KC_LEFT,KC_DOWN, KC_UP,    KC_RGHT  \
78 ),
79
80 /* Colemak
81  * ,------+------+------+------+------+------------------------------------------------.
82  * | Esc  |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |  F7  |  F8  |  F9  |   0  |   -  |
83  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
84  * | Tab  |   Q  |   W  |   F  |   P  |   G  |   7  |   8  |   9  |   J  |   L  |   U  |   Y  |   ;  | Bksp |
85  * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
86  * | CAPS |   A  |   R  |   S  |   T  |   D  |   4  |   5  |   6  |   H  |   N  |   E  |   I  |   O  |  '   |
87  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
88  * | Shift|   Z  |   X  |   C  |   V  |   B  |   1  |   2  |   3  |   K  |   M  |   ,  |   .  |   /  |Ctl/Et|
89  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
90  * |   `  | Ctrl | Alt  | GUI  |Lower |Space |   0  |   .  |   =  |Space |Raise | Left | Down |  Up  |Right |
91  * `--------------------------------------------------------------------------------------------------------'
92  */
93 [_COLEMAK] = LAYOUT(
94   KC_ESC,   KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,    KC_F9,   KC_F10, KC_DEL,\
95   KC_TAB,   KC_Q,    KC_W,    KC_F,    KC_P,    KC_G,    KC_P7,   KC_P8,   KC_P9,    KC_J,    KC_L,    KC_U,    KC_Y,    KC_SCLN,  KC_BSPC, \
96   KC_LCTRL, KC_A,    KC_R,    KC_S,    KC_T,    KC_D,    KC_P4,   KC_P5,   KC_P6,    KC_H,    KC_N,    KC_E,    KC_I, LT_MC(KC_O), KC_QUOT, \
97   KC_LSFT,  KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_P1,   KC_P2,   KC_P3,    KC_K,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH,  CTL_ENT, \
98   KC_GRV,   KC_LCTRL, KC_LGUI, KC_LALT, LOWER,  KC_SPC,  KC_P0,   KC_DOT,  KC_EQL,   KC_SPC,  RAISE,   KC_LEFT, KC_DOWN, KC_UP,    KC_RGHT  \
99   ),
100
101 /* Dvorak
102  * ,------+------+------+------+------+------------------------------------------------.
103  * |  Esc |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  |   -  |
104  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
105  * | Tab  |   "  |   ,  |   .  |   P  |   Y  |   7  |   8  |   9  |   F  |   G  |   C  |   R  |   L  | Bksp |
106  * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
107  * | Esc  |   A  |   O  |   E  |   U  |   I  |   4  |   5  |   6  |   D  |   H  |   T  |   N  |   S  |  /   |
108  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
109  * | Shift|   ;  |   Q  |   J  |   K  |   X  |   1  |   2  |   3  |   B  |   M  |   W  |   V  |   Z  |Ctl/Et|
110  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
111  * |   `  | Ctrl | Alt  | GUI  |Lower |Space |   0  |   .  |   =  |Space |Raise | Left | Down |  Up  |Right |
112  * `--------------------------------------------------------------------------------------------------------'
113  */
114 [_DVORAK] = LAYOUT(
115   KC_ESC,   KC_F1,    KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,    KC_F9,   KC_F10, KC_DEL,\
116   KC_TAB,   KC_QUOT,  KC_COMM, KC_DOT,  KC_P,    KC_Y,    KC_P7,   KC_P8,   KC_P9,    KC_F,    KC_G,   KC_C,    KC_R,    KC_L,     KC_BSPC, \
117   KC_LCTL,  KC_A,     KC_O,    KC_E,    KC_U,    KC_I,    KC_P4,   KC_P5,   KC_P6,    KC_D,    KC_H,   KC_T,    KC_N, LT_MC(KC_S), KC_SLSH, \
118   KC_LSFT,  KC_SCLN,  KC_Q,    KC_J,    KC_K,    KC_X,    KC_P1,   KC_P2,   KC_P3,    KC_B,    KC_M,   KC_W,    KC_V,    KC_Z,     CTL_ENT, \
119   KC_GRV,   KC_LCTRL, KC_LGUI, KC_LALT, LOWER,   KC_SPC,  KC_P0,   KC_DOT,  KC_EQL,   KC_SPC,  RAISE,  KC_LEFT, KC_DOWN, KC_UP,    KC_RGHT \
120 ),
121
122 /* Lower
123  * ,------+------+------+------+------+------------------------------------------------.
124  * |   ~  |   !  |   @  |   #  |   $  |   %  |   ^  |   &  |   *  |   (  |   )  | Bksp |
125  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
126  * |   ~  |   !  |   @  |   #  |   $  |   %  |      |      |      |   ^  |   &  |   *  |   (  |   )  | Del  |
127  * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
128  * |      |  F1  |  F2  |  F3  |  F4  |  F5  |      |      |      |  F6  |   _  |   +  |   {  |   }  |  |   |
129  * |------+------+------+------+------+------|------+------+------+------+------+------+------+------+------|
130  * |      |  F7  |  F8  |  F9  |  F10 |  F11 |      |      |      |  F12 |ISO ~ |ISO | |      |      |      |
131  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
132  * |      |      |      |      |      |      |      |      |      |      |      | Next | Vol- | Vol+ | Play |
133  * `--------------------------------------------------------------------------------------------------------'
134  */
135 [_LOWER] = LAYOUT(
136   KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
137   KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, _______, _______, _______, KC_CIRC, KC_AMPR, KC_ASTR,  KC_LPRN, KC_RPRN, KC_DEL, \
138   _______, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   _______, _______, _______, KC_F6,   KC_UNDS, KC_PLUS,  KC_LBRC, KC_RBRC, KC_PIPE, \
139   _______, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  _______, _______, _______, KC_F12,S(KC_NUHS),S(KC_NUBS),_______,_______, _______, \
140   _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
141 ),
142
143 /* Raise
144  * ,------+------+------+------+------+------------------------------------------------.
145  * |  Esc |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  |   -  |
146  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
147  * |   `  |   1  |   2  |   3  |   4  |   5  |      |      |      |   6  |   7  |   8  |   9  |   0  | Del  |
148  * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
149  * | Del  |  F1  |  F2  |  F3  |  F4  |  F5  |      |      |      |  F6  |   -  |   =  |   [  |   ]  |  \   |
150  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
151  * |      |  F7  |  F8  |  F9  |  F10 |  F11 |      |      |      |  F12 |ISO # |ISO / |      |      |      |
152  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
153  * |      |      |      |      |      |      |      |      |      |      |      | Next | Vol- | Vol+ | Play |
154  * `--------------------------------------------------------------------------------------------------------'
155  */
156 [_RAISE] = LAYOUT(
157   KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC, \
158   KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    _______, _______, _______, KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_DEL, \
159   KC_DEL,  KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   _______, _______, _______, KC_F6,   KC_MINS, KC_EQL,  KC_LBRC, KC_RBRC, KC_BSLS, \
160   _______, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  _______, _______, _______, KC_F12,  KC_NUHS, KC_NUBS, _______, _______, _______, \
161   _______, _______, _______, _______,  _______, KC_SPC, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY   \
162 ),
163
164 /* Mouse Layer (semi-col)
165  * ,------+------+------+------+------+------------------------------------------------.
166  * | ACCL0| ACCL1| ACCL2|      |      |      |      |      |      |      |      |      |
167  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
168  * |      |      |      |      |      |      |      |      | Home | Wh_Up| WHL_L| M_Up | WHL_R| Macro|      |
169  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
170  * |      |      |      |      |      |      |      |      | End  | Wh_Dn| M_Lft| M_Dn | M_Rt |      |      |
171  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
172  * |      |      |      |      |      |      |      |      |      | BTN2 | BTN3 | BTN4 | BTN5 |      |      |
173  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
174  * |      |      |      |      |      | BTN1 |      |      |      | BTN1 |      |      |      |      |      |
175  * `--------------------------------------------------------------------------------------------------------'
176  */
177
178 [_MOUSECURSOR] = LAYOUT(
179   KC_ACL0, KC_ACL1, KC_ACL2, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
180   _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGUP, KC_WH_L, KC_MS_U, KC_WH_R,DEMOMACRO,_______, \
181   _______, _______, _______, _______, _______, _______, _______, _______, KC_END , KC_PGDN, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, \
182   _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_BTN2, KC_BTN3, KC_BTN4, KC_BTN5, _______, _______, \
183   _______, _______, _______, _______, _______, KC_BTN1, _______, _______, _______, KC_BTN1, _______, _______, _______, _______, _______  \
184 ),
185
186 /* Adjust (Lower + Raise)
187  * ,------+------+------+------+------+------------------------------------------------.
188  * |  Esc |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  |   -  |
189  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
190  * | Reset|RGB TG|RGB ST|RGBH -|RGBH +|RGBS -|RGBS +|RGBV -|RGBV +|      |      |      |      |      |  Del |
191  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
192  * |      |      |      |Aud on|Audoff|AGnorm|      |      |      |AGswap|Qwerty|Colemk|      |      |      |
193  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
194  * |      |Voice-|Voice+|Mus on|Musoff|      |      |      |      |      |      |      | BL + |BL ST |BL TG |
195  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
196  * |      |      |      |      |      |      |      |      |      |      |      |      |      |      |      |
197  * `--------------------------------------------------------------------------------------------------------'
198  */
199 [_ADJUST] = LAYOUT(
200   KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12, \
201   RESET,   RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______, _______, KC_DEL, \
202   _______, _______, _______, AU_ON,   AU_OFF,  AG_NORM, _______, _______, _______, AG_SWAP, QWERTY,  COLEMAK, _______,  _______,  _______, \
203   _______, MUV_DE,  MUV_IN,  MU_ON,   MU_OFF,  MI_ON,   MI_OFF, _______, _______, _______,  _______, BL_DEC,  BL_INC,  BL_STEP, BL_TOGG, \
204   _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______\
205 )
206
207
208
209 };
210
211 // define variables for reactive RGB
212 bool RGB_INIT = false;
213 bool TOG_STATUS = false;
214 int RGB_current_mode;
215
216 void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
217   if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
218     rgblight_mode(RGB_current_mode);
219     layer_on(layer3);
220   } else {
221     layer_off(layer3);
222   }
223 }
224
225 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
226   switch (keycode) {
227     case QWERTY:
228       if (record->event.pressed) {
229         set_single_persistent_default_layer(_QWERTY);
230       }
231       return false;
232       break;
233     case COLEMAK:
234       if (record->event.pressed) {
235         set_single_persistent_default_layer(_COLEMAK);
236       }
237       return false;
238       break;
239     case LOWER:
240       if (record->event.pressed) {
241           //not sure how to have keyboard check mode and set it to a variable, so my work around
242           //uses another variable that would be set to true after the first time a reactive key is pressed.
243         if (RGB_INIT) {} else {
244           RGB_current_mode = rgblight_config.mode;
245           RGB_INIT = true;
246         }
247         if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
248         } else {
249           TOG_STATUS = !TOG_STATUS;
250           rgblight_mode(16);
251         }
252         layer_on(_LOWER);
253         update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
254       } else {
255         rgblight_mode(RGB_current_mode);   // revert RGB to initial mode prior to RGB mode change
256         TOG_STATUS = false;
257         layer_off(_LOWER);
258         update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
259       }
260       return false;
261       break;
262     case RAISE:
263       if (record->event.pressed) {
264         //not sure how to have keyboard check mode and set it to a variable, so my work around
265         //uses another variable that would be set to true after the first time a reactive key is pressed.
266         if (RGB_INIT) {} else {
267           RGB_current_mode = rgblight_config.mode;
268           RGB_INIT = true;
269         }
270         if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
271         } else {
272           TOG_STATUS = !TOG_STATUS;
273           rgblight_mode(15);
274         }
275         layer_on(_RAISE);
276         update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
277       } else {
278         rgblight_mode(RGB_current_mode);  // revert RGB to initial mode prior to RGB mode change
279         layer_off(_RAISE);
280         TOG_STATUS = false;
281         update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
282       }
283       return false;
284       break;
285     case BACKLIT:
286       if (record->event.pressed) {
287         register_code(KC_RSFT);
288         #ifdef BACKLIGHT_ENABLE
289           backlight_step();
290         #endif
291       } else {
292         unregister_code(KC_RSFT);
293       }
294       return false;
295       break;
296     case RGB_MOD:
297       //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
298       if (record->event.pressed) {
299         rgblight_mode(RGB_current_mode);
300         rgblight_step();
301         RGB_current_mode = rgblight_config.mode;
302       }
303       return false;
304       break;
305   }
306   return true;
307 }
308
309
310
311 /*
312  * Macro definition
313  */
314 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
315 {
316     if (!eeconfig_is_enabled()) {
317       eeconfig_init();
318     }
319
320     switch (id) {
321       case KC_DEMOMACRO:
322         if (record->event.pressed){
323           return MACRO (I(1), T(H),T(E),T(L), T(L), T(O), T(SPACE), T(W), T(O), T(R), T(L), T(D),  END);
324         }
325     }
326
327     return MACRO_NONE;
328 }
329
330
331 //Functions for ver2
332 #ifdef KEYBOARD_hadron_ver2
333 #include "LUFA/Drivers/Peripheral/TWI.h"
334 void matrix_init_user(void) {
335   #ifdef USE_I2C
336     i2c_master_init();
337   #ifdef SSD1306OLED
338   // calls code for the SSD1306 OLED
339         _delay_ms(400);
340         TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
341         iota_gfx_init();   // turns on the display
342   #endif
343   #endif
344     #ifdef AUDIO_ENABLE
345         startup_user();
346     #endif
347 }
348
349
350 void matrix_scan_user(void) {
351     #ifdef SSD1306OLED
352      iota_gfx_task();  // this is what updates the display continuously
353     #endif
354 }
355
356 void matrix_update(struct CharacterMatrix *dest,
357                           const struct CharacterMatrix *source) {
358   if (memcmp(dest->display, source->display, sizeof(dest->display))) {
359     memcpy(dest->display, source->display, sizeof(dest->display));
360     dest->dirty = true;
361   }
362 }
363 //assign the right code to your layers for OLED display
364 #define L_BASE 0
365 #define L_LOWER 8
366 #define L_RAISE 16
367 #define L_FNLAYER 64
368 #define L_NUMLAY 128
369 #define L_NLOWER 136
370 #define L_NFNLAYER 192
371 #define L_MOUSECURSOR 256
372 #define L_ADJUST 65560
373
374 void iota_gfx_task_user(void) {
375 #if DEBUG_TO_SCREEN
376   if (debug_enable) {
377     return;
378   }
379 #endif
380
381   struct CharacterMatrix matrix;
382
383   matrix_clear(&matrix);
384   matrix_write_P(&matrix, PSTR("USB: "));
385 #ifdef PROTOCOL_LUFA
386   switch (USB_DeviceState) {
387     case DEVICE_STATE_Unattached:
388       matrix_write_P(&matrix, PSTR("Unattached"));
389       break;
390     case DEVICE_STATE_Suspended:
391       matrix_write_P(&matrix, PSTR("Suspended"));
392       break;
393     case DEVICE_STATE_Configured:
394       matrix_write_P(&matrix, PSTR("Connected"));
395       break;
396     case DEVICE_STATE_Powered:
397       matrix_write_P(&matrix, PSTR("Powered"));
398       break;
399     case DEVICE_STATE_Default:
400       matrix_write_P(&matrix, PSTR("Default"));
401       break;
402     case DEVICE_STATE_Addressed:
403       matrix_write_P(&matrix, PSTR("Addressed"));
404       break;
405     default:
406       matrix_write_P(&matrix, PSTR("Invalid"));
407   }
408 #endif
409
410 // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
411
412   char buf[40];
413   snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
414   matrix_write_P(&matrix, PSTR("\n\nLayer: "));
415     switch (layer_state) {
416         case L_BASE:
417            matrix_write_P(&matrix, PSTR("Default"));
418            break;
419         case L_RAISE:
420            matrix_write_P(&matrix, PSTR("Raise"));
421            break;
422         case L_LOWER:
423            matrix_write_P(&matrix, PSTR("Lower"));
424            break;
425         case L_ADJUST:
426            matrix_write_P(&matrix, PSTR("ADJUST"));
427            break;
428         default:
429            matrix_write(&matrix, buf);
430  }
431
432   // Host Keyboard LED Status
433   char led[40];
434     snprintf(led, sizeof(led), "\n%s  %s  %s",
435             (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : "       ",
436             (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : "    ",
437             (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : "    ");
438   matrix_write(&matrix, led);
439   matrix_update(&display, &matrix);
440 }
441
442 #endif