BooleanEvent

class wpilib.BooleanEvent(loop: wpilib._wpilib.EventLoop, signal: collections.abc.Callable[[], bool])

Bases: pybind11_object

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().

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.

and_(*args, **kwargs)

Overloaded function.

  1. and_(self: wpilib._wpilib.BooleanEvent, other: wpilib._wpilib.BooleanEvent) -> wpilib._wpilib.BooleanEvent

Compose this event with another event

  1. and_(self: wpilib._wpilib.BooleanEvent, other: collections.abc.Callable[[], bool]) -> wpilib._wpilib.BooleanEvent

Compose this event with a callable

castTo(ctor: collections.abc.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._wpimath.Debouncer.DebounceType = <DebounceType.kRising: 0>) wpilib._wpilib.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._wpilib.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: collections.abc.Callable[[], None]) None

Bind an action to this event.

Parameters:

action – the action to run if this event is active.

negate() wpilib._wpilib.BooleanEvent

Returns a BooleanEvent that is active when this event is inactive.

or_(*args, **kwargs)

Overloaded function.

  1. or_(self: wpilib._wpilib.BooleanEvent, other: wpilib._wpilib.BooleanEvent) -> wpilib._wpilib.BooleanEvent

Compose this event with another event

  1. or_(self: wpilib._wpilib.BooleanEvent, other: collections.abc.Callable[[], bool]) -> wpilib._wpilib.BooleanEvent

Compose this event with a callable

rising() wpilib._wpilib.BooleanEvent

Creates a new event that triggers when this one changes from false to true.

Returns:

the new event.