rev2.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Copyright 2022 Kyle McCreery
  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 "rev2.h"
  17. #ifdef ENCODER_ENABLE
  18. bool encoder_update_kb(uint8_t index, bool clockwise) {
  19. if (!encoder_update_user(index, clockwise)) { return false; }
  20. switch (index) {
  21. case 0:
  22. if (clockwise) {
  23. tap_code(KC_VOLU);
  24. } else {
  25. tap_code(KC_VOLD);
  26. }
  27. break;
  28. }
  29. return true;
  30. }
  31. #endif
  32. #ifdef OLED_ENABLE
  33. static const char PROGMEM mw_logo[] = {
  34. 0x8A, 0x8B, 0x8C, 0x8D, '\r',
  35. 0xAA, 0xAB, 0xAC, 0xAD, 0xAE,
  36. 0xCA, 0xCB, 0xCC, 0xCD, '\r',
  37. 0x20, 0x8E, 0x8F, 0x90, 0x00};
  38. oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
  39. return OLED_ROTATION_270; // flips the display 270 degrees
  40. }
  41. bool oled_task_kb(void) {
  42. if (!oled_task_user()) {
  43. return false;
  44. }
  45. oled_write_P(mw_logo, false); // Render MechWild "MW" Logo
  46. oled_set_cursor(0,6);
  47. oled_write_ln_P(PSTR("Layer"), false);
  48. switch (get_highest_layer(layer_state)) {
  49. case 0:
  50. oled_write_ln_P(PSTR("Base"), false);
  51. break;
  52. case 1:
  53. oled_write_ln_P(PSTR("FN 1"), false);
  54. break;
  55. case 2:
  56. oled_write_ln_P(PSTR("FN 2"), false);
  57. break;
  58. case 3:
  59. oled_write_ln_P(PSTR("FN 3"), false);
  60. break;
  61. default:
  62. oled_write_ln_P(PSTR("Undef"), false);
  63. }
  64. oled_write_ln_P(PSTR(""), false);
  65. // Host Keyboard LED Status
  66. led_t led_state = host_keyboard_led_state();
  67. oled_write_ln_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false);
  68. oled_write_ln_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false);
  69. oled_write_ln_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);
  70. return true;
  71. }
  72. #endif