EnhancedBooleanSupplier is a Feature that updates once / loop and tracks some
additional data about a boolean that is frequently needed in FTC.Constructing:
Copy
EnhancedBooleanSupplier enhancedBooleanSupplier = new EnhancedBooleanSupplier(() -> true);// or, apply debounce at constructionnew EnhancedBooleanSupplier(() -> true, 0.02, 0.02);
State:
Copy
// current stateenhancedBooleanSupplier.state();// rising edgeenhancedBooleanSupplier.onTrue();// falling edgeenhancedBooleanSupplier.onFalse();// toggle that changes on rising edgeenhancedBooleanSupplier.toggleTrue();// toggle that changes on falling edgeenhancedBooleanSupplier.toggleFalse();
Debouncing:Debounce is basically a filter. This means that a state needs to be true for
that long before it changes. I.e. with a leading debounce of 0.02 seconds, you
need to hold down the gamepad button for 0.02 seconds before it will change to
true in the code.The arguments are in seconds.
Copy
// debounce both edgesenhancedBooleanSupplier.debounce(0.02);// debounce both edges rising, then fallingenhancedBooleanSupplier.debounce(0, 0.02);enhancedBooleanSupplier.debounceRisingEdge(0);enhancedBooleanSupplier.debounceFallingEdge(0.02);
Both debouncings and combinations return new EnhancedBooleanSuppliers,
rather than mutating the existing one.Manual update management:
Copy
// you can enable / disable the feature based auto updatesenhancedBooleanSupplier.getAutoUpdates();enhancedBooleanSupplier.setAutoUpdates(false);// you can invalidate the current update to get a new update next time you get stateenhancedBooleanSupplier.invalidate();