Minutero#
Introducción#
El temporizador de VEX V5 le permite controlar el tiempo transcurrido y realizar acciones según intervalos de tiempo. Con diversos métodos de gestión del tiempo, puede crear operaciones precisas y sincronizadas dentro de su programa.
This page uses timer as the example Timer name. Replace it with your own configured name as needed.
A continuación se muestra una lista de todos los métodos:
Métodos – Controlar e interactuar con el temporizador del cerebro.
clear– Resets the timer to zero.time– Returns the elapsed time since the project started.event– Calls a function after a specified number of milliseconds, with optional arguments.
Constructor – Crea temporizadores adicionales.
Timer– Creates an additional timer.
claro#
clear sets the timer to zero.
Usage:
timer.clear()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Reset the timer when the Bumper Switch is pressed
while True:
print("\033[2J")
print(timer.time(SECONDS))
wait(50, MSEC)
if bumper_switch.pressing():
timer.clear()
tiempo#
time returns the current elapsed time of the timer in the specified units — an integer for MSEC or a float for SECONDS.
Usage:
timer.time(units)
Parámetros |
Descripción |
|---|---|
|
Optional. The unit to represent the time:
|
# Display the time until the Bumper Switch is pressed
while True:
print("\033[2J")
print(timer.time(SECONDS))
wait(50, MSEC)
if bumper_switch.pressing():
timer.clear()
evento#
event calls a function after a specified amount of time.
Usage:
timer.event(callback, delay, arg)
Parámetros |
Descripción |
|---|---|
|
Una función previamente definida que se ejecuta después de la cantidad de tiempo especificada. |
|
El retraso antes de que se llame a la función, en milisegundos. |
|
Opcional. Una tupla que contiene los argumentos que se pasan 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():
drivetrain.drive_for(FORWARD, 200, MM)
# Drive forward after a 5000 millisecond delay
timer.event(timer_event, 5000)
Constructores#
Timer#
Timer creates a new timer. A Timer object will immediately begin counting the moment it is created and will work with all timer methods.
Usage:
Timer
Parámetros |
Descripción |
|---|---|
Este constructor no tiene parámetros. |
# Create a Timer
timer = Timer()