logo

qmk_firmware

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

keymap.c (5741B)


  1. /* Copyright 2020 plut0nium
  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. // Defines names for use in layer keycodes and the keymap
  18. enum layer_names {
  19. _QWERTY,
  20. _FN
  21. };
  22. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  23. /* Base */
  24. [_QWERTY] = LAYOUT(
  25. KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
  26. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
  27. MO(_FN), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT,
  28. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_PGUP, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
  29. KC_LCTL, KC_LGUI, KC_MENU, KC_LALT, KC_SPC, KC_SPC, KC_PGDN, KC_SPC, KC_SPC, KC_RALT, KC_LBRC, KC_RBRC, KC_RCTL
  30. ),
  31. [_FN] = LAYOUT(
  32. KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,
  33. QK_BOOT, _______, KC_UP, _______, _______, _______, _______, _______, _______, KC_F11, KC_F12, _______,
  34. _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, _______,
  35. _______, UG_HUEU, UG_SATU, UG_VALU, UG_NEXT, _______, KC_END, _______, _______, BL_UP, KC_MPLY, KC_VOLU, KC_MUTE,
  36. _______, UG_HUED, UG_SATD, UG_VALD, UG_TOGG, UG_TOGG, KC_HOME, BL_TOGG, BL_TOGG, BL_DOWN, KC_MPRV, KC_VOLD, KC_MNXT
  37. )
  38. };
  39. #ifdef OLED_ENABLE
  40. static void render_logo(void) {
  41. static const char PROGMEM my_logo[] = {
  42. // '0x3E_logo_32x16', 32x16px
  43. 0xff, 0x0f, 0x07, 0xf3, 0x73, 0xb3, 0x07, 0x0f, 0xff, 0x3f, 0x3f, 0xff, 0xff, 0x3f, 0x3f, 0xff,
  44. 0xe7, 0xe3, 0x33, 0x33, 0x03, 0x87, 0xff, 0xff, 0x03, 0x03, 0x33, 0x33, 0x33, 0xf3, 0xff, 0xff,
  45. 0x7f, 0x78, 0x70, 0x66, 0x67, 0x67, 0x70, 0x78, 0x7f, 0x67, 0x62, 0x78, 0x78, 0x62, 0x67, 0x7f,
  46. 0x73, 0x63, 0x67, 0x67, 0x60, 0x70, 0x7f, 0x7f, 0x60, 0x60, 0x67, 0x67, 0x67, 0x67, 0x7f, 0x7f
  47. };
  48. oled_write_raw_P(my_logo, sizeof(my_logo));
  49. }
  50. #ifdef RGBLIGHT_ENABLE
  51. void render_rgb_status(void) {
  52. oled_write_ln_P(PSTR("RGB"), false);
  53. if (!rgblight_is_enabled()) {
  54. oled_write_P(PSTR(" off\n\n\n"), false);
  55. }
  56. else {
  57. static char string[4] = {0};
  58. oled_write_P(PSTR("M:"), false);
  59. uint8_t n = rgblight_get_mode();
  60. string[3] = '\0';
  61. string[2] = '0' + n % 10;
  62. string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  63. string[0] = n / 10 ? '0' + n / 10 : ' ';
  64. oled_write(string, false);
  65. oled_write_P(PSTR("H:"), false);
  66. n = rgblight_get_hue();
  67. string[3] = '\0';
  68. string[2] = '0' + n % 10;
  69. string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  70. string[0] = n / 10 ? '0' + n / 10 : ' ';
  71. oled_write(string, false);
  72. oled_write_P(PSTR("S:"), false);
  73. n = rgblight_get_sat();
  74. string[3] = '\0';
  75. string[2] = '0' + n % 10;
  76. string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  77. string[0] = n / 10 ? '0' + n / 10 : ' ';
  78. oled_write(string, false);
  79. oled_write_P(PSTR("V:"), false);
  80. n = rgblight_get_val()/RGBLIGHT_VAL_STEP;
  81. string[3] = '\0';
  82. string[2] = '0' + n % 10;
  83. string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  84. string[0] = n / 10 ? '0' + n / 10 : ' ';
  85. oled_write(string, false);
  86. }
  87. }
  88. #endif
  89. void render_backlight_status(void) {
  90. oled_write_ln_P(PSTR("BKL"), false);
  91. if (!is_backlight_enabled()) {
  92. oled_write_P(PSTR(" off"), false);
  93. }
  94. else {
  95. char string[4];
  96. oled_write_P(PSTR("L:"), false);
  97. uint8_t n = get_backlight_level();
  98. string[3] = '\0';
  99. string[2] = '0' + n % 10;
  100. string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  101. string[0] = n / 10 ? '0' + n / 10 : ' ';
  102. oled_write(string, false);
  103. }
  104. }
  105. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  106. return OLED_ROTATION_270; // flips the display 180 degrees if offhand
  107. }
  108. bool oled_task_user(void) {
  109. render_logo();
  110. oled_set_cursor(0,2); // default logo is 16px high (2 lines)
  111. // Host Keyboard Layer Status
  112. oled_write_P(PSTR("Layer"), false);
  113. switch (get_highest_layer(layer_state)) {
  114. case _QWERTY:
  115. oled_write_P(PSTR("QWTY\n"), false);
  116. break;
  117. case _FN:
  118. oled_write_P(PSTR("FN\n"), false);
  119. break;
  120. default:
  121. // Or use the write_ln shortcut over adding '\n' to the end of your string
  122. oled_write_ln_P(PSTR("Undf"), false);
  123. }
  124. oled_write_P(PSTR("-----"), false);
  125. render_backlight_status();
  126. // Host Keyboard RGB status
  127. #ifdef RGBLIGHT_ENABLE
  128. oled_write_P(PSTR("-----"), false);
  129. render_rgb_status();
  130. #endif
  131. return false;
  132. }
  133. #endif