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