BooleanEvent

class wpilib.event.BooleanEvent(loop: wpilib.event._event.EventLoop, condition: Callable[[], bool])

Bases: pybind11_object

This class provides an easy way to link actions to inputs. Each object represents a boolean condition to which callback actions can be bound using IfHigh().

These events can easily be composed using factories such as {@link #operator!}, operator, operator etc.

To get an event that activates only when this one changes, see {@link #Falling()} and Rising().

Creates a new event with the given condition determining whether it is active.

Parameters:
  • loop – the loop that polls this event

  • condition – returns whether or not the event should be active

castTo(arg0: function) 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: 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

Get a new event that triggers only when this one newly changes to false.

Returns:

a new event representing when this one newly changes to false.

getAsBoolean() bool

Check whether this event is active or not.

Returns:

true if active.

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

Get a new event that events only when this one newly changes to true.

Returns:

a new event representing when this one newly changes to true.