Class ToggleBinding

java.lang.Object
com.cdarobotics.cdalib.bindings.Binding
com.cdarobotics.cdalib.bindings.ToggleBinding

public class ToggleBinding extends Binding
A Binding that flips its state on each rising edge of the underlying condition. The raw condition is treated as a "button": every time it transitions from false to true, the toggle inverts. getStatus() returns the latched toggle state, not the raw button.

Because edge detection is stateful, getStatus() should be polled exactly once per loop.

  • Constructor Details

    • ToggleBinding

      public ToggleBinding(BooleanSupplier condition, String id)
      Parameters:
      condition - the momentary "button" condition whose rising edges flip the toggle
      id - the unique name used to register and look up this binding
  • Method Details

    • getStatus

      public boolean getStatus()
      Overrides:
      getStatus in class Binding
      Returns:
      the current value of this binding's condition.