keymap.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* Copyright 2020 Leon Anavi <leon@anavi.org>
  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. #define _SCH 0
  18. #define _PCB 1
  19. #define _FN 2
  20. #define KC_X0 LT(_FN, KC_ESC)
  21. #ifdef RGBLIGHT_ENABLE
  22. // How long (in ms) to wait between animation steps for the rainbow mode
  23. const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {60, 30, 15};
  24. // How long (in milliseconds) to wait between animation steps for each of the "Swirling rainbow" animations
  25. const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {20, 10, 4};
  26. #endif
  27. /*
  28. * The keymap contains 2 layers for KiCad hotkeys and a 3rd layer
  29. * for controlling the backlighting and the underlighting.
  30. *
  31. * - Layer for KiCad Schematic hotkeys:
  32. * m - to move selected component
  33. * r - to rotate selected component
  34. * w - to wire components
  35. * v - to edit component value
  36. * F1 - zoom in
  37. * F2 - zoom out
  38. * F4 - zoom center
  39. *
  40. * - Layer for KiCad PCB layout hotkets:
  41. * m - to move selected component
  42. * r - to rotate selected component
  43. * x - to route a new track
  44. * v - to add a via
  45. * F1 - zoom in
  46. * F2 - zoom out
  47. * F4 - zoom center
  48. *
  49. */
  50. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  51. [_SCH] = LAYOUT_ortho_2x4(
  52. KC_M, KC_R, KC_W, KC_V,
  53. KC_F1, KC_F2, KC_F4, TO(_PCB)
  54. ),
  55. [_PCB] = LAYOUT_ortho_2x4(
  56. KC_M, KC_R, KC_X, KC_V,
  57. KC_F1, KC_F2, KC_F4, TO(_FN)
  58. ),
  59. [_FN] = LAYOUT_ortho_2x4(
  60. RGB_TOG, RGB_MOD, RGB_M_R, RGB_M_SN,
  61. BL_TOGG, BL_STEP, BL_BRTG, TO(_SCH)
  62. )
  63. };
  64. #ifdef OLED_DRIVER_ENABLE
  65. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  66. return OLED_ROTATION_180; // flips the display 180 degrees if offhand
  67. }
  68. void oled_task_user(void) {
  69. // Host Keyboard Layer Status
  70. oled_write_ln_P(PSTR("ANAVI Macro Pad 8"), false);
  71. oled_write_P(PSTR("Layer: "), false);
  72. switch (get_highest_layer(layer_state)) {
  73. case _SCH:
  74. oled_write_ln_P(PSTR("KiCad Schema"), false);
  75. break;
  76. case _PCB:
  77. oled_write_ln_P(PSTR("KiCad PCB"), false);
  78. break;
  79. case _FN:
  80. oled_write_ln_P(PSTR("FN "), false);
  81. break;
  82. default:
  83. // Or use the write_ln shortcut over adding '\n' to the end of your string
  84. oled_write_ln_P(PSTR("N/A"), false);
  85. }
  86. // Host Keyboard LED Status
  87. led_t led_state = host_keyboard_led_state();
  88. oled_write_P(PSTR("Num Lock: "), false);
  89. oled_write_ln_P(led_state.num_lock ? PSTR("On") : PSTR("Off"), false);
  90. oled_write_P(PSTR("Caps Lock: "), false);
  91. oled_write_ln_P(led_state.caps_lock ? PSTR("On") : PSTR("Off"), false);
  92. oled_write_P(PSTR("Scroll Lock: "), false);
  93. oled_write_ln_P(led_state.scroll_lock ? PSTR("On") : PSTR("Off"), false);
  94. oled_write_P(PSTR("Backlit: "), false);
  95. oled_write_ln_P(is_backlight_enabled() ? PSTR("On") : PSTR("Off"), false);
  96. #ifdef RGBLIGHT_ENABLE
  97. static char rgbStatusLine1[26] = {0};
  98. snprintf(rgbStatusLine1, sizeof(rgbStatusLine1), "RGB Mode: %d", rgblight_get_mode());
  99. oled_write_ln(rgbStatusLine1, false);
  100. static char rgbStatusLine2[26] = {0};
  101. snprintf(rgbStatusLine2, sizeof(rgbStatusLine2), "h:%d s:%d v:%d", rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val());
  102. oled_write_ln(rgbStatusLine2, false);
  103. #endif
  104. }
  105. #endif