2019.c 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Copyright 2019 ishtob
  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 "quantum.h"
  17. #ifdef OLED_ENABLE
  18. oled_rotation_t oled_init_kb(oled_rotation_t rotation) { return OLED_ROTATION_180; }
  19. bool oled_task_kb(void) {
  20. if (!oled_task_user()) {
  21. return false;
  22. }
  23. oled_write_P(PSTR("BOSTON MK LAYER"), false);
  24. oled_advance_char();
  25. oled_write_char(get_highest_layer(layer_state) + 0x30, true);
  26. led_t led_state = host_keyboard_led_state();
  27. oled_set_cursor(18, 0);
  28. oled_write_P(PSTR("NUM"), led_state.num_lock);
  29. oled_set_cursor(18, 1);
  30. oled_write_P(PSTR("CAP"), led_state.caps_lock);
  31. oled_set_cursor(18, 2);
  32. oled_write_P(PSTR("SCR"), led_state.scroll_lock);
  33. uint8_t mod_state = get_mods();
  34. oled_set_cursor(10, 3);
  35. oled_write_P(PSTR("S"), mod_state & MOD_MASK_SHIFT);
  36. oled_advance_char();
  37. oled_write_P(PSTR("C"), mod_state & MOD_MASK_CTRL);
  38. oled_advance_char();
  39. oled_write_P(PSTR("A"), mod_state & MOD_MASK_ALT);
  40. oled_advance_char();
  41. oled_write_P(PSTR("G"), mod_state & MOD_MASK_GUI);
  42. oled_advance_char();
  43. /* Matrix display is 12 x 12 pixels */
  44. #define MATRIX_DISPLAY_X 8
  45. #define MATRIX_DISPLAY_Y 16
  46. // matrix
  47. for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
  48. for (uint8_t y = 0; y < MATRIX_COLS; y++) {
  49. bool on = (matrix_get_row(x) & (1 << y)) > 0;
  50. // force on for oled location
  51. if((x == 0) && (y >= (MATRIX_COLS - 2))) on = 1;
  52. oled_write_pixel(MATRIX_DISPLAY_X + y + y + 2, MATRIX_DISPLAY_Y + x + x + 2, on);
  53. oled_write_pixel(MATRIX_DISPLAY_X + y + y + 3, MATRIX_DISPLAY_Y + x + x + 2, on);
  54. oled_write_pixel(MATRIX_DISPLAY_X + y + y + 2, MATRIX_DISPLAY_Y + x + x + 3, on);
  55. oled_write_pixel(MATRIX_DISPLAY_X + y + y + 3, MATRIX_DISPLAY_Y + x + x + 3, on);
  56. }
  57. }
  58. // outline
  59. for (uint8_t x = 0; x < 12; x++) {
  60. oled_write_pixel(MATRIX_DISPLAY_X + x, MATRIX_DISPLAY_Y, true);
  61. oled_write_pixel(MATRIX_DISPLAY_X + x, MATRIX_DISPLAY_Y + 12, true);
  62. }
  63. for (uint8_t y = 0; y < 12; y++) {
  64. oled_write_pixel(MATRIX_DISPLAY_X, MATRIX_DISPLAY_Y+y, true);
  65. oled_write_pixel(MATRIX_DISPLAY_X + 12, MATRIX_DISPLAY_Y+y, true);
  66. }
  67. // bodge for layer number left hand side
  68. for (uint8_t y = 0; y < 8; y++) {
  69. oled_write_pixel(95, 0 + y, true);
  70. }
  71. return false;
  72. }
  73. #endif