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.

164 lines
7.9 KiB

  1. /* Copyright 2021 adpenrose
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include QMK_KEYBOARD_H
  17. /* Base layout:
  18. * ,---------------------------------------------------------------------|
  19. * |` |1 |2 |3 |4 |5 |6 |7 |8 |9 |0 |- |= |Backspace| OLED|
  20. * |--------------------------------------------------------------- |
  21. * |Tab |Q |W |E |R |T |Y |U |I |O |P |[ | ] | \ OLED|
  22. * |---------------------------------------------------------------------|
  23. * |Caps |A |S |D |F |G |H |J |K |L |; |' | Enter | ENC |
  24. * |---------------------------------------------------------------------|
  25. * |Shft |Z |X |C |V |B |N |M |, |. |/ |Shift |Up| M1 |
  26. * |---------------------------------------------------------------------|
  27. * |Ctrl|GUI |Alt | Space |MO(2) |MO(3)| |Lt |Dn |Rt |
  28. * `---------------------------------------------------------------------|'
  29. */
  30. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  31. /* Base */
  32. [0] = LAYOUT_65_ansi_blocker(
  33. KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
  34. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,
  35. KC_LGUI, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_MUTE,
  36. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_DEL,
  37. KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(2), MO(3), KC_LEFT, KC_DOWN, KC_RIGHT
  38. ),
  39. [1] = LAYOUT_65_ansi_blocker(
  40. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  41. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  42. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  43. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  44. _______, _______, _______, _______, _______, _______, _______, _______, _______
  45. ),
  46. [2] = LAYOUT_65_ansi_blocker(
  47. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  48. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  49. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  50. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  51. _______, _______, _______, _______, _______, _______, _______, _______, _______
  52. ),
  53. [3] = LAYOUT_65_ansi_blocker(
  54. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______,
  55. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  56. RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY,
  57. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  58. _______, _______, _______, KC_SPC, _______, _______, _______, _______, _______
  59. ),
  60. };
  61. /* Encoder */
  62. #ifdef ENCODER_ENABLE
  63. bool encoder_update_user(uint8_t index, bool clockwise) {
  64. static uint8_t selected_layer = 0; /* Used to change the layer using the encoder. */
  65. if (clockwise){
  66. /* Check if left shift is pressed: */
  67. if (selected_layer < 3 && get_mods() & MOD_BIT(KC_LSFT)){
  68. selected_layer ++;
  69. layer_move(selected_layer); /* Jump up one layer. */
  70. } else {
  71. /* If shift isn't pressed, encoder will do this stuff: */
  72. switch (get_highest_layer(layer_state)){
  73. case 3:
  74. tap_code(KC_MNXT);
  75. break;
  76. default:
  77. tap_code(KC_VOLU);
  78. break;
  79. }
  80. }
  81. } else {
  82. /* Check if left shift is pressed: */
  83. if (selected_layer > 0 && get_mods() & MOD_BIT(KC_LSFT)){
  84. selected_layer --;
  85. layer_move(selected_layer); /* Go down one layer. */
  86. } else {
  87. /* If shift isn't pressed, encoder will do this stuff: */
  88. switch (get_highest_layer(layer_state)){
  89. case 3:
  90. tap_code(KC_MPRV);
  91. break;
  92. default:
  93. tap_code(KC_VOLD);
  94. break;
  95. }
  96. }
  97. }
  98. return false;
  99. }
  100. #endif
  101. /* Rotation of the OLED: */
  102. #ifdef OLED_ENABLE
  103. /* Function that renders the kintsugi logo in the desired order. */
  104. static void render_logo(void) {
  105. static const char PROGMEM logo_1[] = {
  106. 0x83, 0x84, 0x85, 0x86, 0x87, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0x00
  107. };
  108. static const char PROGMEM logo_2[] = {
  109. 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0x00
  110. };
  111. static const char PROGMEM logo_3[] = {
  112. 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0x00
  113. };
  114. oled_set_cursor(1,0);
  115. oled_write_P(logo_1, false);
  116. oled_set_cursor(1,4);
  117. oled_write_P(logo_2, false);
  118. oled_set_cursor(1,8);
  119. oled_write_P(logo_3, false);
  120. }
  121. /* Function that renders the current layer to the user. */
  122. void render_layer(void) {
  123. oled_set_cursor(0,12);
  124. switch (get_highest_layer(layer_state)){
  125. case 0:
  126. oled_write_P(PSTR("_BASE"), false);
  127. break;
  128. case 1:
  129. oled_write_P(PSTR("_KCAD"), false);
  130. break;
  131. case 2:
  132. oled_write_P(PSTR("_NMPD"), false);
  133. break;
  134. case 3:
  135. oled_write_P(PSTR("_FNCT"), false);
  136. break;
  137. default:
  138. oled_write_P(PSTR("_OhNo"), false);
  139. break;
  140. }
  141. }
  142. /* The following function displays wpm to the user. */
  143. void render_wpm(void) {
  144. oled_set_cursor(1,14);
  145. oled_write(get_u8_str(get_current_wpm(), '0'), false);
  146. oled_set_cursor(1,15);
  147. oled_write_P(PSTR("WPM"), false);
  148. }
  149. /* Function that renders stuff on the oled: */
  150. bool oled_task_user(void) {
  151. render_logo();
  152. render_layer();
  153. render_wpm();
  154. return false;
  155. }
  156. #endif