meyelens.utils
- class meyelens.utils.CountdownTimer(duration: float)[source]
Bases:
objectCountdown timer based on PsychoPy’s high-precision clock.
This utility wraps
psychopy.core.Clockto provide a simple countdown interface for time-limited tasks (e.g., stimulus display windows, response deadlines, trial timeouts).- Parameters:
duration (float) – Total countdown duration in seconds.
- duration
Total countdown duration in seconds.
- Type:
float
- clock
PsychoPy clock (if available) or a perf_counter-based fallback.
- Type:
psychopy.core.Clock or _PerfCounterClock
- is_running
Truewhen the countdown is active.- Type:
bool
Notes
If the timer is not running,
get_time_left()returns 0 (matching your current behavior and avoiding exceptions).This class is intentionally minimal and does not use logging.
- start() None[source]
Start (or restart) the countdown.
Resets the internal clock and marks the timer as running.
- Return type:
None
- get_time_left() float[source]
Get the remaining time in the countdown.
- Returns:
Remaining time in seconds. If the timer is not running or the countdown has completed, returns 0.
- Return type:
float
- is_finished() bool[source]
Check whether the countdown has completed.
- Returns:
Trueif remaining time is 0, otherwiseFalse.- Return type:
bool
- stop() None[source]
Stop (pause) the countdown.
This does not reset elapsed time; it simply marks the timer as inactive. With the current design,
get_time_left()will return 0 while stopped.- Return type:
None