WPILibC++  2019.1.1-beta-2-2-gf54c0f7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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 "frc/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 
36  Trigger(Trigger&&) = default;
37  Trigger& operator=(Trigger&&) = default;
38 
39  bool Grab();
40  virtual bool Get() = 0;
41  void WhenActive(Command* command);
42  void WhileActive(Command* command);
43  void WhenInactive(Command* command);
44  void CancelWhenActive(Command* command);
45  void ToggleWhenActive(Command* command);
46 
47  void InitSendable(SendableBuilder& builder) override;
48 
49  private:
50  std::atomic_bool m_sendablePressed{false};
51 };
52 
53 } // namespace frc
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: SendableBase.h:19
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
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