Timer refactor: stopwatch-like semantics, mcrfpy.timers collection closes #173

Major Timer API improvements:
- Add `stopped` flag to Timer C++ class for proper state management
- Add `start()` method to restart stopped timers (preserves callback)
- Add `stop()` method that removes from engine but preserves callback
- Make `active` property read-write (True=start/resume, False=pause)
- Add `start=True` init parameter to create timers in stopped state
- Add `mcrfpy.timers` module-level collection (tuple of active timers)
- One-shot timers now set stopped=true instead of clearing callback
- Remove deprecated `setTimer()` and `delTimer()` module functions

Timer callbacks now receive (timer, runtime) instead of just (runtime).
Updated all tests to use new Timer API and callback signature.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-01-03 19:21:37 -05:00
commit 5d41292bf6
16 changed files with 440 additions and 262 deletions

View file

@ -153,7 +153,7 @@ def test_enter_exit_simulation():
automation.moveTo(50, 50)
# Give time for callbacks to execute
def check_results(runtime):
def check_results(timer, runtime):
global enter_count, exit_count
if enter_count >= 1 and exit_count >= 1:
@ -166,7 +166,7 @@ def test_enter_exit_simulation():
print("\n=== Basic Mouse Enter/Exit tests passed! ===")
sys.exit(0)
mcrfpy.setTimer("check", check_results, 200)
mcrfpy.Timer("check", check_results, 200, once=True)
def run_basic_tests():