Trigger

class Trigger

This class allows for easy triggering of Commands based on boolean inputs

Public Functions

inline Trigger(std::function<bool()> condition, EventLoop *event_loop)

Create a Trigger with a specified condition and EventLoop.

Parameters:
  • condition – The condition for the Trigger

  • event_loop – The EventLoop for the condition to run on

inline explicit Trigger(std::function<bool()> condition)

Create a Trigger with a specified condition and the default CommandSchedulerEventLoop.

Parameters:

condition – The condition for the Trigger

inline Trigger *onChange(Command *command)

Binds a function to the EventLoop checks the condition to see if it has changed. Upon change the Command is scheduled.

Parameters:

command – The command to run when the condition changes

Returns:

Trigger to allow for easy method chaining

inline Trigger *onTrue(Command *command)

Binds a function to the EventLoop checks the condition to see if it has changed from false to true. Upon change the Command is scheduled.

Parameters:

command – The command to run when the condition changes from false to true

Returns:

Trigger to allow for easy method chaining

inline Trigger *onFalse(Command *command)

Binds a function to the EventLoop checks the condition to see if it has changed from true to false. Upon change the Command is scheduled.

Parameters:

command – The command to run when the condition changes from true to false

Returns:

Trigger to allow for easy method chaining

inline Trigger *whileTrue(Command *command)

Binds a function to the EventLoop checks the condition to see if it has changed from false to true. Upon change the Command is scheduled. When the Trigger detects the condition has changed from true to false, the Command is cancelled. It is not rescheduled when the command finishes (If this behavior is desired use a RepeatCommand)

Parameters:

command – The command to run when the condition is true

Returns:

Trigger to allow for easy method chaining

inline Trigger *whileFalse(Command *command)

Binds a function to the EventLoop checks the condition to see if it has changed from true to false. Upon change the Command is scheduled. When the Trigger detects the condition has changed from false to true, the Command is cancelled. It is not rescheduled when the command finishes (If this behavior is desired use a RepeatCommand)

Parameters:

command – The command to run when the condition is false

Returns:

Trigger to allow for easy method chaining

inline Trigger *toggleOnTrue(Command *command)

Binds a function to the EventLoop checks the condition to see if it has changed from false to true. Upon change the Command is scheduled if it is not already scheduled, and cancelled otherwise.

Parameters:

command – The command to toggle when the condition changes to true

Returns:

Trigger to allow for easy method chaining

inline Trigger *toggleOnFalse(Command *command)

Binds a function to the EventLoop checks the condition to see if it has changed from true to false. Upon change the Command is scheduled if it is not already scheduled, and cancelled otherwise.

Parameters:

command – The command to toggle when the condition changes to false

Returns:

Trigger to allow for easy method chaining