1
0

yampad.c 2.2 KB

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