Package edu.wpi.first.wpilibj.event
Class BooleanEvent
java.lang.Object
edu.wpi.first.wpilibj.event.BooleanEvent
- All Implemented Interfaces:
- BooleanSupplier
- Direct Known Subclasses:
- NetworkBooleanEvent
This class provides an easy way to link actions to active high logic signals. Each object
 represents a digital signal to which callback actions can be bound using 
ifHigh(Runnable).
 BooleanEvents can easily be composed for advanced functionality using and(BooleanSupplier), or(BooleanSupplier), and negate().
 
To get a new BooleanEvent that triggers when this one changes see falling() and
 rising().
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionBooleanEvent(EventLoop loop, BooleanSupplier signal) Creates a new event that is active when the condition is true.
- 
Method SummaryModifier and TypeMethodDescriptionand(BooleanSupplier other) Composes this event with another event, returning a new event that is active when both events are active.<T extends BooleanSupplier>
 TcastTo(BiFunction<EventLoop, BooleanSupplier, T> ctor) A method to "downcast" a BooleanEvent instance to a subclass (for example, to a command-based version of this class).debounce(double seconds) Creates a new debounced event from this event - it will become active when this event has been active for longer than the specified period.debounce(double seconds, Debouncer.DebounceType type) Creates a new debounced event from this event - it will become active when this event has been active for longer than the specified period.falling()Creates a new event that triggers when this one changes from true to false.final booleanReturns the state of this signal (high or low) as of the last loop poll.final voidBind an action to this event.negate()Creates a new event that is active when this event is inactive.or(BooleanSupplier other) Composes this event with another event, returning a new event that is active when either event is active.rising()Creates a new event that triggers when this one changes from false to true.
- 
Field Details- 
m_loopPoller loop.
 
- 
- 
Constructor Details- 
BooleanEventCreates a new event that is active when the condition is true.- Parameters:
- loop- the loop that polls this event.
- signal- the digital signal represented by this object.
 
 
- 
- 
Method Details- 
getAsBooleanReturns the state of this signal (high or low) as of the last loop poll.- Specified by:
- getAsBooleanin interface- BooleanSupplier
- Returns:
- true for the high state, false for the low state. If the event was never polled, it returns the state at event construction.
 
- 
ifHighBind an action to this event.- Parameters:
- action- the action to run if this event is active.
 
- 
castToA method to "downcast" a BooleanEvent instance to a subclass (for example, to a command-based version of this class).- Type Parameters:
- T- the subclass type
- Parameters:
- ctor- a method reference to the constructor of the subclass that accepts the loop as the first parameter and the condition/signal as the second.
- Returns:
- an instance of the subclass.
 
- 
negateCreates a new event that is active when this event is inactive.- Returns:
- the new event.
 
- 
andComposes this event with another event, returning a new event that is active when both events are active.The events must use the same event loop. If the events use different event loops, the composed signal won't update until both loops are polled. - Parameters:
- other- the event to compose with.
- Returns:
- the new event.
 
- 
orComposes this event with another event, returning a new event that is active when either event is active.The events must use the same event loop. If the events use different event loops, the composed signal won't update until both loops are polled. - Parameters:
- other- the event to compose with.
- Returns:
- the new event.
 
- 
risingCreates a new event that triggers when this one changes from false to true.- Returns:
- the new event.
 
- 
fallingCreates a new event that triggers when this one changes from true to false.- Returns:
- the event.
 
- 
debounceCreates a new debounced event from this event - it will become active when this event has been active for longer than the specified period.- Parameters:
- seconds- The debounce period.
- Returns:
- The debounced event (rising edges debounced only).
 
- 
debounceCreates a new debounced event from this event - it will become active when this event has been active for longer than the specified period.- Parameters:
- seconds- The debounce period.
- type- The debounce type.
- Returns:
- The debounced event.
 
 
-