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.

76 lines
1.7 KiB

  1. # Encoders
  2. Basic encoders are supported by adding this to your `rules.mk`:
  3. ```make
  4. ENCODER_ENABLE = yes
  5. ```
  6. and this to your `config.h`:
  7. ```c
  8. #define ENCODERS_PAD_A { B12 }
  9. #define ENCODERS_PAD_B { B13 }
  10. ```
  11. Each PAD_A/B variable defines an array so multiple encoders can be defined, e.g.:
  12. ```c
  13. #define ENCODERS_PAD_A { encoder1a, encoder2a }
  14. #define ENCODERS_PAD_B { encoder1b, encoder2b }
  15. ```
  16. If your encoder's clockwise directions are incorrect, you can swap the A & B pad definitions. They can also be flipped with a define:
  17. ```c
  18. #define ENCODER_DIRECTION_FLIP
  19. ```
  20. Additionally, the resolution can be specified in the same file (the default & suggested is 4):
  21. ```c
  22. #define ENCODER_RESOLUTION 4
  23. ```
  24. ## Split Keyboards
  25. If you are using different pinouts for the encoders on each half of a split keyboard, you can define the pinout for the right half like this:
  26. ```c
  27. #define ENCODERS_PAD_A_RIGHT { encoder1a, encoder2a }
  28. #define ENCODERS_PAD_B_RIGHT { encoder1b, encoder2b }
  29. ```
  30. ## Callbacks
  31. The callback functions can be inserted into your `<keyboard>.c`:
  32. ```c
  33. void encoder_update_kb(uint8_t index, bool clockwise) {
  34. encoder_update_user(index, clockwise);
  35. }
  36. ```
  37. or `keymap.c`:
  38. ```c
  39. void encoder_update_user(uint8_t index, bool clockwise) {
  40. if (index == 0) { /* First encoder */
  41. if (clockwise) {
  42. tap_code(KC_PGDN);
  43. } else {
  44. tap_code(KC_PGUP);
  45. }
  46. } else if (index == 1) { /* Second encoder */
  47. if (clockwise) {
  48. tap_code(KC_DOWN);
  49. } else {
  50. tap_code(KC_UP);
  51. }
  52. }
  53. }
  54. ```
  55. ## Hardware
  56. The A an B lines of the encoders should be wired directly to the MCU, and the C/common lines should be wired to ground.