Skip to content

Conversation

@alrapal
Copy link
Owner

@alrapal alrapal commented Jul 13, 2025

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

  • Embedded Hal Based Driver for a HY040 encoder
  • Provide Direction
    • Clockwise
    • CounterClockwise
    • Rest
  • Unit test to test the logic using Mocked pins

This works best when polling via a time based interrupt every 5ms. However, the precision seem to be not the greatest (when reading the atomic, the value is often increased by 2 instead of one). Tried a variant with interrupt which led to the same result. Different things can be tested once modules that are supposed to interpret the rotation are defined and implemented, but this allows to move forward for now.

Fixes #13

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Unit test for logic
  • Tested using the main, timer interrupt based polling with 5ms to control the radius of the circle on the screen.

Test Configuration:

  • Firmware version: 0.1.0
  • Hardware: esp32s3
  • Toolchain: esp / stable
  • SDK: embedded_hal, esp_hal

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Template from Embedded Artistry

---
- Embedded Hal Based Driver for a HY040 encoder
- Provide Direction
  - Clockwise
  - CounterClockwise
  - Rest
- Unit test to test the logic using Mocked pins

This works best when polling via a time based interrupt every 5ms.
However, the precision seem to be not the greatest (when reading the atomic, the value is often increased by 2 instead of one).
Tried a variant with interrupt which led to the same result.
Different things can be tested once modules that are supposed to
interpret the rotation are defined and implemented, but this allows to
move forward for now.

related to #13
@alrapal alrapal self-assigned this Jul 13, 2025
@alrapal alrapal added the enhancement New feature or request label Jul 13, 2025
@alrapal alrapal added this to the Rotary Encoder milestone Jul 13, 2025
@alrapal alrapal merged commit 2e4a266 into main Jul 13, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ DRIVER ] - Hy-040 driver

1 participant