This is a simple stopwatch GUI. It uses the functions CLOCK and ETIME along with user inputs to display the elapsed time in a HH:MM:SS.SSS format.
Controls:
1) Press the START button to begin the timer (or press any key except L, R, or X)
a. If the timer has already been activated, press the PAUSE button to stop the timer (or press any key except L, R, or X)
b. If the timer has been paused, press the RESUME button to continue from the paused time (or press any key except L, R, or X)
c. If the timer is in lap mode, press the RESUME button to continue as though the lap time had not been activated (or press any key except L, R, or X)
2) Press the LAP button to view lap times (or press the L key)
a. The LAP button can be pressed successively to view mulitple laps
3) Press the RESET button to restore the timer (or press the R key)
4) Press the EXIT button to close the timer window (or press the X key)
Help notes available.
This file works great for timing myself speed solving the Rubik's Cube. :)
Notes:
1. This file has been reworked to use nested functions and a timer rather than persistent variables. This allows the user to run multiple independent instances.
2. I also included the capability to start the stopwatch with a time offset. The offset can be positive or negative. If it is negative, the stopwatch will work like a countdown (see examples).
3. It is also possible to initialize the stopwatch with a 6 element vector in CLOCK format, which will cause the stopwatch to start running as soon as it is called (see examples).
Example:
% start the stopwatch
stopwatch;
Example:
% start the stopwatch with a positive offset
stopwatch(3598.765);
Example:
% count down from one hour
stopwatch(-3600);
Example:
% start the stopwatch with time already running
stopwatch(clock);
Example:
% start the stopwatch with running time since the day began
time = clock;
time(4:6) = 0;
stopwatch(time);
Example:
% count down the time until midnight
time = clock;
time(3:6) = [time(3)+1 0 0 0];
stopwatch(time); |