yampad.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Copyright 2019
  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 "yampad.h"
  17. #if defined(OLED_DRIVER_ENABLE)
  18. __attribute__((weak))
  19. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  20. return OLED_ROTATION_270; // flips the display 270 degrees
  21. }
  22. __attribute__((weak))
  23. void oled_task_user(void) {
  24. // Host Keyboard Layer Status
  25. oled_write_P(PSTR("Layer"), false);
  26. switch (get_highest_layer(layer_state)) {
  27. case 0:
  28. oled_write_ln_P(PSTR(" BAS"), false);
  29. break;
  30. case 1:
  31. oled_write_ln_P(PSTR(" NAV"), false);
  32. break;
  33. case 2:
  34. oled_write_ln_P(PSTR(" RGB"), false);
  35. break;
  36. default:
  37. // Or use the write_ln shortcut over adding '\n' to the end of your string
  38. oled_write_ln_P(PSTR(" UND"), false);
  39. }
  40. // Host Keyboard LED Status
  41. led_t led_state = host_keyboard_led_state();
  42. oled_write_P(PSTR("-----"), false);
  43. oled_write_P(PSTR("Stats"), false);
  44. oled_write_P(led_state.num_lock ? PSTR("num:*") : PSTR("num:."), false);
  45. oled_write_P(led_state.caps_lock ? PSTR("cap:*") : PSTR("cap:."), false);
  46. oled_write_P(led_state.scroll_lock ? PSTR("scr:*") : PSTR("scr:."), false);
  47. // Host Keyboard RGB backlight status
  48. oled_write_P(PSTR("-----"), false);
  49. oled_write_P(PSTR("Light"), false);
  50. static char led_buf[30];
  51. snprintf(led_buf, sizeof(led_buf) - 1, "RGB:%cM: %2d\nh: %2ds: %2dv: %2d\n",
  52. rgblight_is_enabled() ? '*' : '.', (uint8_t)rgblight_get_mode(),
  53. (uint8_t)(rgblight_get_hue() / RGBLIGHT_HUE_STEP),
  54. (uint8_t)(rgblight_get_sat() / RGBLIGHT_SAT_STEP),
  55. (uint8_t)(rgblight_get_val() / RGBLIGHT_VAL_STEP));
  56. oled_write(led_buf, false);
  57. }
  58. #endif