Package com.pocolifo.robobase.control
Class Toggleable
java.lang.Object
com.pocolifo.robobase.control.Toggleable
-
Constructor Summary
ConstructorsConstructorDescriptionToggleable
(BoolSupplier currentState) Creates aToggleable
.Toggleable
(BoolSupplier currentState, boolean initialState) Creates aToggleable
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
get()
Get the current toggled state.onToggleOff
(Runnable runnable) Run code when thisToggleable
is toggled OFF.onToggleOn
(Runnable runnable) Run code when thisToggleable
is toggled ON.Updates this Toggleable.
-
Constructor Details
-
Toggleable
Creates aToggleable
.- Parameters:
currentState
- A method to get the current state of something (like whether a gamepad button is pressed)
-
Toggleable
Creates aToggleable
.- Parameters:
currentState
- A method to get the current state of something (like whether a gamepad button is pressed)
-
-
Method Details
-
get
public boolean get()Get the current toggled state.- Returns:
- The toggled state of this
Toggleable
-
processUpdates
Updates this Toggleable. Should be called ONCE as frequent as possible or in the main loop!- Returns:
- This
Toggleable
instance.
-
onToggleOn
Run code when thisToggleable
is toggled ON.- Parameters:
runnable
- ARunnable
that is executed when this toggleable is toggled ON.- Returns:
- This
Toggleable
instance.
-
onToggleOff
Run code when thisToggleable
is toggled OFF.- Parameters:
runnable
- ARunnable
that is executed when this toggleable is toggled OFF.- Returns:
- This
Toggleable
instance.
-