yea, this is used when polling the button, it returns a boolean indicating if the button is currently pressed or not.
Controller1.ButtonA.pressing()
These are used when you want your code to be event based.
Controller.ButtonA.pressed( callback_pressed );
Controller.ButtonA.released( callback_released );
A callback used an an event is running in its own thread, that means you can block using time consuming code or a while loop if you really want to, for example, this code
using namespace vex;
controller p = controller( controllerType::primary );
void b1() {
Brain.Screen.setPenColor( vex::color::green );
while( p.ButtonL1.pressing() ) {
Brain.Screen.printAt( 200, 180, "L1 pressed");
vex::this_thread::sleep_for(100);
}
Brain.Screen.printAt( 200, 180, " ");
return;
}
int main() {
int count = 0;
p.ButtonL1.pressed( b1 );
while(1) {
Brain.Screen.printAt( 10, 50, "Hello %d", count++ );
// Allow other tasks to run
this_thread::sleep_for(10);
}
}
Will call the function “b1” when the L1 button is pressed and stay in that function until it is released.