Skip to content
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

Add new function for encode module #16954

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions quantum/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ extern volatile bool isLeftHand;

static pin_t encoders_pad_a[NUM_ENCODERS_MAX_PER_SIDE] = ENCODERS_PAD_A;
static pin_t encoders_pad_b[NUM_ENCODERS_MAX_PER_SIDE] = ENCODERS_PAD_B;
static bool encoder_external_update[NUM_ENCODERS] = {false};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is set-only and never consulted.
As far as I can tell the issue raised by @FWest98 has not been addressed as a result, suggest revisiting this before it goes stale again.


#ifdef ENCODER_RESOLUTIONS
static uint8_t encoder_resolutions[NUM_ENCODERS] = ENCODER_RESOLUTIONS;
Expand Down Expand Up @@ -225,6 +226,7 @@ bool encoder_read(void) {
encoder_state[i] <<= 2;
encoder_state[i] |= new_status;
changed |= encoder_update(i, encoder_state[i]);
encoder_external_update[i] = false;
}
}
return changed;
Expand Down Expand Up @@ -268,3 +270,12 @@ void encoder_update_raw(uint8_t *slave_state) {
if (changed) last_encoder_activity_trigger();
}
#endif

drashna marked this conversation as resolved.
Show resolved Hide resolved
void encoder_insert_state(void) {
for (uint8_t i = 0; i < thisCount; i++) {
encoder_state[i] <<= 2;
encoder_state[i] |= (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
encoder_pulses[i] += encoder_LUT[encoder_state[i] & 0xF];
encoder_external_update[i] = true;
}
}
1 change: 1 addition & 0 deletions quantum/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ bool encoder_read(void);

bool encoder_update_kb(uint8_t index, bool clockwise);
bool encoder_update_user(uint8_t index, bool clockwise);
void encoder_insert_state(void);

#ifdef SPLIT_KEYBOARD

Expand Down