WPILibC++  unspecified
AnalogTrigger.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2017 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  virtual ~AnalogTrigger();
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  private:
40  int m_index;
41  HAL_AnalogTriggerHandle m_trigger;
42  AnalogInput* m_analogInput = nullptr;
43  bool m_ownsAnalog = false;
44 };
45 
46 } // namespace frc
void SetLimitsVoltage(double lower, double upper)
Set the upper and lower limits of the analog trigger.
Definition: AnalogTrigger.cpp:87
Definition: Timer.cpp:18
Base class for all sensors.
Definition: SensorBase.h:20
void SetAveraged(bool useAveragedValue)
Configure the analog trigger to use the averaged vs.
Definition: AnalogTrigger.cpp:103
bool GetInWindow()
Return the InWindow output of the analog trigger.
Definition: AnalogTrigger.cpp:146
void SetLimitsRaw(int lower, int upper)
Set the upper and lower limits of the analog trigger.
Definition: AnalogTrigger.cpp:72
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:164
Definition: AnalogTrigger.h:21
void SetFiltered(bool useFilteredValue)
Configure the analog trigger to use a filtered value.
Definition: AnalogTrigger.cpp:120
std::shared_ptr< AnalogTriggerOutput > CreateOutput(AnalogTriggerType type) const
Creates an AnalogTriggerOutput object.
Definition: AnalogTrigger.cpp:181
AnalogTrigger(int channel)
Constructor for an analog trigger given a channel number.
Definition: AnalogTrigger.cpp:25
Analog input class.
Definition: AnalogInput.h:36
int GetIndex() const
Return the index of the analog trigger.
Definition: AnalogTrigger.cpp:134