keymap.c 21 KB

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