diff options
author | Takeshi ISHII <2170248+mtei@users.noreply.github.com> | 2022-02-21 23:13:06 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 23:13:06 +0900 |
commit | b1de11c27575f9956d2f7dfd6bf0240d630e3ae1 (patch) | |
tree | 0208001bd9be25d96a3db73171133a01ab269567 | |
parent | ae5f43072f0de93b65854af569ba90564b8003de (diff) | |
download | qmk_firmware-b1de11c27575f9956d2f7dfd6bf0240d630e3ae1.tar.gz qmk_firmware-b1de11c27575f9956d2f7dfd6bf0240d630e3ae1.zip |
Fix a potential bug in encoder_init(). (#16372)
After executing `setPinInputHigh(pin)`, it is necessary to wait for the charging time to read from the corresponding pin. This is the same as requiring `matrix_output_unselect_delay()` after doing `unselect_row()` in matrix.c.
-rw-r--r-- | quantum/encoder.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/quantum/encoder.c b/quantum/encoder.c index 8fb87281c..ecbc0c161 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c | |||
@@ -59,6 +59,8 @@ static uint8_t thisHand, thatHand; | |||
59 | static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0}; | 59 | static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0}; |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | __attribute__((weak)) void encoder_wait_pullup_charge(void) { wait_us(100); } | ||
63 | |||
62 | __attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; } | 64 | __attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; } |
63 | 65 | ||
64 | __attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) { return encoder_update_user(index, clockwise); } | 66 | __attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) { return encoder_update_user(index, clockwise); } |
@@ -84,7 +86,9 @@ void encoder_init(void) { | |||
84 | for (int i = 0; i < NUMBER_OF_ENCODERS; i++) { | 86 | for (int i = 0; i < NUMBER_OF_ENCODERS; i++) { |
85 | setPinInputHigh(encoders_pad_a[i]); | 87 | setPinInputHigh(encoders_pad_a[i]); |
86 | setPinInputHigh(encoders_pad_b[i]); | 88 | setPinInputHigh(encoders_pad_b[i]); |
87 | 89 | } | |
90 | encoder_wait_pullup_charge(); | ||
91 | for (int i = 0; i < NUMBER_OF_ENCODERS; i++) { | ||
88 | encoder_state[i] = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1); | 92 | encoder_state[i] = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1); |
89 | } | 93 | } |
90 | 94 | ||