You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

554 lines
26 KiB

  1. #include QMK_KEYBOARD_H
  2. #include "bootloader.h"
  3. #ifdef PROTOCOL_LUFA
  4. #include "lufa.h"
  5. #include "split_util.h"
  6. #endif
  7. #ifdef AUDIO_ENABLE
  8. #include "audio.h"
  9. #endif
  10. #ifdef SSD1306OLED
  11. #include "ssd1306.h"
  12. #endif
  13. extern keymap_config_t keymap_config;
  14. #ifdef RGBLIGHT_ENABLE
  15. //Following line allows macro to read current RGB settings
  16. extern rgblight_config_t rgblight_config;
  17. #endif
  18. extern uint8_t is_master;
  19. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  20. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  21. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  22. // entirely and just use numbers.
  23. enum layer_number {
  24. _QWERTY = 0,
  25. _LOWER,
  26. _RAISE,
  27. _FUNC,
  28. _ADJUST
  29. };
  30. enum custom_keycodes {
  31. QWERTY = SAFE_RANGE,
  32. LOWER,
  33. RAISE,
  34. FUNC,
  35. ADJUST,
  36. EISU,
  37. KANA
  38. };
  39. enum macro_keycodes {
  40. KC_SAMPLEMACRO,
  41. };
  42. //Macros
  43. #define M_SAMPLE M(KC_SAMPLEMACRO)
  44. #if HELIX_ROWS == 5
  45. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  46. /* Qwerty
  47. * ,-----------------------------------------. ,-----------------------------------------.
  48. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | = |
  49. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  50. * | Tab | Q | W | E | R | T | | Y | U | I | O | P | - |
  51. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  52. * | ESC | A | S | D | F | G | | H | J | K | L | ; | ' |
  53. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  54. * |Shift | Z | X | C | V | B | Fn | Fn | N | M | , | . | / |Shift |
  55. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  56. * | EISU | Ctrl | Alt | GUI |Lower |Space | Bksp |Enter |Space |Raise | GUI | Alt | Ctrl | KANA |
  57. * `-------------------------------------------------------------------------------------------------'
  58. */
  59. [_QWERTY] = LAYOUT( \
  60. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_EQL, \
  61. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_MINS, \
  62. KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
  63. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, FUNC, FUNC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
  64. EISU, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_BSPC, KC_ENT, KC_SPC, RAISE, KC_RGUI, KC_RALT, KC_RCTL, KANA \
  65. ),
  66. /* Lower
  67. * ,-----------------------------------------. ,-----------------------------------------.
  68. * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
  69. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  70. * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
  71. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  72. * | Del | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | |
  73. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  74. * | | F7 | F8 | F9 | F10 | F11 | | | F12 | | | | | |
  75. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  76. * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  77. * `-------------------------------------------------------------------------------------------------'
  78. */
  79. [_LOWER] = LAYOUT( \
  80. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \
  81. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \
  82. KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
  83. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, KC_F12, _______, _______, _______, _______, _______, \
  84. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  85. ),
  86. /* Raise
  87. * ,-----------------------------------------. ,-----------------------------------------.
  88. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp |
  89. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  90. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
  91. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  92. * | Del | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ |
  93. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  94. * | | F7 | F8 | F9 | F10 | F11 | | | F12 | | | | | |
  95. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  96. * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  97. * `-------------------------------------------------------------------------------------------------'
  98. */
  99. [_RAISE] = LAYOUT( \
  100. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
  101. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
  102. KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
  103. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, KC_F12, _______, _______, _______, _______, _______, \
  104. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  105. ),
  106. /* Func
  107. * ,-----------------------------------------. ,-----------------------------------------.
  108. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp |
  109. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  110. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
  111. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  112. * | | | | | | | | LEFT | DOWN | UP |RIGHT | PGUP | |
  113. * |------+------+------+------+------+------|------+------|------+------+------+------+------+------|
  114. * | | | | | | | | | HOME | END |Alt+ |Alt+ | PGDN | |
  115. * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
  116. * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  117. * `-------------------------------------------------------------------------------------------------'
  118. */
  119. [_FUNC] = LAYOUT( \
  120. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
  121. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
  122. _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_PGUP, _______, \
  123. _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_END, LALT(KC_LEFT), LALT(KC_RGHT), KC_PGDN, _______, \
  124. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  125. ),
  126. /* Adjust (Lower + Raise)
  127. * ,-----------------------------------------. ,-----------------------------------------.
  128. * | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 |
  129. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  130. * | | Reset| | | | | | | | | | | Del |
  131. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  132. * | | | |Aud on|Audoff| Mac | | Win |Qwerty| | | | |
  133. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  134. * | | | | | | | | | | |RGB ON| HUE+ | SAT+ | VAL+ |
  135. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  136. * | | | | | | | | | | | MODE | HUE- | SAT- | VAL- |
  137. * `-------------------------------------------------------------------------------------------------'
  138. */
  139. [_ADJUST] = LAYOUT( \
  140. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
  141. _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
  142. _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, _______, _______, _______, _______, \
  143. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \
  144. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD \
  145. )
  146. };
  147. #elif HELIX_ROWS == 4
  148. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  149. /* Qwerty
  150. * ,-----------------------------------------. ,-----------------------------------------.
  151. * | = | Q | W | E | R | T | | Y | U | I | O | P | - |
  152. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  153. * | Esc | A | S | D | F | G | | H | J | K | L | ; | ' |
  154. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  155. * | Shift| Z | X | C | V | B | | N | M | , | . | / |Enter |
  156. * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
  157. * | EISU | Ctrl | Alt | GUI |ESC/Lower | Func | Bksp |Enter |Space |Raise | GUI | Alt | Ctrl | KANA |
  158. * `-------------------------------------------------------------------------------------------------'
  159. */
  160. [_QWERTY] = LAYOUT( \
  161. KC_EQL, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_MINS, \
  162. KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
  163. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
  164. EISU, KC_LCTL, KC_LALT, KC_LGUI, LT(_LOWER, KC_ESC), FUNC, KC_BSPC, KC_ENT, KC_SPC, RAISE, KC_RGUI, KC_RALT, KC_RCTL, KANA \
  165. ),
  166. /* Lower
  167. * ,-----------------------------------------. ,-----------------------------------------.
  168. * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
  169. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  170. * | Del | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | |
  171. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  172. * | | F7 | F8 | F9 | F10 | F11 | | F12 | | | | | |
  173. * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
  174. * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  175. * `-------------------------------------------------------------------------------------------------'
  176. */
  177. [_LOWER] = LAYOUT( \
  178. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \
  179. KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
  180. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______, \
  181. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  182. ),
  183. /* Raise
  184. * ,-----------------------------------------. ,-----------------------------------------.
  185. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | |
  186. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  187. * | Del | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ |
  188. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  189. * | | F7 | F8 | F9 | F10 | F11 | | F12 | | | | | |
  190. * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
  191. * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  192. * `-------------------------------------------------------------------------------------------------'
  193. */
  194. [_RAISE] = LAYOUT( \
  195. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, \
  196. KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
  197. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______, \
  198. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  199. ),
  200. /* Func
  201. * ,-----------------------------------------. ,-----------------------------------------.
  202. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
  203. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  204. * | | | | | | | | LEFT | DOWN | UP |RIGHT | PGUP | |
  205. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  206. * | | | | | | | | HOME | END |Alt+ |Alt+ | PGDN | |
  207. * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
  208. * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  209. * `-------------------------------------------------------------------------------------------------'
  210. */
  211. [_FUNC] = LAYOUT( \
  212. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
  213. _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_PGUP, _______, \
  214. _______, _______, _______, _______, _______, _______, KC_HOME, KC_END, LALT(KC_LEFT), LALT(KC_RGHT), KC_PGDN, _______, \
  215. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  216. ),
  217. /* Adjust (Lower + Raise)
  218. * ,-----------------------------------------. ,-----------------------------------------.
  219. * | | Reset| | | | | | | | | | | Del |
  220. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  221. * | | | |Aud on|Audoff| Mac | | Win |Qwerty| | | | |
  222. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  223. * | | | | | | | | | |RGB ON| HUE+ | SAT+ | VAL+ |
  224. * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
  225. * | | | | | | | | | | | MODE | HUE- | SAT- | VAL- |
  226. * `-------------------------------------------------------------------------------------------------'
  227. */
  228. [_ADJUST] = LAYOUT( \
  229. _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
  230. _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, _______, _______, _______, _______, \
  231. _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \
  232. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD \
  233. )
  234. };
  235. #else
  236. #error "undefined keymaps"
  237. #endif
  238. #ifdef AUDIO_ENABLE
  239. float tone_qwerty[][2] = SONG(QWERTY_SOUND);
  240. float tone_dvorak[][2] = SONG(DVORAK_SOUND);
  241. float tone_colemak[][2] = SONG(COLEMAK_SOUND);
  242. float tone_plover[][2] = SONG(PLOVER_SOUND);
  243. float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND);
  244. float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
  245. #endif
  246. // define variables for reactive RGB
  247. bool TOG_STATUS = false;
  248. int RGB_current_mode;
  249. void persistent_default_layer_set(uint16_t default_layer) {
  250. eeconfig_update_default_layer(default_layer);
  251. default_layer_set(default_layer);
  252. }
  253. // Setting ADJUST layer RGB back to default
  254. void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  255. if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
  256. #ifdef RGBLIGHT_ENABLE
  257. //rgblight_mode(RGB_current_mode);
  258. #endif
  259. layer_on(layer3);
  260. } else {
  261. layer_off(layer3);
  262. }
  263. }
  264. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  265. switch (keycode) {
  266. case QWERTY:
  267. if (record->event.pressed) {
  268. #ifdef AUDIO_ENABLE
  269. PLAY_SONG(tone_qwerty);
  270. #endif
  271. persistent_default_layer_set(1UL<<_QWERTY);
  272. }
  273. return false;
  274. break;
  275. case LOWER:
  276. if (record->event.pressed) {
  277. //not sure how to have keyboard check mode and set it to a variable, so my work around
  278. //uses another variable that would be set to true after the first time a reactive key is pressed.
  279. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
  280. } else {
  281. TOG_STATUS = !TOG_STATUS;
  282. #ifdef RGBLIGHT_ENABLE
  283. //rgblight_mode(RGBLIGHT_MODE_SNAKE + 1);
  284. #endif
  285. }
  286. layer_on(_LOWER);
  287. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  288. } else {
  289. #ifdef RGBLIGHT_ENABLE
  290. //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
  291. #endif
  292. TOG_STATUS = false;
  293. layer_off(_LOWER);
  294. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  295. }
  296. return false;
  297. break;
  298. case RAISE:
  299. if (record->event.pressed) {
  300. //not sure how to have keyboard check mode and set it to a variable, so my work around
  301. //uses another variable that would be set to true after the first time a reactive key is pressed.
  302. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
  303. } else {
  304. TOG_STATUS = !TOG_STATUS;
  305. #ifdef RGBLIGHT_ENABLE
  306. //rgblight_mode(RGBLIGHT_MODE_SNAKE);
  307. #endif
  308. }
  309. layer_on(_RAISE);
  310. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  311. } else {
  312. #ifdef RGBLIGHT_ENABLE
  313. //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
  314. #endif
  315. layer_off(_RAISE);
  316. TOG_STATUS = false;
  317. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  318. }
  319. return false;
  320. break;
  321. case FUNC:
  322. if (record->event.pressed) {
  323. layer_on(_FUNC);
  324. } else {
  325. layer_off(_FUNC);
  326. }
  327. return false;
  328. break;
  329. case ADJUST:
  330. if (record->event.pressed) {
  331. layer_on(_ADJUST);
  332. } else {
  333. layer_off(_ADJUST);
  334. }
  335. return false;
  336. break;
  337. //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
  338. case RGB_MOD:
  339. #ifdef RGBLIGHT_ENABLE
  340. if (record->event.pressed) {
  341. rgblight_mode(RGB_current_mode);
  342. rgblight_step();
  343. RGB_current_mode = rgblight_config.mode;
  344. }
  345. #endif
  346. return false;
  347. break;
  348. case EISU:
  349. if (record->event.pressed) {
  350. if(keymap_config.swap_lalt_lgui==false){
  351. register_code(KC_LANG2);
  352. }else{
  353. SEND_STRING(SS_LALT("`"));
  354. }
  355. } else {
  356. unregister_code(KC_LANG2);
  357. }
  358. return false;
  359. break;
  360. case KANA:
  361. if (record->event.pressed) {
  362. if(keymap_config.swap_lalt_lgui==false){
  363. register_code(KC_LANG1);
  364. }else{
  365. SEND_STRING(SS_LALT("`"));
  366. }
  367. } else {
  368. unregister_code(KC_LANG1);
  369. }
  370. return false;
  371. break;
  372. }
  373. return true;
  374. }
  375. void matrix_init_user(void) {
  376. #ifdef AUDIO_ENABLE
  377. startup_user();
  378. #endif
  379. #ifdef RGBLIGHT_ENABLE
  380. RGB_current_mode = rgblight_config.mode;
  381. #endif
  382. //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
  383. #ifdef SSD1306OLED
  384. iota_gfx_init(!has_usb()); // turns on the display
  385. #endif
  386. }
  387. #ifdef AUDIO_ENABLE
  388. void startup_user()
  389. {
  390. _delay_ms(20); // gets rid of tick
  391. }
  392. void shutdown_user()
  393. {
  394. _delay_ms(150);
  395. stop_all_notes();
  396. }
  397. void music_on_user(void)
  398. {
  399. music_scale_user();
  400. }
  401. void music_scale_user(void)
  402. {
  403. PLAY_SONG(music_scale);
  404. }
  405. #endif
  406. //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
  407. #ifdef SSD1306OLED
  408. // hook point for 'led_test' keymap
  409. // 'default' keymap's led_test_init() is empty function, do nothing
  410. // 'led_test' keymap's led_test_init() force rgblight_mode_noeeprom(RGBLIGHT_MODE_RGB_TEST);
  411. __attribute__ ((weak))
  412. void led_test_init(void) {}
  413. void matrix_scan_user(void) {
  414. led_test_init();
  415. iota_gfx_task(); // this is what updates the display continuously
  416. }
  417. void matrix_update(struct CharacterMatrix *dest,
  418. const struct CharacterMatrix *source) {
  419. if (memcmp(dest->display, source->display, sizeof(dest->display))) {
  420. memcpy(dest->display, source->display, sizeof(dest->display));
  421. dest->dirty = true;
  422. }
  423. }
  424. //assign the right code to your layers for OLED display
  425. #define L_BASE 0
  426. #define L_LOWER (1<<_LOWER)
  427. #define L_RAISE (1<<_RAISE)
  428. #define L_FUNC (1<<_FUNC)
  429. #define L_ADJUST (1<<_ADJUST)
  430. #define L_ADJUST_TRI (L_ADJUST|L_RAISE|L_LOWER)
  431. static void render_logo(struct CharacterMatrix *matrix) {
  432. static char logo[]={
  433. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
  434. 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
  435. 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,
  436. 0};
  437. matrix_write(matrix, logo);
  438. //matrix_write_P(&matrix, PSTR(" Split keyboard kit"));
  439. }
  440. void render_status(struct CharacterMatrix *matrix) {
  441. // Render to mode icon
  442. static char logo[][2][3]={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}};
  443. if(keymap_config.swap_lalt_lgui==false){
  444. matrix_write(matrix, logo[0][0]);
  445. matrix_write_P(matrix, PSTR("\n"));
  446. matrix_write(matrix, logo[0][1]);
  447. }else{
  448. matrix_write(matrix, logo[1][0]);
  449. matrix_write_P(matrix, PSTR("\n"));
  450. matrix_write(matrix, logo[1][1]);
  451. }
  452. // 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
  453. char buf[40];
  454. snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
  455. matrix_write_P(matrix, PSTR("\nLayer: "));
  456. switch (layer_state) {
  457. case L_BASE:
  458. matrix_write_P(matrix, PSTR("Default"));
  459. break;
  460. case L_RAISE:
  461. matrix_write_P(matrix, PSTR("Raise"));
  462. break;
  463. case L_LOWER:
  464. matrix_write_P(matrix, PSTR("Lower"));
  465. break;
  466. case L_FUNC:
  467. matrix_write_P(matrix, PSTR("Func"));
  468. break;
  469. case L_ADJUST:
  470. case L_ADJUST_TRI:
  471. matrix_write_P(matrix, PSTR("Adjust"));
  472. break;
  473. default:
  474. matrix_write(matrix, buf);
  475. }
  476. // Host Keyboard LED Status
  477. char led[40];
  478. snprintf(led, sizeof(led), "\n%s %s %s",
  479. (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
  480. (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
  481. (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
  482. matrix_write(matrix, led);
  483. }
  484. void iota_gfx_task_user(void) {
  485. struct CharacterMatrix matrix;
  486. #if DEBUG_TO_SCREEN
  487. if (debug_enable) {
  488. return;
  489. }
  490. #endif
  491. matrix_clear(&matrix);
  492. if(is_master){
  493. render_status(&matrix);
  494. }else{
  495. render_logo(&matrix);
  496. }
  497. matrix_update(&display, &matrix);
  498. }
  499. #endif