Refactor to per-encoder timers with opaque handle API#8
Refactor to per-encoder timers with opaque handle API#8UncleRus merged 6 commits intoesp-idf-lib:mainfrom
Conversation
196e246 to
fd16746
Compare
|
Please don't forget to increment the component version in the |
fd16746 to
220bbdd
Compare
|
Also, given the amount of work, it would be nice to include your name in the list of authors in the header and source files. |
Done. I mistakenly assumed the prior bump to 2.0.0 hadn't been published yet. |
The component is automatically published when a release is made. Regarding version increment: If the changes are internal and do not affect the component's interface, then the least significant number in the version is incremented (e.g., 3.0.0 -> 3.0.1, etc.). If the changes are relatively significant but compatibility with the previous version is not broken, the middle number is incremented and the least significant number is reset (e.g., 2.1.15 -> 2.2.0, etc.). Changes that break compatibility always require incrementing the major version number and resetting the others (e.g., 2.3.4 -> 3.0.0). In this case, given the break in compatibility, version 3.0.0 is quite appropriate. |
96bdbb6 to
670a015
Compare
Replace the shared timer/mutex/global-array design with per-encoder esp_timers, eliminating all global state. Adopt the standard ESP-IDF handle pattern: rotary_encoder_create() heap-allocates an opaque handle, rotary_encoder_delete() stops the timer and frees it.
Move the polling interval from a global Kconfig-only setting to a per-encoder config field (polling_interval_us), defaulting to CONFIG_RE_INTERVAL_US.
Allow disabling internal pull-up/pull-down resistors on encoder GPIO pins for hardware setups that use external pull resistors. Defaults to true for backward compatibility. Closes esp-idf-lib#4
Rename acceleration_min/max_cutoff_ms to acceleration_threshold_ms and acceleration_cap_ms. The old names were confusing because min/max referred to the acceleration level, not the time value - so min_cutoff was the larger number (200ms) and max_cutoff the smaller (4ms).
670a015 to
0cde496
Compare
The timer callback and public API methods (enable/disable acceleration, delete) access shared state. This change adds a FreeRTOS mutex to protect against torn reads of the 64-bit last_time field on 32-bit platforms and use-after-free when deleting an encoder while its timer callback is in-flight.
0cde496 to
0630710
Compare
Summary
esp_timerinstances, eliminating all global staterotary_encoder_create()heap-allocates a handle,rotary_encoder_delete()stops the timer and frees itrotary_encoder_init()andCONFIG_RE_MAXpolling_interval_usconfig field, defaulting toCONFIG_RE_INTERVAL_USenable_internal_pullupconfig option for hardware setups using external pull resistors (closes Enable/Disable built-in pull-up resistors (Encoder) #4)acceleration_min/max_cutoff_mstoacceleration_threshold_msandacceleration_cap_msfor clarityCloses #7
Closes #4