límite#
Inicializando la clase límite#
Un interruptor de límite se crea utilizando el siguiente constructor:
El constructor limit
crea un objeto límite en el puerto de tres cables especificado.
Parámetro |
Descripción |
---|---|
|
El puerto de 3 cables al que está conectado el interruptor de límite, ya sea un puerto en el Cerebro o un Expandedor de 3 cables. |
Primero se debe crear un Brain o un 3-Wire Expander antes de poder usarlos para crear un objeto con el constructor de clase Limit.
// Create the Brain.
brain Brain;
// Construct a Limit Switch "limit" with the Limit class.
limit Limit = limit(Brain.ThreeWirePort.A);
Este objeto “límite” se utilizará en todos los ejemplos posteriores a lo largo de esta documentación de API cuando se haga referencia a los métodos de la clase límite.
Métodos de clase#
apretado()#
El comando pressed(callback)
registra una función de devolución de llamada para cuando se presiona el interruptor de límite.
Parámetros |
Descripción |
---|---|
llamar de vuelta |
La función de devolución de llamada que se llamará cuando se presione el interruptor de límite. |
Devoluciones: Ninguna.
// Define the switchPressed function with a void return type,
// showing it doesn't return a value.
void switchPressed() {
// The Brain will print that the Limit Switch was pressed
// on the Brain's screen.
Brain.Screen.print("switch pressed");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run switchPressed when the Limit Switch is pressed.
Limit.pressed(switchPressed);
}
liberado()#
El comando released(callback)
registra una función de devolución de llamada para cuando se libera el interruptor de límite.
Parámetros |
Descripción |
---|---|
llamar de vuelta |
La función de devolución de llamada que se llamará cuando se libere el interruptor de límite. |
Devoluciones: Ninguna.
// Define the switchReleased function with a void return
// type, showing it doesn't return a value.
void switchReleased() {
// The Brain will print that the Limit Switch was released
// on the Brain's screen.
Brain.Screen.print("switch released");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run switchReleased when the Limit Switch is released.
LimitSwitchA.released(switchReleased);
}
prensado()#
El comando pressing()
verifica si el interruptor de límite está siendo presionado actualmente.
Devuelve: Un valor entero que representa el estado del interruptor de parachoques. Se devuelve un 1 si el interruptor de parachoques está presionado. Se devuelve un 0 si no lo está.