Minutero#
Introducción#
El temporizador de VEX CTE permite controlar el tiempo transcurrido y realizar acciones en función de intervalos de tiempo. Gracias a diversos métodos de gestión del tiempo, puedes crear operaciones precisas y programadas dentro de tu programa.
Note: The Timer is only available when a Brain has been constructed with brain = Brain(), as all Timer functionality is driven through methods on the Brain instance.
This page uses brain as the example Brain name. Replace it with your own configured name as needed.
A continuación se muestra una lista de todos los métodos:
timer_reset– Resets the timer to zero.timer_time– Returns the elapsed time since the project started.timer_event– Calls a function after a specified number of milliseconds, with optional arguments.
reinicio del temporizador#
clear sets the timer to zero.
Usage:
brain.timer_reset()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Display the time until the move is completed
arm.move_to(-100, 200, 100, False)
while True:
print("\033[2J")
print(brain.timer_time(SECONDS))
wait(50, MSEC)
if arm.is_done():
brain.timer_reset()
tiempo_temporizador#
timer_time returns the current elapsed time of the timer in the specified units — an integer for MSEC or a float for SECONDS.
Usage:
brain.timer_time(units)
Parámetros |
Descripción |
|---|---|
|
Optional. The unit to represent the time:
|
# Display the time until the move is completed
arm.move_to(-100, 200, 100, False)
while True:
print("\033[2J")
print(brain.timer_time(SECONDS))
wait(50, MSEC)
if arm.is_done():
brain.timer_reset()
evento_temporizador#
timer_event calls a function after a specified amount of time.
Usage:
timer_event(callback, delay, arg)
Parámetros |
Descripción |
|---|---|
|
Una función definida previamente que se ejecuta después de la cantidad de tiempo especificada. |
|
El tiempo de espera antes de que se llame a la función, en milisegundos. |
|
Opcional. Una tupla que contiene los argumentos que se pasarán a la función de devolución de llamada. Consulte Uso de funciones con parámetros para obtener más información. |
def timer_event():
arm.move_inc(0, 100, 0)
# Drive forward after a 5000 millisecond delay
timer_event(timer_event, 5000)