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.

73 lines
2.0 KiB

  1. // Copyright 2022 Leon Anavi <leon@anavi.org>
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "quantum.h"
  4. #include <stdio.h>
  5. void keyboard_post_init_kb(void) {
  6. // Enable RGB LED
  7. gpio_set_pin_output(GP11);
  8. gpio_write_pin_high(GP11);
  9. rgblight_enable();
  10. // Offload to the user func
  11. keyboard_post_init_user();
  12. }
  13. #ifdef ENCODER_ENABLE
  14. bool encoder_update_kb(uint8_t index, bool clockwise) {
  15. if (!encoder_update_user(index, clockwise)) { return false; }
  16. if (0 == index) {
  17. if (clockwise) {
  18. tap_code(KC_VOLU);
  19. } else {
  20. tap_code(KC_VOLD);
  21. }
  22. } else if (1 == index) {
  23. if (clockwise) {
  24. tap_code(KC_UP);
  25. } else {
  26. tap_code(KC_DOWN);
  27. }
  28. } else if (2 == index) {
  29. if (clockwise) {
  30. tap_code(KC_LEFT);
  31. } else {
  32. tap_code(KC_RIGHT);
  33. }
  34. }
  35. return true;
  36. }
  37. #endif
  38. #ifdef OLED_ENABLE
  39. bool oled_task_kb(void) {
  40. if (!oled_task_user()) {
  41. return false;
  42. }
  43. // Host Keyboard Layer Status
  44. oled_write_ln_P(PSTR("ANAVI Knobs 3"), false);
  45. oled_write_ln_P(PSTR("Keymap: Default"), false);
  46. // Host Keyboard LED Status
  47. led_t led_state = host_keyboard_led_state();
  48. oled_write_P(PSTR("Num Lock: "), false);
  49. oled_write_ln_P(led_state.num_lock ? PSTR("On") : PSTR("Off"), false);
  50. oled_write_P(PSTR("Caps Lock: "), false);
  51. oled_write_ln_P(led_state.caps_lock ? PSTR("On") : PSTR("Off"), false);
  52. oled_write_P(PSTR("Scroll Lock: "), false);
  53. oled_write_ln_P(led_state.scroll_lock ? PSTR("On") : PSTR("Off"), false);
  54. #ifdef RGBLIGHT_ENABLE
  55. static char rgbStatusLine1[26] = {0};
  56. snprintf(rgbStatusLine1, sizeof(rgbStatusLine1), "RGB Mode: %d", rgblight_get_mode());
  57. oled_write_ln(rgbStatusLine1, false);
  58. static char rgbStatusLine2[26] = {0};
  59. snprintf(rgbStatusLine2, sizeof(rgbStatusLine2), "h:%d s:%d v:%d", rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val());
  60. oled_write_ln(rgbStatusLine2, false);
  61. #endif
  62. return false;
  63. }
  64. #endif