You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.0 KiB

  1. #include "quantum.h"
  2. #ifdef OLED_ENABLE
  3. oled_rotation_t oled_init_kb(oled_rotation_t rotation) { return OLED_ROTATION_180; }
  4. bool oled_task_kb(void) {
  5. if (!oled_task_user()) {
  6. return false;
  7. }
  8. oled_write_P(PSTR("LAYER "), false);
  9. oled_write_char(get_highest_layer(layer_state) + 0x30, true);
  10. led_t led_state = host_keyboard_led_state();
  11. oled_set_cursor(18, 0);
  12. oled_write_P(PSTR("NUM"), led_state.num_lock);
  13. oled_set_cursor(18, 1);
  14. oled_write_P(PSTR("CAP"), led_state.caps_lock);
  15. oled_set_cursor(18, 2);
  16. oled_write_P(PSTR("SCR"), led_state.scroll_lock);
  17. uint8_t mod_state = get_mods();
  18. oled_set_cursor(10, 3);
  19. oled_write_P(PSTR("S"), mod_state & MOD_MASK_SHIFT);
  20. oled_advance_char();
  21. oled_write_P(PSTR("C"), mod_state & MOD_MASK_CTRL);
  22. oled_advance_char();
  23. oled_write_P(PSTR("A"), mod_state & MOD_MASK_ALT);
  24. oled_advance_char();
  25. oled_write_P(PSTR("G"), mod_state & MOD_MASK_GUI);
  26. oled_advance_char();
  27. /* Matrix display is 12 x 12 pixels */
  28. #define MATRIX_DISPLAY_X 5
  29. #define MATRIX_DISPLAY_Y 18
  30. // matrix
  31. for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
  32. for (uint8_t y = 0; y < MATRIX_COLS; y++) {
  33. bool on = (matrix_get_row(x) & (1 << y)) > 0;
  34. oled_write_pixel(MATRIX_DISPLAY_X + y + 2, MATRIX_DISPLAY_Y + x + 2, on);
  35. }
  36. }
  37. // outline
  38. for (uint8_t x = 0; x < 19; x++) {
  39. oled_write_pixel(MATRIX_DISPLAY_X + x, MATRIX_DISPLAY_Y, true);
  40. oled_write_pixel(MATRIX_DISPLAY_X + x, MATRIX_DISPLAY_Y + 9, true);
  41. }
  42. for (uint8_t y = 0; y < 9; y++) {
  43. oled_write_pixel(MATRIX_DISPLAY_X, MATRIX_DISPLAY_Y+y, true);
  44. oled_write_pixel(MATRIX_DISPLAY_X + 19, MATRIX_DISPLAY_Y+y, true);
  45. }
  46. // oled location
  47. for (uint8_t x = 0; x < 3; x++) {
  48. oled_write_pixel(MATRIX_DISPLAY_X + 14 + x, MATRIX_DISPLAY_Y + 2, true);
  49. }
  50. // bodge for layer number left hand side
  51. for (uint8_t y = 0; y < 8; y++) {
  52. oled_write_pixel(35, 0 + y, true);
  53. }
  54. return false;
  55. }
  56. #endif