UncleRus / esp-idf-lib

Component library for ESP32-xx and ESP8266
https://esp-idf-lib.readthedocs.io/en/latest/
1.39k stars 431 forks source link

Improve Rotary Encoder #631

Closed NemesisXB closed 4 months ago

NemesisXB commented 4 months ago

Improve rotary "tick". Misses less ticks.

Add Acceleration for rotary encoder with the following functions to enable or disable acceleration. The larger the Coefficient, the faster the acceleration.

esp_err_t rotary_encoder_enable_acceleration(rotary_encoder_t *re, uint16_t coeff)

esp_err_t rotary_encoder_disable_acceleration(rotary_encoder_t *re)

Added 2 configurable time variables to Kconfig:

    config RE_ACCELERATION_MIN_CUTOFF
        int "Minimum Acceleration cutoff time (ms)"
        default 200
        help
            At this time in milliseconds between rotary ticks we want to be at the minimum acceleration

    config RE_ACCELERATION_MAX_CUTOFF
        int "Maximum Acceleration cutoff time (ms)"
        default 4
        help
            At this time in milliseconds between rotary ticks we want to be at the maximum acceleration

to determine at what time interval between "ticks" we are accelerating at the fastest and at which the slowest. In between the value is interpolated.

UncleRus commented 4 months ago

Great addition! Thank you!