oled.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. Copyright 2021 Spencer Deven <splitlogicdesign@gmail.com>
  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 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifdef OLED_DRIVER_ENABLE
  15. static void render_logo(void) {
  16. static const char PROGMEM qmk_logo[] = {
  17. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
  18. 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
  19. 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0
  20. };
  21. oled_write_P(qmk_logo, false);
  22. }
  23. static void print_status_narrow(void) {
  24. // Print current mode
  25. oled_write_P(PSTR("\n\n"), false);
  26. switch (get_highest_layer(layer_state)) {
  27. case 0:
  28. oled_write_ln_P(PSTR("Qwrt"), false);
  29. break;
  30. default:
  31. oled_write_P(PSTR("Mod\n"), false);
  32. break;
  33. }
  34. oled_write_P(PSTR("\n\n"), false);
  35. // Print current layer
  36. oled_write_ln_P(PSTR("LAYER"), false);
  37. switch (get_highest_layer(layer_state)) {
  38. case 0:
  39. oled_write_P(PSTR("Base\n"), false);
  40. break;
  41. case 1:
  42. oled_write_P(PSTR("Raise"), false);
  43. break;
  44. case 2:
  45. oled_write_P(PSTR("Lower"), false);
  46. break;
  47. case 3:
  48. oled_write_P(PSTR("Adjust"), false);
  49. break;
  50. default:
  51. oled_write_ln_P(PSTR("Undef"), false);
  52. }
  53. oled_write_P(PSTR("\n\n"), false);
  54. led_t led_usb_state = host_keyboard_led_state();
  55. oled_write_ln_P(PSTR("CPSLK"), led_usb_state.caps_lock);
  56. }
  57. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  58. if (is_keyboard_master()) {
  59. return OLED_ROTATION_90;
  60. }
  61. return rotation;
  62. }
  63. void oled_task_user(void) {
  64. if (is_keyboard_master()) {
  65. print_status_narrow();
  66. } else {
  67. render_logo();
  68. }
  69. }
  70. #endif