Botón#
El cerebro IQ (2.ª generación) tiene acceso a tres objetos para sus tres botones:
botónCheck
botónIzquierda
botónDerecha
apretado()#
El método pressed(callback)
registra una función que se llamará cuando se presione un botón.
Parámetros |
Descripción |
---|---|
llamar de vuelta |
Una función que se llamará cuando se presione el botón. |
Devoluciones: Ninguna.
// Create a new function buttonPressed().
void button_pressed() {
Brain.Screen.print("button pressed");
}
int main() {
// When the Brain's Left button is pressed, run the
// button_pressed function.
Brain.buttonLeft.pressed(buttonPressed);
}
liberado()#
El método released(callback)
registra una función que se llamará cuando se suelte un botón.
Parámetros |
Descripción |
---|---|
llamar de vuelta |
Una función que se llamará cuando se suelte el botón. |
Devoluciones: Ninguna.
// Create a new function buttonReleased().
void button_pressed() {
Brain.Screen.print("button released");
}
int main() {
// When the Brain's Left button is released, run the
// button_pressed function.
Brain.buttonLeft.released(buttonReleased);
}
prensado()#
El método pressing()
devuelve si un botón está siendo presionado actualmente.
Devuelve: true
si se está presionando el botón. false
si no lo está.