diff options
author | James Young <18669334+noroadsleft@users.noreply.github.com> | 2020-11-28 12:02:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-28 12:02:18 -0800 |
commit | c66df1664497546f32662409778731143e45a552 (patch) | |
tree | da73a2d532a27685a31d932b3a44a707d4a3af81 /quantum/encoder.c | |
parent | 15385d4113414d42bd062c60c9de5df797d3157f (diff) | |
download | qmk_firmware-c66df1664497546f32662409778731143e45a552.tar.gz qmk_firmware-c66df1664497546f32662409778731143e45a552.zip |
2020 November 28 Breaking Changes Update (#11053)
* Branch point for 2020 November 28 Breaking Change
* Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183)
* Add support for soft serial to ATmega32U2 (#10204)
* Change MIDI velocity implementation to allow direct control of velocity value (#9940)
* Add ability to build a subset of all keyboards based on platform.
* Actually use eeprom_driver_init().
* Make bootloader_jump weak for ChibiOS. (#10417)
* Joystick 16-bit support (#10439)
* Per-encoder resolutions (#10259)
* Share button state from mousekey to pointing_device (#10179)
* Add hotfix for chibios keyboards not wake (#10088)
* Add advanced/efficient RGB Matrix Indicators (#8564)
* Naming change.
* Support for STM32 GPIOF,G,H,I,J,K (#10206)
* Add milc as a dependency and remove the installed milc (#10563)
* ChibiOS upgrade: early init conversions (#10214)
* ChibiOS upgrade: configuration file migrator (#9952)
* Haptic and solenoid cleanup (#9700)
* XD75 cleanup (#10524)
* OLED display update interval support (#10388)
* Add definition based on currently-selected serial driver. (#10716)
* New feature: Retro Tapping per key (#10622)
* Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638)
* Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530)
* Rescale both ChibiOS and AVR backlighting.
* Reduce Helix keyboard build variation (#8669)
* Minor change to behavior allowing display updates to continue between task ticks (#10750)
* Some GPIO manipulations in matrix.c change to atomic. (#10491)
* qmk cformat (#10767)
* [Keyboard] Update the Speedo firmware for v3.0 (#10657)
* Maartenwut/Maarten namechange to evyd13/Evy (#10274)
* [quantum] combine repeated lines of code (#10837)
* Add step sequencer feature (#9703)
* aeboards/ext65 refactor (#10820)
* Refactor xelus/dawn60 for Rev2 later (#10584)
* add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824)
* [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549)
* update chibios os usb for the otg driver (#8893)
* Remove HD44780 References, Part 4 (#10735)
* [Keyboard] Add Valor FRL TKL (+refactor) (#10512)
* Fix cursor position bug in oled_write_raw functions (#10800)
* Fixup version.h writing when using SKIP_VERSION=yes (#10972)
* Allow for certain code in the codebase assuming length of string. (#10974)
* Add AT90USB support for serial.c (#10706)
* Auto shift: support repeats and early registration (#9826)
* Rename ledmatrix.h to match .c file (#7949)
* Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231)
* Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840)
* Merge point for 2020 Nov 28 Breaking Change
Diffstat (limited to 'quantum/encoder.c')
-rw-r--r-- | quantum/encoder.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/quantum/encoder.c b/quantum/encoder.c index 81ec1bb37..7ca31afed 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c | |||
@@ -23,7 +23,7 @@ | |||
23 | // for memcpy | 23 | // for memcpy |
24 | #include <string.h> | 24 | #include <string.h> |
25 | 25 | ||
26 | #ifndef ENCODER_RESOLUTION | 26 | #if !defined(ENCODER_RESOLUTIONS) && !defined(ENCODER_RESOLUTION) |
27 | # define ENCODER_RESOLUTION 4 | 27 | # define ENCODER_RESOLUTION 4 |
28 | #endif | 28 | #endif |
29 | 29 | ||
@@ -34,6 +34,9 @@ | |||
34 | #define NUMBER_OF_ENCODERS (sizeof(encoders_pad_a) / sizeof(pin_t)) | 34 | #define NUMBER_OF_ENCODERS (sizeof(encoders_pad_a) / sizeof(pin_t)) |
35 | static pin_t encoders_pad_a[] = ENCODERS_PAD_A; | 35 | static pin_t encoders_pad_a[] = ENCODERS_PAD_A; |
36 | static pin_t encoders_pad_b[] = ENCODERS_PAD_B; | 36 | static pin_t encoders_pad_b[] = ENCODERS_PAD_B; |
37 | #ifdef ENCODER_RESOLUTIONS | ||
38 | static uint8_t encoder_resolutions[] = ENCODER_RESOLUTIONS; | ||
39 | #endif | ||
37 | 40 | ||
38 | #ifndef ENCODER_DIRECTION_FLIP | 41 | #ifndef ENCODER_DIRECTION_FLIP |
39 | # define ENCODER_CLOCKWISE true | 42 | # define ENCODER_CLOCKWISE true |
@@ -65,9 +68,15 @@ void encoder_init(void) { | |||
65 | if (!isLeftHand) { | 68 | if (!isLeftHand) { |
66 | const pin_t encoders_pad_a_right[] = ENCODERS_PAD_A_RIGHT; | 69 | const pin_t encoders_pad_a_right[] = ENCODERS_PAD_A_RIGHT; |
67 | const pin_t encoders_pad_b_right[] = ENCODERS_PAD_B_RIGHT; | 70 | const pin_t encoders_pad_b_right[] = ENCODERS_PAD_B_RIGHT; |
71 | # if defined(ENCODER_RESOLUTIONS_RIGHT) | ||
72 | const uint8_t encoder_resolutions_right[] = ENCODER_RESOLUTIONS_RIGHT; | ||
73 | # endif | ||
68 | for (uint8_t i = 0; i < NUMBER_OF_ENCODERS; i++) { | 74 | for (uint8_t i = 0; i < NUMBER_OF_ENCODERS; i++) { |
69 | encoders_pad_a[i] = encoders_pad_a_right[i]; | 75 | encoders_pad_a[i] = encoders_pad_a_right[i]; |
70 | encoders_pad_b[i] = encoders_pad_b_right[i]; | 76 | encoders_pad_b[i] = encoders_pad_b_right[i]; |
77 | # if defined(ENCODER_RESOLUTIONS_RIGHT) | ||
78 | encoder_resolutions[i] = encoder_resolutions_right[i]; | ||
79 | # endif | ||
71 | } | 80 | } |
72 | } | 81 | } |
73 | #endif | 82 | #endif |
@@ -87,19 +96,26 @@ void encoder_init(void) { | |||
87 | 96 | ||
88 | static void encoder_update(int8_t index, uint8_t state) { | 97 | static void encoder_update(int8_t index, uint8_t state) { |
89 | uint8_t i = index; | 98 | uint8_t i = index; |
99 | |||
100 | #ifdef ENCODER_RESOLUTIONS | ||
101 | int8_t resolution = encoder_resolutions[i]; | ||
102 | #else | ||
103 | int8_t resolution = ENCODER_RESOLUTION; | ||
104 | #endif | ||
105 | |||
90 | #ifdef SPLIT_KEYBOARD | 106 | #ifdef SPLIT_KEYBOARD |
91 | index += thisHand; | 107 | index += thisHand; |
92 | #endif | 108 | #endif |
93 | encoder_pulses[i] += encoder_LUT[state & 0xF]; | 109 | encoder_pulses[i] += encoder_LUT[state & 0xF]; |
94 | if (encoder_pulses[i] >= ENCODER_RESOLUTION) { | 110 | if (encoder_pulses[i] >= resolution) { |
95 | encoder_value[index]++; | 111 | encoder_value[index]++; |
96 | encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE); | 112 | encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE); |
97 | } | 113 | } |
98 | if (encoder_pulses[i] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise | 114 | if (encoder_pulses[i] <= -resolution) { // direction is arbitrary here, but this clockwise |
99 | encoder_value[index]--; | 115 | encoder_value[index]--; |
100 | encoder_update_kb(index, ENCODER_CLOCKWISE); | 116 | encoder_update_kb(index, ENCODER_CLOCKWISE); |
101 | } | 117 | } |
102 | encoder_pulses[i] %= ENCODER_RESOLUTION; | 118 | encoder_pulses[i] %= resolution; |
103 | } | 119 | } |
104 | 120 | ||
105 | void encoder_read(void) { | 121 | void encoder_read(void) { |