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 "ErrorBase.h"
16 #include "SmartDashboard/SendableBase.h"
17 
18 namespace frc {
19 
20 class AnalogInput;
21 
22 class AnalogTrigger : public ErrorBase, public SendableBase {
23  friend class AnalogTriggerOutput;
24 
25  public:
32  explicit AnalogTrigger(int channel);
33 
42  explicit AnalogTrigger(AnalogInput* channel);
43 
44  ~AnalogTrigger() override;
45 
54  void SetLimitsVoltage(double lower, double upper);
55 
65  void SetLimitsRaw(int lower, int upper);
66 
76  void SetAveraged(bool useAveragedValue);
77 
88  void SetFiltered(bool useFilteredValue);
89 
97  int GetIndex() const;
98 
106  bool GetInWindow();
107 
118  bool GetTriggerState();
119 
129  std::shared_ptr<AnalogTriggerOutput> CreateOutput(
130  AnalogTriggerType type) const;
131 
132  void InitSendable(SendableBuilder& builder) override;
133 
134  private:
135  int m_index;
136  HAL_AnalogTriggerHandle m_trigger;
137  AnalogInput* m_analogInput = nullptr;
138  bool m_ownsAnalog = false;
139 };
140 
141 } // namespace frc
void SetLimitsVoltage(double lower, double upper)
Set the upper and lower limits of the analog trigger.
Definition: AnalogTrigger.cpp:51
Definition: Utility.cpp:119
void SetAveraged(bool useAveragedValue)
Configure the analog trigger to use the averaged vs.
Definition: AnalogTrigger.cpp:65
bool GetInWindow()
Return the InWindow output of the analog trigger.
Definition: AnalogTrigger.cpp:84
void SetLimitsRaw(int lower, int upper)
Set the upper and lower limits of the analog trigger.
Definition: AnalogTrigger.cpp:58
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:92
Base class for most objects.
Definition: ErrorBase.h:74
Definition: SendableBase.h:19
Definition: AnalogTrigger.h:22
void SetFiltered(bool useFilteredValue)
Configure the analog trigger to use a filtered value.
Definition: AnalogTrigger.cpp:72
std::shared_ptr< AnalogTriggerOutput > CreateOutput(AnalogTriggerType type) const
Creates an AnalogTriggerOutput object.
Definition: AnalogTrigger.cpp:100
Definition: SendableBuilder.h:23
AnalogTrigger(int channel)
Constructor for an analog trigger given a channel number.
Definition: AnalogTrigger.cpp:19
Analog input class.
Definition: AnalogInput.h:32
int GetIndex() const
Return the index of the analog trigger.
Definition: AnalogTrigger.cpp:79
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
Definition: AnalogTrigger.cpp:107