Skip to content

feat: decouple long-click retrigger interval from initial threshold#91

Merged
LennartHennigs merged 1 commit intomasterfrom
feat/longclick-retrigger-interval
Mar 23, 2026
Merged

feat: decouple long-click retrigger interval from initial threshold#91
LennartHennigs merged 1 commit intomasterfrom
feat/longclick-retrigger-interval

Conversation

@LennartHennigs
Copy link
Owner

Summary

Closes #86, closes #90 — takes the API style of #86 (interval bundled into the retriggerable setter) with the cleaner implementation approach of #90 (sentinel value instead of extra bool flag).

  • New overload: setLongClickDetectedRetriggerable(bool retriggerable, unsigned int retrigger_ms) — sets a custom retrigger cadence independent of the initial threshold
  • New getter: getLongClickInterval() — alongside the other timing getters
  • The bool-only overload delegates to the two-arg overload (resets interval to 0), keeping one source of truth
  • _checkForLongClick: first fire at longclick_time_ms; subsequent fires every retrigger_ms (falls back to longclick_time_ms when not set → fully backward compatible)
  • reset() now clears longclick_retriggerable and longclick_interval_ms
  • New example: LongpressRetriggerInterval showing setLongClickTime(3000) + setLongClickDetectedRetriggerable(true, 500)

Usage

button.setLongClickTime(3000);                        // first fire after 3 s
button.setLongClickDetectedRetriggerable(true, 500);  // then every 500 ms

Test plan

  • pio test -e epoxy-esp8266 — all 13 callback tests pass (3 new), all 10 config tests pass (3 new)
  • pio test -e epoxy-esp32 — same
  • pio test -e epoxy-nano — same
  • New long_click_detected_custom_interval test verifies ≥3 fires with 100 ms retrigger interval
  • New getLongClickInterval tests verify getter, setter, and reset-by-bool-overload behaviour

🤖 Generated with Claude Code

Decouples the initial long-press threshold from the continuous retrigger
interval, taking the API style of PR #86 with the cleaner implementation
approach of PR #90.

- New overload: setLongClickDetectedRetriggerable(bool, unsigned int retrigger_ms)
- New getter: getLongClickInterval()
- bool-only overload delegates to the two-arg overload (resets interval to 0)
- _checkForLongClick: first fire at longclick_time_ms, subsequent fires
  every retrigger_ms (falls back to longclick_time_ms if not set, preserving
  backward compatibility)
- reset() now clears longclick_retriggerable and longclick_interval_ms
- New example: LongpressRetriggerInterval
- New tests: getLongClickInterval getter, retrigger timing with custom interval
- test_helpers: pressAndHold() helper extracted; click() delegates to it

Closes #86, Closes #90

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link

@michpro michpro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@LennartHennigs LennartHennigs merged commit 58bb249 into master Mar 23, 2026
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.

2 participants