logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

keymap.c (6728B)


  1. /* Copyright 2020 Brandon Schlack
  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. enum layer_names {
  18. _BASE = 0,
  19. _FN
  20. };
  21. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  22. [_BASE] = LAYOUT_4x4_encoders(
  23. KC_MUTE, KC_MPLY,
  24. KC_PMNS, KC_P7, KC_P8, KC_P9,
  25. KC_PPLS, KC_P4, KC_P5, KC_P6,
  26. KC_BSPC, KC_P1, KC_P2, KC_P3,
  27. KC_PENT, MO(_FN), KC_P0, KC_PDOT
  28. ),
  29. [_FN] = LAYOUT_4x4_encoders(
  30. _______, _______,
  31. KC_PSLS, KC_F21, KC_F22, KC_F23,
  32. KC_PAST, KC_F18, KC_F19, KC_F20,
  33. KC_NUM, KC_F15, KC_F16, KC_F17,
  34. QK_BOOT, _______, KC_F13, KC_F14
  35. )
  36. };
  37. bool encoder_update_user(uint8_t index, bool clockwise) {
  38. if (index == 0) { /* Left encoder */
  39. if (clockwise) {
  40. tap_code16(KC_VOLU);
  41. } else {
  42. tap_code16(KC_VOLD);
  43. }
  44. } else if (index == 1) { /* Right encoder */
  45. if (clockwise) {
  46. tap_code16(KC_MNXT);
  47. } else {
  48. tap_code16(KC_MPRV);
  49. }
  50. }
  51. return true;
  52. }
  53. #ifdef OLED_ENABLE
  54. static uint32_t oled_logo_timer = 0;
  55. bool oled_logo_cleared = false; // Set to true if you don't want a logo at all
  56. static void render_status(void) {
  57. // Host Keyboard Layer Status
  58. oled_write_P(PSTR("Layer: "), false);
  59. switch (get_highest_layer(layer_state)) {
  60. case _BASE:
  61. oled_write_P(PSTR("Numpad\n"), false);
  62. break;
  63. case _FN:
  64. oled_write_P(PSTR("Macropad\n"), false);
  65. break;
  66. default:
  67. // Or use the write_ln shortcut over adding '\n' to the end of your string
  68. oled_write_ln_P(PSTR("Some Other Layer"), false);
  69. }
  70. // Empty Line
  71. oled_write_ln_P(PSTR(" "), false);
  72. // Host Keyboard LED Status
  73. led_t led_state = host_keyboard_led_state();
  74. oled_write_P(led_state.num_lock ? PSTR(" NUM ") : PSTR(" "), led_state.num_lock);
  75. oled_write_P(led_state.caps_lock ? PSTR(" CAP ") : PSTR(" "), led_state.caps_lock);
  76. oled_write_P(led_state.scroll_lock ? PSTR(" SCR ") : PSTR(" "), led_state.scroll_lock);
  77. }
  78. /*
  79. How to convert your own image:
  80. https://docs.splitkb.com/hc/en-us/articles/360013811280
  81. */
  82. static void render_logo(void) {
  83. static const char radpad_logo [] PROGMEM = {
  84. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf8, 0xf8,
  85. 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf0, 0xf0, 0xf0, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00,
  86. 0x00, 0x00, 0x00, 0xe0, 0xf0, 0xf0, 0xf0, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  87. 0x60, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0,
  88. 0xc0, 0xc0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, 0xf8, 0xf8, 0xf8,
  89. 0xf8, 0xf0, 0xf0, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xf0, 0xf0, 0xe0,
  90. 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0,
  91. 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
  92. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7,
  93. 0xf1, 0xf8, 0xf8, 0xfc, 0xfc, 0xfe, 0x7f, 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x00, 0x80, 0xe0,
  94. 0xf8, 0xfc, 0xff, 0xff, 0xff, 0xbf, 0xff, 0xff, 0xff, 0xfe, 0xc0, 0xc0, 0xe0, 0xe0, 0xe0, 0xc0,
  95. 0xc0, 0xf0, 0xfd, 0xff, 0xff, 0xff, 0x3f, 0x0f, 0x01, 0x00, 0x00, 0x81, 0xc1, 0xff, 0xff, 0xff,
  96. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xf9, 0xf8, 0xfc, 0x7e, 0x7e, 0x3f,
  97. 0x3f, 0x1f, 0x1f, 0x0f, 0x07, 0x03, 0x80, 0xc0, 0xf0, 0xfc, 0xff, 0xff, 0xff, 0xbf, 0xff, 0xff,
  98. 0xff, 0xff, 0xe0, 0xc0, 0xc0, 0xe0, 0xe0, 0xc0, 0x80, 0xe0, 0xfd, 0xff, 0xff, 0xff, 0x7f, 0x0f,
  99. 0x03, 0x00, 0x00, 0x81, 0xc1, 0xf3, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x0f, 0x00, 0x00, 0x00, 0x00,
  100. 0x00, 0x00, 0x00, 0x00, 0x80, 0xf0, 0xfc, 0xff, 0xff, 0x7f, 0x1f, 0x0f, 0x03, 0x03, 0x03, 0x01,
  101. 0x01, 0x01, 0x0f, 0x7f, 0xff, 0xff, 0xfe, 0x80, 0x00, 0xe0, 0xf0, 0xf8, 0xfc, 0xff, 0xff, 0x3f,
  102. 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x0f, 0x07, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xe3, 0xf9, 0xff,
  103. 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xfc, 0xfc, 0x7e, 0x3e, 0x3f, 0x1f, 0x1f, 0x8f, 0xe7, 0xff,
  104. 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  105. 0x00, 0xc0, 0xf0, 0xf8, 0xfc, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x0f, 0x07, 0x1f,
  106. 0xff, 0xff, 0xff, 0xff, 0xc3, 0xe3, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xf8, 0xfc,
  107. 0x7e, 0x3e, 0x3f, 0x1f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  108. 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  109. 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x07, 0x00, 0x01, 0x01, 0x03, 0x03, 0x01, 0x00, 0x00,
  110. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x03, 0x07, 0x07, 0x07, 0x07, 0x03,
  111. 0x07, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1f, 0x1f, 0x0f,
  112. 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  113. 0x00, 0x00, 0x01, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  114. 0x01, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00,
  115. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  116. };
  117. oled_write_raw_P(radpad_logo, sizeof(radpad_logo));
  118. }
  119. bool oled_task_user(void) {
  120. if (oled_logo_cleared) {
  121. render_status();
  122. } else {
  123. if (timer_elapsed32(oled_logo_timer) > OLED_LOGO_TIMEOUT) {
  124. oled_clear();
  125. oled_logo_cleared = true;
  126. render_status();
  127. } else {
  128. render_logo();
  129. }
  130. }
  131. return false;
  132. }
  133. #endif