Minutero#

Introducción#

El temporizador de VEX GO 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.

A continuación se muestra una lista de todos los métodos:

Métodos – Controlar e interactuar con el temporizador del cerebro.

  • reset – 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.

reiniciar#

restablecer establece el temporizador a cero.

Uso:
timer.reset()

Parámetros

Descripción

Este método no tiene parámetros.

# Build Used: Super Code Base 2.0
def main():
    # Reset the timer when the bumper is pressed
    while True:
        console.clear()
        console.print(timer.time(SECONDS))
        wait(50, MSEC)
        if bumper.is_pressed():
            timer.reset()

# Start threads — Do not delete
start_thread(main)

tiempo#

tiempo devuelve el tiempo transcurrido actual del temporizador en las unidades especificadas: un entero para MSEC o un flotante para SEGUNDOS.

Uso:
timer.time(unidades)

Parámetros

Descripción

unidades

Las unidades de tiempo son milisegundos MSEC (predeterminado) o SEGUNDOS.

# Build Used: Super Code Base 2.0
def main():
    # Display the time until the bumper is pressed
    while True:
        console.clear()
        console.print(timer.time(SECONDS))
        wait(50, MSEC)
        if bumper.is_pressed():
            timer.reset()

# Start threads — Do not delete
start_thread(main)

evento#

evento llama a una función después de una cantidad de tiempo especificada.

Uso:
timer.event(callback, delay)

Parámetros

Descripción

devolución de llamada

Una función a ejecutar cuando ocurre el evento del temporizador.

retraso

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

# Build Used: Super Code Base 2.0
def timer_event():
    drivetrain.drive_for(FORWARD, 200, MM)

def main():
    # Drive forward after a 5000 millisecond delay
    timer.event(timer_event, 5000)

# Start threads — Do not delete
start_thread(main)

Constructores#

Timer#

temporizador crea un nuevo temporizador. El objeto del temporizador comenzará a contar inmediatamente en el momento de su creación y funcionará con los métodos

Uso:
my_timer = Timer()

Parámetros

Descripción

Este constructor no tiene parámetros.

def main():
    # Display the time of two timers
    wait(2, SECONDS)
    timer_1 = Timer()
    while True:
        console.clear()
        console.print("Timer: ", timer.time(SECONDS))
        console.new_line()
        console.print("timer_1: ", timer_1.time(SECONDS))
        wait(15, MSEC)

# Start threads — Do not delete
start_thread(main)