logo

qmk_firmware

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

mirrored.c (2620B)


  1. // Copyright 2022 Kyle McCreery (@Kyle McCreery)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "quantum.h"
  4. #ifdef ENCODER_ENABLE
  5. bool encoder_update_kb(uint8_t index, bool clockwise) {
  6. if (!encoder_update_user(index, clockwise)) { return false; }
  7. switch (index) {
  8. case 0:
  9. if (clockwise) {
  10. tap_code(KC_VOLU);
  11. } else {
  12. tap_code(KC_VOLD);
  13. }
  14. break;
  15. case 1:
  16. if (clockwise) {
  17. tap_code(KC_PGUP);
  18. } else {
  19. tap_code(KC_PGDN);
  20. }
  21. break;
  22. }
  23. return true;
  24. }
  25. #endif
  26. #ifdef OLED_ENABLE
  27. oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
  28. return OLED_ROTATION_270; // flips the display 270 degrees
  29. }
  30. static void render_logo(void) { // Render MechWild "MW" Logo
  31. static const char PROGMEM logo_1[] = {0x8A, 0x8B, 0x8C, 0x8D, 0x00};
  32. static const char PROGMEM logo_2[] = {0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0x00};
  33. static const char PROGMEM logo_3[] = {0xCA, 0xCB, 0xCC, 0xCD, 0x00};
  34. static const char PROGMEM logo_4[] = {0x20, 0x8E, 0x8F, 0x90, 0x00};
  35. oled_set_cursor(0,0);
  36. oled_write_P(logo_1, false);
  37. oled_set_cursor(0,1);
  38. oled_write_P(logo_2, false);
  39. oled_set_cursor(0,2);
  40. oled_write_P(logo_3, false);
  41. oled_set_cursor(0,3);
  42. oled_write_P(logo_4, false);
  43. }
  44. bool oled_task_kb(void) {
  45. if (!oled_task_user()) {
  46. return false;
  47. }
  48. render_logo();
  49. oled_set_cursor(0,6);
  50. oled_write_ln_P(PSTR("Layer"), false);
  51. switch (get_highest_layer(layer_state)) {
  52. case 0:
  53. oled_write_ln_P(PSTR("Base"), false);
  54. break;
  55. case 1:
  56. oled_write_ln_P(PSTR("FN 1"), false);
  57. break;
  58. case 2:
  59. oled_write_ln_P(PSTR("FN 2"), false);
  60. break;
  61. case 3:
  62. oled_write_ln_P(PSTR("FN 3"), false);
  63. break;
  64. default:
  65. oled_write_ln_P(PSTR("Undef"), false);
  66. }
  67. oled_write_ln_P(PSTR(""), false);
  68. // Host Keyboard LED Status
  69. led_t led_state = host_keyboard_led_state();
  70. oled_write_ln_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false);
  71. oled_write_ln_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false);
  72. oled_write_ln_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);
  73. return false;
  74. }
  75. #endif