custom_oled.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #include "custom_oled.h"
  2. #include "process_records.h"
  3. #include <stdio.h>
  4. #ifdef OLED_DRIVER_ENABLE
  5. static void render_logo(void)
  6. {
  7. static const char PROGMEM sol_logo[] = {
  8. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
  9. 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
  10. 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
  11. oled_write_P(sol_logo, false);
  12. }
  13. static void render_status(void)
  14. {
  15. // Render to mode icon
  16. static const char PROGMEM mode_logo[2][3] = {
  17. {0x97,0x98,0},
  18. {0xb7,0xb8,0}
  19. };
  20. oled_write_P(mode_logo[0], false);
  21. #if defined(RGB_MATRIX_ENABLE)
  22. static char buffer[20] = {0};
  23. snprintf(buffer, sizeof(buffer), " h%3d s%3d v%3d\n", rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val);
  24. oled_write(buffer, false);
  25. #endif
  26. oled_write_P(mode_logo[1], false);
  27. #if defined(RGB_MATRIX_ENABLE)
  28. snprintf(buffer, sizeof(buffer), " s%3d m%3d\n", rgb_matrix_config.speed, rgb_matrix_config.mode);
  29. oled_write(buffer, false);
  30. #endif
  31. // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
  32. oled_write_P(PSTR("Layer: "), false);
  33. switch (biton32(layer_state))
  34. {
  35. case _QWERTY:
  36. #ifndef GAMELAYER_DISABLE
  37. switch (biton32(default_layer_state))
  38. {
  39. case _QWERTY:
  40. oled_write_P(PSTR("Default\n"), false);
  41. break;
  42. case _GAME:
  43. oled_write_P(PSTR("Game\n"), false);
  44. break;
  45. default:
  46. oled_write_P(PSTR("Undefined\n"), false);
  47. break;
  48. }
  49. #else
  50. oled_write_P(PSTR("Default\n"), false);
  51. #endif
  52. break;
  53. case _LOWER:
  54. oled_write_P(PSTR("Lower\n"), false);
  55. break;
  56. case _RAISE:
  57. oled_write_P(PSTR("Raise\n"), false);
  58. break;
  59. #ifdef TRILAYER_ENABLED
  60. case _ADJUST:
  61. oled_write_P(PSTR("Adjust\n"), false);
  62. break;
  63. #endif
  64. default:
  65. oled_write_P(PSTR("Undefined\n"), false);
  66. break;
  67. }
  68. // Host Keyboard LED Status
  69. uint8_t led_usb_state = host_keyboard_leds();
  70. oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false);
  71. oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false);
  72. oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false);
  73. }
  74. void oled_task_user(void)
  75. {
  76. if (is_keyboard_master())
  77. render_status();
  78. else
  79. {
  80. render_logo();
  81. oled_scroll_left();
  82. }
  83. }
  84. #endif