BooleanEvent
- class wpilib.event.BooleanEvent(loop: wpilib.event._event.EventLoop, signal: Callable[[], bool])
Bases:
pybind11_objectThis 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().BooleanEvents can easily be composed for advanced functionality using {@link #operator&&}, {@link #operator||}, and {@link #operator!}.
To get a new BooleanEvent that triggers when this one changes see {@link #Falling()} and
Rising().Creates 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.
- castTo(ctor: Callable) object
A method to “downcast” a BooleanEvent instance to a subclass (for example, to a command-based version of this class).
- 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.
- debounce(debounceTime: wpimath.units.seconds, type: wpimath.filter._filter.Debouncer.DebounceType = <DebounceType.kRising: 0>) wpilib.event._event.BooleanEvent
Creates a new debounced event from this event - it will become active when this event has been active for longer than the specified period.
- Parameters:
debounceTime – The debounce period.
type – The debounce type.
- Returns:
The debounced event.
- falling() wpilib.event._event.BooleanEvent
Creates a new event that triggers when this one changes from true to false.
- Returns:
the event.
- getAsBoolean() bool
Returns the state of this signal (high or low) as of the last loop poll.
- Returns:
true for the high state, false for the low state. If the event was never polled, it returns the state at event construction.
- ifHigh(action: Callable[[], None]) None
Bind an action to this event.
- Parameters:
action – the action to run if this event is active.
- rising() wpilib.event._event.BooleanEvent
Creates a new event that triggers when this one changes from false to true.
- Returns:
the new event.