WPILibC++  unspecified
AnalogTrigger.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-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 <memory>
11 
12 #include <HAL/Types.h>
13 
14 #include "AnalogTriggerOutput.h"
15 #include "SensorBase.h"
16 
17 namespace frc {
18 
19 class AnalogInput;
20 
21 class AnalogTrigger : public SensorBase {
22  friend class AnalogTriggerOutput;
23 
24  public:
25  explicit AnalogTrigger(int channel);
26  explicit AnalogTrigger(AnalogInput* channel);
27  ~AnalogTrigger() override;
28 
29  void SetLimitsVoltage(double lower, double upper);
30  void SetLimitsRaw(int lower, int upper);
31  void SetAveraged(bool useAveragedValue);
32  void SetFiltered(bool useFilteredValue);
33  int GetIndex() const;
34  bool GetInWindow();
35  bool GetTriggerState();
36  std::shared_ptr<AnalogTriggerOutput> CreateOutput(
37  AnalogTriggerType type) const;
38 
39  void InitSendable(SendableBuilder& builder) override;
40 
41  private:
42  int m_index;
43  HAL_AnalogTriggerHandle m_trigger;
44  AnalogInput* m_analogInput = nullptr;
45  bool m_ownsAnalog = false;
46 };
47 
48 } // namespace frc
void SetLimitsVoltage(double lower, double upper)
Set the upper and lower limits of the analog trigger.
Definition: AnalogTrigger.cpp:89
Definition: RobotController.cpp:14
Base class for all sensors.
Definition: SensorBase.h:25
void SetAveraged(bool useAveragedValue)
Configure the analog trigger to use the averaged vs.
Definition: AnalogTrigger.cpp:105
bool GetInWindow()
Return the InWindow output of the analog trigger.
Definition: AnalogTrigger.cpp:148
void SetLimitsRaw(int lower, int upper)
Set the upper and lower limits of the analog trigger.
Definition: AnalogTrigger.cpp:74
Class to represent a specific output from an analog trigger.
Definition: AnalogTriggerOutput.h:49
bool GetTriggerState()
Return the TriggerState output of the analog trigger.
Definition: AnalogTrigger.cpp:166
Definition: AnalogTrigger.h:21
void SetFiltered(bool useFilteredValue)
Configure the analog trigger to use a filtered value.
Definition: AnalogTrigger.cpp:122
std::shared_ptr< AnalogTriggerOutput > CreateOutput(AnalogTriggerType type) const
Creates an AnalogTriggerOutput object.
Definition: AnalogTrigger.cpp:183
Definition: SendableBuilder.h:23
AnalogTrigger(int channel)
Constructor for an analog trigger given a channel number.
Definition: AnalogTrigger.cpp:25
Analog input class.
Definition: AnalogInput.h:31
int GetIndex() const
Return the index of the analog trigger.
Definition: AnalogTrigger.cpp:136
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
Definition: AnalogTrigger.cpp:190