EnhancedBooleanSupplier is a Feature that updates once / loop and tracks some additional data about a boolean that is frequently needed in FTC.

Constructing:

EnhancedBooleanSupplier enhancedBooleanSupplier = new EnhancedBooleanSupplier(() -> true);
// or, apply debounce at construction
new EnhancedBooleanSupplier(() -> true, 0.02, 0.02);

State:

// current state
enhancedBooleanSupplier.state();
// rising edge
enhancedBooleanSupplier.onTrue();
// falling edge
enhancedBooleanSupplier.onFalse();
// toggle that changes on rising edge
enhancedBooleanSupplier.toggleTrue();
// toggle that changes on falling edge
enhancedBooleanSupplier.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.

// debounce both edges
enhancedBooleanSupplier.debounce(0.02);
// debounce both edges rising, then falling
enhancedBooleanSupplier.debounce(0, 0.02);
enhancedBooleanSupplier.debounceRisingEdge(0);
enhancedBooleanSupplier.debounceFallingEdge(0.02);

Combining:

enhancedBooleanSupplier.and(() -> false);
enhancedBooleanSupplier.or(() -> false);
enhancedBooleanSupplier.xor(() -> false);
enhancedBooleanSupplier.not();

Both debouncings and combinations return new EnhancedBooleanSuppliers, rather than mutating the existing one.

Manual update management:

// you can enable / disable the feature based auto updates
enhancedBooleanSupplier.getAutoUpdates();
enhancedBooleanSupplier.setAutoUpdates(false);

// you can invalidate the current update to get a new update next time you get state
enhancedBooleanSupplier.invalidate();