-
-
Notifications
You must be signed in to change notification settings - Fork 42.4k
Asymmetric encoders, encoder tests. #16068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6a6d5e2 to
9b039d1
Compare
d1618fd to
d804133
Compare
|
FYI: Last September, I experimented with encoder_read() by rewriting it as follows. As a result, the estimated execution time of encoder_read() in normal time went from 18 microseconds to 2 microseconds. bool encoder_read(void) {
bool changed = false;
for (uint8_t i = 0; i < NUMBER_OF_ENCODERS; i++) {
uint8_t new_status = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
if ((encoder_state[i]&0x3) != new_status) {
encoder_state[i] <<= 2;
encoder_state[i] |= new_status;
changed |= encoder_update(i, encoder_state[i]);
}
}
return changed;
} |
|
@mtei great, thanks, added to the PR. |
Correction. There are some regressions here. It reintroduces the "trigger encoder on startup" issue, again. |
You probably have to wait for the input signal to stabilize after the pull-up resistor is enabled. diff --git a/quantum/encoder.c b/quantum/encoder.c
index 2f37bee6d9..83758a8cbd 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -121,7 +121,9 @@ void encoder_init(void) {
for (uint8_t i = 0; i < thisCount; i++) {
setPinInputHigh(encoders_pad_a[i]);
setPinInputHigh(encoders_pad_b[i]);
-
+ }
+ wait_ms(1); // After the pull-up resistor is enabled, wait for the input signal to stabilize.
+ for (uint8_t i = 0; i < thisCount; i++) {
encoder_state[i] = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
}
}EDIT: I posted new PR #16372 |
|
Can confirm that fixes the issue I was seeing with this. |
f36a583 to
b5acb20
Compare
b5acb20 to
e9b9e71
Compare
…Asymmetric encoders, encoder tests. (qmk#16068) is applied.)
…Asymmetric encoders, encoder tests. (qmk#16068) is applied.)
Description
Previous asymmetric encoders PR was broken, and was rolled back shortly after merge.
In addition, encoders had tests, but weren't hooked up.
This PR attempts to address both situations -- enabling the existing test runs showed that encoder tests were broken, so I figured it was best to actually fix up encoder sizing assumptions at the same time.
Modifications
keymap.hhas new defines to allow shorthand for encoder counts, as well as per-sideENCODER_RESOLUTIONS_RIGHTalready documented but there were places where keyboards were usingENCODER_RESOLUTIONSandENCODER_RESOLUTIONS_RIGHTincorrectly together (or not at all).ENCODER_RESOLUTIONSis used for both left and right ifENCODER_RESOLUTIONS_RIGHTis unspecified, matchingENCODERS_PAD_A.Types of Changes
Checklist