oled_utils.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include "oled_utils.h"
  2. void render_qmk_logo(void) {
  3. static const char PROGMEM qmk_logo[] = {
  4. 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
  5. 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4,
  6. 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00
  7. };
  8. oled_write_P(qmk_logo, false);
  9. }
  10. void render_layer(void) {
  11. oled_write_P(PSTR("\nLayer: "), false);
  12. switch (get_highest_layer(layer_state)) {
  13. case _QWERTY:
  14. oled_write_P(PSTR("Default\n"), false);
  15. break;
  16. case _LOWER:
  17. oled_write_P(PSTR("Lower\n"), false);
  18. break;
  19. case _RAISE:
  20. oled_write_P(PSTR("Raise\n"), false);
  21. break;
  22. case _ADJUST:
  23. oled_write_P(PSTR("Adjust\n"), false);
  24. break;
  25. default:
  26. oled_write_P(PSTR("???\n"), false);
  27. }
  28. }
  29. #ifdef ENCODER_ENABLE
  30. void render_encoder(encoder_mode_t mode) {
  31. switch (mode) {
  32. case ENC_MODE_VOLUME:
  33. oled_write_P(PSTR("Volume\n"), false);
  34. break;
  35. case ENC_MODE_WORD_NAV:
  36. oled_write_P(PSTR("Word Nav\n"), false);
  37. break;
  38. case ENC_MODE_LEFT_RIGHT:
  39. oled_write_P(PSTR("Left / Right\n"), false);
  40. break;
  41. case ENC_MODE_UP_DOWN:
  42. oled_write_P(PSTR("Up / Down\n"), false);
  43. break;
  44. case ENC_MODE_PAGING:
  45. oled_write_P(PSTR("PgUp / PgDwn\n"), false);
  46. break;
  47. default:
  48. oled_write_P(PSTR("???\n"), false);
  49. }
  50. }
  51. #endif
  52. #ifdef THUMBSTICK_ENABLE
  53. void render_thumbstick(thumbstick_mode_t mode) {
  54. switch (mode) {
  55. case THUMBSTICK_MODE_MOUSE:
  56. oled_write_P(PSTR("Mouse"), false);
  57. break;
  58. case THUMBSTICK_MODE_ARROWS:
  59. oled_write_P(PSTR("Arrows"), false);
  60. break;
  61. case THUMBSTICK_MODE_SCROLL:
  62. oled_write_P(PSTR("Scroll"), false);
  63. break;
  64. default:
  65. oled_write_P(PSTR("???\n"), false);
  66. }
  67. }
  68. #endif
  69. void render_status(void) {
  70. if (is_keyboard_master()) {
  71. // Host Keyboard Layer Status
  72. render_layer();
  73. #ifdef ENCODER_ENABLE
  74. // Encoder state
  75. oled_write_P(PSTR("L-Enc: "), false);
  76. render_encoder(encoder_left_mode);
  77. oled_write_P(PSTR("R-Enc: "), false);
  78. render_encoder(encoder_right_mode);
  79. #endif
  80. #ifdef THUMBSTICK_ENABLE
  81. if (!isLeftHand) {
  82. // Thumbstick state
  83. oled_write_P(PSTR("Joystick: "), false);
  84. render_thumbstick(thumbstick_state.config.mode);
  85. }
  86. #endif
  87. // Host Keyboard LED Status
  88. led_t led_state = host_keyboard_led_state();
  89. oled_write_P(led_state.num_lock ? PSTR("NUMLCK ") : PSTR(" "), false);
  90. oled_write_P(led_state.caps_lock ? PSTR("CAPLCK ") : PSTR(" "), false);
  91. oled_write_P(led_state.scroll_lock ? PSTR("SCRLCK ") : PSTR(" "), false);
  92. } else {
  93. // QMK Logo and version information
  94. render_qmk_logo();
  95. oled_write_P(PSTR("\n Kyria v1.0\n"), false);
  96. }
  97. }