Minutero#

Introducción#

El temporizador de VEX EXP permite controlar el tiempo transcurrido y realizar acciones en función de intervalos de tiempo. Se puede usar para medir la duración de una tarea o para reiniciarla y realizar nuevas operaciones de temporización.

This page uses brain.timer as Brain Timer. You can also construct a Timer object to create a new timer and 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 how much time has passed.

  • event – Registers a function to be called after a specified number of milliseconds.

Constructor – Crea temporizadores adicionales.

  • Timer – Creates an additional timer.

claro#

clear sets the timer to zero. This can be used to time additional sections of code within the same project.

Usage:
brain.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(brain.timer.time(SECONDS))
    wait(50, MSEC)
    if bumper_switch.pressing():
        brain.timer.clear()

tiempo#

time returns the time since the timer was last reset as a decimal. The timer is automatically reset at the start of a project.

Usage:
brain.timer.time(units)

Parámetros

Descripción

units

The unit that represents the time: MSEC (default) – milliseconds, or SECONDS

# Display the time until the Bumper Switch is pressed
while True:
    print("\033[2J")
    print(brain.timer.time(SECONDS))
    wait(50, MSEC)
    if bumper_switch.pressing():
        brain.timer.clear()

evento#

event calls a function after a specified amount of time passes.

Usage:
brain.timer.event(callback, delay, arg)

Parámetros

Descripción

callback

Una función que se ejecutará cuando ocurra el evento del temporizador.

delay

El tiempo de espera antes de que se llame a la función, en milisegundos.

arg

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():
    drivetrain.drive_for(FORWARD, 200, MM)

# Drive forward after a 5000 millisecond delay
brain.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()