按钮#
IQ(第一代)大脑可以通过三个按钮访问三个对象:
buttonCheck
buttonUp
buttonDown
按下()#
The pressed(callback)
method registers a function to be called when a button is pressed.
参数 |
描述 |
---|---|
打回来 |
按下按钮时调用的函数。 |
**返回:**无。
// Create a new function buttonPressed().
void button_pressed() {
Brain.Screen.print("button pressed");
}
int main() {
// When the Brain's Up button is pressed, run the
// button_pressed function.
Brain.buttonUp.pressed(buttonPressed);
}
发布()#
The released(callback)
method registers a function to be called when a button is released.
参数 |
描述 |
---|---|
打回来 |
释放按钮时调用的函数。 |
**返回:**无。
// Create a new function buttonReleased().
void button_pressed() {
Brain.Screen.print("button released");
}
int main() {
// When the Brain's Up button is released, run the
// button_pressed function.
Brain.buttonUp.released(buttonReleased);
}
紧迫()#
The pressing()
method returns whether a button is currently being pressed.
Returns: true
if the button is being pressed. false
if it is not.