Skip to content

fix: reliable flash detection at threshold frequencies#1

Merged
OMARVII merged 1 commit intomainfrom
fix/flash-counting-off-by-one
Apr 9, 2026
Merged

fix: reliable flash detection at threshold frequencies#1
OMARVII merged 1 commit intomainfrom
fix/flash-counting-off-by-one

Conversation

@OMARVII
Copy link
Copy Markdown
Owner

@OMARVII OMARVII commented Apr 9, 2026

Summary

  • Bug: Maximum (and other) sensitivity modes failed to detect flashes at exact threshold frequencies (~40% miss rate). Reported during manual testing — max mode didn't catch obvious flashes.
  • Root cause: The 1-second sliding analysis window was too tight. At boundary-aligned flash cycles (e.g. 3Hz at medium, 1Hz at maximum), the final direction change fell just outside the window.
  • Fix: Extended WINDOW_DURATION_MS from 1000ms to 1067ms (one extra frame interval). This guarantees the window captures all transitions at every advertised threshold. No fps increase needed — 15fps is sufficient by Nyquist theorem.
  • Added 5 new/updated tests including a realistic 15fps simulation suite that exercises the exact scenario that was broken.

Test plan

  • npm test — 70/70 pass (was 65 before, 5 new/updated)
  • npm run lint — 0 errors
  • Verified 100% detection reliability at all threshold Hz via simulation (1Hz/max, 2Hz/high, 3Hz/medium, 5Hz/low)
  • Verified no false positives below threshold (2Hz does NOT trigger medium)

🤖 Generated with Claude Code

…requencies

The 1-second sliding window missed boundary transitions ~40% of the time
at exact threshold Hz values (e.g. 3Hz at medium, 1Hz at maximum).
Extending by one frame interval (67ms) guarantees full coverage.
@OMARVII OMARVII changed the title Fix flash detection missing flashes at threshold frequencies fix: reliable flash detection at threshold frequencies Apr 9, 2026
@OMARVII OMARVII merged commit 4d9be01 into main Apr 9, 2026
2 checks passed
@OMARVII OMARVII mentioned this pull request Apr 9, 2026
1 task
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