Skip to content

[Feature] add long press callback interval#65

Open
wdllmh wants to merge 3 commits into0x1abin:masterfrom
wdllmh:feature/long-press-interval
Open

[Feature] add long press callback interval#65
wdllmh wants to merge 3 commits into0x1abin:masterfrom
wdllmh:feature/long-press-interval

Conversation

@wdllmh
Copy link
Copy Markdown

@wdllmh wdllmh commented Apr 16, 2026

Summary

  1. Adds macro LONG_CALLBACK_TICKS, provide an interval between two callback function BTN_LONG_PRESS_HOLD called.
  2. Updates test case 12 to cover and verify this new feature.
  3. Fixes an inaccuracy state machine diagram in both README.md.

Changes

Feature

  • Long press state contains idle -> press -> long-press-hold -> idle, so reset of handle->tick won't interfere with other state.
  • Uses conditional compilation macro to provide optional use

Tests

  • make sure state machine has entered BTN_STATE_LONG_HOLD before manually setting ticks near UINT16_MAX

Testing

  • make test passes
  • make all compiles without warnings
  • Tested on hardware (if applicable): implemented on STM32F103C8T6, using long press to change lamp brightness continuously. Use this interval to match button tick and lamp tick.
  • Flash usage increase by 40 Byte after setting LONG_CALLBACK_TICKS larger than 1

P.S. This is my first PR. I'm very excited to contribute! Any feedback or suggestions for improvement are greatly appreciated.

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