Interruptor de límite#
Introducción#
The limit class is used to detect when the Limit Switch is pressed and released.
Constructor de clases#
limit(
triport::port &port);
Instructor de clase#
Destroys the limit object and releases associated resources.
virtual ~limit();
Parámetros#
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The 3-Wire Port that the Limit Switch is connected to, written as |
Ejemplo#
// Create a limit instance in Port A
limit LimitSwitchA = limit(Brain.ThreeWirePort.A);
Funciones de los miembros#
The limit class includes the following member functions:
pressing— Returns a Boolean indicating whether the Limit Switch is being pressed.pressed— Registers a function to be called when the Limit Switch is pressed.released— Registers a function to be called when the Limit Switch is released.
Before calling any limit member functions, a limit instance must be created, as shown below:
/* This constructor is required when using VS Code.
Limit Switch configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */
// Create a limit instance in Port A
limit LimitSwitchA = limit(Brain.ThreeWirePort.A);
pressing#
Devuelve un valor si el interruptor de límite está presionado.
Available Functionsint32_t pressing();
Esta función no acepta ningún parámetro.
Return ValuesReturns an int32_t indicating whether the Limit Switch is being pressed.
1— The Limit Switch is being pressed.0— The Limit Switch is not being pressed.
pressed#
Registra una función que se llamará cuando se presione el interruptor de límite.
Available Functionsvoid pressed(
void (* callback)(void) );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
Un puntero a una función que se llamará cuando se presione el interruptor de límite. La función no debe recibir parámetros y no debe devolver ningún valor. |
Esta función no devuelve ningún valor.
Examplesvoid switchPressed() {
// The Brain will print that the Limit Switch was pressed
// on the Brain's screen.
Brain.Screen.print("switch pressed");
}
// Run switchPressed when the Limit Switch is pressed.
LimitSwitchA.pressed(switchPressed);
released#
Registra una función que se llamará cuando se suelte el interruptor de límite.
Available Functionsvoid released(
void (* callback)(void) );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
Un puntero a una función que se llamará cuando se suelte el interruptor de límite. La función no debe recibir parámetros y no debe devolver ningún valor. |
Esta función no devuelve ningún valor.
Examplesvoid switchReleased() {
Brain.Screen.print("switch released");
}
// Run switchReleased when the Limit Switch is released.
LimitSwitchA.released(switchReleased);