-
Notifications
You must be signed in to change notification settings - Fork 0
Wait
The Wait class provides you with two useful methods for flow control:
-
Wait.waitForSeconds(double seconds)
-
Wait.waitFor(WaitCondition condition)
The waitForSeconds() method is pretty straightforward - You supply it with a double representing the seconds it should wait, and it... waits.
Example:
Wait.waitForSeconds(3.2);These functions do not integrate with FLL-leJOS' run interruptions, so you might get stuck in a blocking call and not be able to stop your robot during a match.
The waitFor() method is an extremely powerful tool. Using waitFor you can safely wait for any boolean condition without worrying about getting stuck in a blocking call.
Wait.waitFor(() -> {
<write a Java method here. This method must return a boolean condition.>
});
Example:
Wait.waitFor(() -> {
return Button.getButtons() == Button.ID_ENTER;
});The example above uses a combination of FLL-leJOS' wait function and vanilla leJOS' Button class to wait until the center button on the EV3 is pressed.
- Overview
- Code Documentation
- Writing our first run
- Setting Up
- Defining hardware
- Writing a basic Motor Control run
- [Adding sensors and waits]
- [Defining Runs]
- Writing our second run
- [Using the chassis]
- [Finishing up]
- [Line follower code example]