48 operator std::function<bool()>();
55 void IfHigh(std::function<
void()> action);
68 [](
EventLoop* loop, std::function<
bool()> condition) {
69 return T(loop, condition);
71 return ctor(m_loop, [state = m_state] {
return *state; });
133 std::function<bool()> m_signal;
134 std::shared_ptr<bool> m_state;
This class provides an easy way to link actions to active high logic signals.
Definition BooleanEvent.h:30
BooleanEvent(EventLoop *loop, std::function< bool()> signal)
Creates a new event that is active when the condition is true.
BooleanEvent Falling()
Creates a new event that triggers when this one changes from true to false.
bool GetAsBoolean() const
Returns the state of this signal (high or low) as of the last loop poll.
BooleanEvent operator!()
Creates a new event that is active when this event is inactive.
BooleanEvent operator&&(std::function< bool()> rhs)
Composes this event with another event, returning a new event that is active when both events are act...
BooleanEvent Debounce(units::second_t debounceTime, frc::Debouncer::DebounceType type=frc::Debouncer::DebounceType::kRising)
Creates a new debounced event from this event - it will become active when this event has been active...
void IfHigh(std::function< void()> action)
Bind an action to this event.
T CastTo(std::function< T(EventLoop *, std::function< bool()>)> ctor=[](EventLoop *loop, std::function< bool()> condition) { return T(loop, condition);})
A method to "downcast" a BooleanEvent instance to a subclass (for example, to a command-based version...
Definition BooleanEvent.h:67
BooleanEvent Rising()
Creates a new event that triggers when this one changes from false to true.
BooleanEvent operator||(std::function< bool()> rhs)
Composes this event with another event, returning a new event that is active when either event is act...
DebounceType
Type of debouncing to perform.
Definition Debouncer.h:23
@ kRising
Rising edge.
Definition Debouncer.h:25
A declarative way to bind a set of actions to a loop and execute them when the loop is polled.
Definition EventLoop.h:15