WPILibC++  2020.3.2
Trigger.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2011-2019 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/Sendable.h"
13 #include "frc/smartdashboard/SendableHelper.h"
14 
15 namespace frc {
16 
17 class Command;
18 
32 class Trigger : public Sendable, public SendableHelper<Trigger> {
33  public:
34  Trigger() = default;
35  ~Trigger() override = default;
36 
37  Trigger(const Trigger& rhs);
38  Trigger& operator=(const Trigger& rhs);
39  Trigger(Trigger&& rhs);
40  Trigger& operator=(Trigger&& rhs);
41 
42  bool Grab();
43  virtual bool Get() = 0;
44  void WhenActive(Command* command);
45  void WhileActive(Command* command);
46  void WhenInactive(Command* command);
47  void CancelWhenActive(Command* command);
48  void ToggleWhenActive(Command* command);
49 
50  void InitSendable(SendableBuilder& builder) override;
51 
52  private:
53  std::atomic_bool m_sendablePressed{false};
54 };
55 
56 } // namespace frc
frc::Command
The Command class is at the very core of the entire command framework.
Definition: Command.h:49
frc::Trigger
This class provides an easy way to link commands to inputs.
Definition: Trigger.h:32
frc::Trigger::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
frc::Sendable
Interface for Sendable objects.
Definition: Sendable.h:17
frc
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
frc::SendableHelper
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
frc::SendableBuilder
Definition: SendableBuilder.h:23