keymap.c 21 KB

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