Skip to content

Add ESP-IDF 5 pulse_cnt driver support#127

Open
rvbc1 wants to merge 2 commits into
madhephaestus:masterfrom
rvbc1:master
Open

Add ESP-IDF 5 pulse_cnt driver support#127
rvbc1 wants to merge 2 commits into
madhephaestus:masterfrom
rvbc1:master

Conversation

@rvbc1
Copy link
Copy Markdown

@rvbc1 rvbc1 commented May 26, 2026

Summary

This PR adds support for the new ESP-IDF 5 pulse counter driver API.

For ESP-IDF 5 and newer, ESP32Encoder now uses driver/pulse_cnt.h instead of the deprecated legacy driver/pcnt.h. The existing legacy implementation is kept for older ESP-IDF versions.

This addresses the deprecated PCNT driver warning reported in #117 without suppressing the warning.

Changes

  • Add conditional PCNT driver selection based on ESP-IDF version.
  • Use driver/pulse_cnt.h for ESP-IDF >= 5.
  • Keep driver/pcnt.h for older ESP-IDF versions.
  • Reimplement attach/detach/count/filter logic for the new PCNT API.
  • Use PCNT watch points and accum_count for count accumulation.
  • Preserve the existing public API.

Testing

  • Compiled successfully with ESP-IDF 5.5 / Arduino ESP32 3.x based PlatformIO environment.
  • Verified downstream firmware build using ESP32-S3.
  • Tested encoder behavior locally on hardware.

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

Successfully merging this pull request may close these issues.

1 participant