按钮#
EXP Brain 的三个按钮可以访问三个对象:
buttonCheck
buttonLeft
buttonRight
按下()#
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 Left button is pressed, run the
// button_pressed function.
Brain.buttonLeft.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 Left button is released, run the
// button_pressed function.
Brain.buttonLeft.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.