2
0

keymap.c 22 KB

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