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

4 Rotary encoders does not work #736

Open
jeriellopez opened this issue May 22, 2024 · 1 comment
Open

4 Rotary encoders does not work #736

jeriellopez opened this issue May 22, 2024 · 1 comment

Comments

@jeriellopez
Copy link

This works:
main keyboard info.json

    "encoder": {
        "rotary": [
            { "pin_a": "GP28", "pin_b": "GP27", "resolution": 4 },
            { "pin_a": "GP22", "pin_b": "GP26", "resolution": 4 },
            { "pin_a": "GP4", "pin_b": "GP3", "resolution": 4 }
        ]
    },

keymap.c

#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
    [0] =   { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
};
#endif

This builds, but none of the rotary encoders work:

    "encoder": {
        "rotary": [
            { "pin_a": "GP28", "pin_b": "GP27", "resolution": 4 },
            { "pin_a": "GP22", "pin_b": "GP26", "resolution": 4 },
            { "pin_a": "GP4", "pin_b": "GP3", "resolution": 4 },
            { "pin_a": "GP9", "pin_b": "GP5", "resolution": 4 }
        ]
    },

keymap.c:

#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
    [0] =   { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
};
#endif

My board uses an rp2040. This old precompiled firmware works with 4 encoders: https://github.com/pabile/Pabile-Keyboards/blob/main/firmware_precompiled/vial/pabile_p20v8iii_wowenkho.uf2

@jeriellopez
Copy link
Author

Update quantum/encoder.c

bool encoder_queue_full_advanced(encoder_events_t *events) {
    // Maximum is 128 since uint8_t's max is 255.
    return events->head == ((events->tail + MAX_QUEUED_ENCODER_EVENTS - 1) % MAX_QUEUED_ENCODER_EVENTS);
    // at 4 encoders, MAX_QUEUED_ENCODER_EVENTS becomes 5. 0 - 1 is 255, and 255 % 5 is 0
    // which will evaluate to true for the code below, indicating "full", even though it is actually empty.
    // return events->head == (events->tail - 1) % MAX_QUEUED_ENCODER_EVENTS;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant