keymap.c 21 KB

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