WPILibC++  unspecified
Trigger.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2011-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <atomic>
11 
12 #include "SmartDashboard/SendableBase.h"
13 
14 namespace frc {
15 
16 class Command;
17 
31 class Trigger : public SendableBase {
32  public:
33  Trigger() = default;
34  ~Trigger() override = default;
35  bool Grab();
36  virtual bool Get() = 0;
37  void WhenActive(Command* command);
38  void WhileActive(Command* command);
39  void WhenInactive(Command* command);
40  void CancelWhenActive(Command* command);
41  void ToggleWhenActive(Command* command);
42 
43  void InitSendable(SendableBuilder& builder) override;
44 
45  private:
46  std::atomic_bool m_sendablePressed{false};
47 };
48 
49 } // namespace frc
Definition: RobotController.cpp:14
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
Definition: Trigger.cpp:45
Definition: SendableBase.h:19
Definition: SendableBuilder.h:23
The Command class is at the very core of the entire command framework.
Definition: Command.h:48
This class provides an easy way to link commands to inputs.
Definition: Trigger.h:31