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.

128 lines
4.6 KiB

  1. /* Copyright 2021 Drashna Jael're
  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 "work_board.h"
  17. #if !defined(VIA_ENABLE) && defined(ENCODER_ENABLE)
  18. bool encoder_update_kb(uint8_t index, bool clockwise) {
  19. if (!encoder_update_user(index, clockwise)) {
  20. return false;
  21. }
  22. if (clockwise) {
  23. tap_code(KC_VOLD);
  24. } else {
  25. tap_code(KC_VOLU);
  26. }
  27. return true;
  28. }
  29. #endif
  30. #ifdef OLED_ENABLE
  31. # ifdef RGB_MATRIX_ENABLE
  32. # error Cannot run OLED and Per Key RGB at the same time due to pin conflicts
  33. # endif
  34. __attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_90; }
  35. __attribute__((weak)) void oled_task_user(void) {
  36. oled_write_P(PSTR("LAYER"), false);
  37. oled_write_P(PSTR("Lower"), layer_state_is(3));
  38. oled_write_P(PSTR("Raise"), layer_state_is(4));
  39. oled_write_P(PSTR("Adjst"), layer_state_is(5));
  40. led_t led_usb_state = host_keyboard_led_state();
  41. oled_write_P(PSTR("Lock:"), false);
  42. oled_write_P(PSTR(" "), false);
  43. oled_write_P(PSTR("N"), led_usb_state.num_lock);
  44. oled_write_P(PSTR("C"), led_usb_state.caps_lock);
  45. oled_write_ln_P(PSTR("S"), led_usb_state.scroll_lock);
  46. uint8_t modifiers = get_mods() | get_oneshot_mods();
  47. oled_write_P(PSTR("Mods:"), false);
  48. oled_write_P(PSTR(" "), false);
  49. oled_write_P(PSTR("S"), (modifiers & MOD_MASK_SHIFT));
  50. oled_write_P(PSTR("C"), (modifiers & MOD_MASK_CTRL));
  51. oled_write_P(PSTR("A"), (modifiers & MOD_MASK_ALT));
  52. oled_write_P(PSTR("G"), (modifiers & MOD_MASK_GUI));
  53. /* Show Ctrl-Gui Swap options */
  54. static const char PROGMEM logo[][2][3] = {
  55. {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
  56. {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
  57. };
  58. oled_write_P(PSTR("BTMGK"), false);
  59. oled_write_P(PSTR(" "), false);
  60. oled_write_P(logo[0][0], !keymap_config.swap_lctl_lgui);
  61. oled_write_P(logo[1][0], keymap_config.swap_lctl_lgui);
  62. oled_write_P(PSTR(" "), false);
  63. oled_write_P(logo[0][1], !keymap_config.swap_lctl_lgui);
  64. oled_write_P(logo[1][1], keymap_config.swap_lctl_lgui);
  65. oled_write_P(PSTR(" NKRO"), keymap_config.nkro);
  66. }
  67. #endif
  68. #ifdef RGB_MATRIX_ENABLE
  69. // clang-format off
  70. led_config_t g_led_config = { {
  71. { 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48 },
  72. { 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25 },
  73. { 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 },
  74. { 12, 11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 0}
  75. }, {
  76. { 223, 63 }, { 203, 63 }, { 183, 63 }, { 162, 63 }, { 142, 63 }, { 122, 63 }, { 112, 63 }, { 101, 63 }, { 81, 63 }, { 61, 63 }, { 40, 63 }, { 20, 63 }, { 0, 63 },
  77. { 0, 42 }, { 20, 42 }, { 40, 42 }, { 61, 42 }, { 81, 42 }, { 101, 42 }, { 122, 42 }, { 142, 42 }, { 162, 42 }, { 183, 42 }, { 203, 42 }, { 223, 42 },
  78. { 223, 21 }, { 203, 21 }, { 183, 21 }, { 162, 21 }, { 142, 21 }, { 122, 21 }, { 101, 21 }, { 81, 21 }, { 61, 21 }, { 40, 21 }, { 20, 21 }, { 0, 21 },
  79. { 0, 0 }, { 20, 0 }, { 40, 0 }, { 61, 0 }, { 81, 0 }, { 101, 0 }, { 122, 0 }, { 142, 0 }, { 162, 0 }, { 183, 0 }, { 203, 0 }, { 223, 0 }
  80. }, {
  81. 1, 1, 1, 1, 1, 4,4,4, 1, 1, 1, 1, 1,
  82. 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
  83. 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
  84. 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1
  85. } };
  86. // clang-format on
  87. __attribute__((weak)) void rgb_matrix_indicators_user(void) {
  88. # ifdef VIA_ENABLE
  89. static bool layout_2u = false;
  90. static uint16_t timer = 0;
  91. if (timer_elapsed(timer) > 500) {
  92. timer = timer_read();
  93. layout_2u = (bool)via_get_layout_options();
  94. }
  95. if (layout_2u) {
  96. rgb_matrix_set_color(5, 0, 0, 0);
  97. rgb_matrix_set_color(7, 0, 0, 0);
  98. } else {
  99. rgb_matrix_set_color(6, 0, 0, 0);
  100. }
  101. # else
  102. rgb_matrix_set_color(5, 0, 0, 0);
  103. rgb_matrix_set_color(7, 0, 0, 0);
  104. # endif
  105. }
  106. void keyboard_pre_init_kb(void) {
  107. setPinOutput(B2);
  108. setPinOutput(B3);
  109. setPinOutput(B7);
  110. writePinLow(B2);
  111. writePinLow(B3);
  112. writePinLow(B7);
  113. keyboard_pre_init_user();
  114. }
  115. #endif