2
0

keymap.c 22 KB

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