tools – Timing and Datalogging

Common tools for timing and datalogging.

tools.print(*value, sep=' ', end='\n', file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, flush=False)

Print values on the terminal or a stream.

Example:

# Print some text
print("Hello, world")

# Print some text and a number
print("Value:", 5)
tools.wait(time)

Pause the user program for a specified amount of time.

Parameters

time (time: ms) – How long to wait.

class tools.StopWatch

A stopwatch to measure time intervals. Similar to the stopwatch feature on your phone.

time()

Get the current time of the stopwatch.

Returns

Elapsed time.

Return type

time: ms

pause()

Pause the stopwatch.

resume()

Resume the stopwatch.

reset()

Reset the stopwatch time to 0.

The run state is unaffected:

  • If it was paused, it stays paused (but now at 0).

  • If it was running, it stays running (but starting again from 0).