WPILibC++  2020.3.2
AnalogTrigger.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2020 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 "frc/AnalogTriggerOutput.h"
15 #include "frc/ErrorBase.h"
16 #include "frc/smartdashboard/Sendable.h"
17 #include "frc/smartdashboard/SendableHelper.h"
18 
19 namespace frc {
20 
21 class AnalogInput;
22 class DutyCycle;
23 class SendableBuilder;
24 
25 class AnalogTrigger : public ErrorBase,
26  public Sendable,
27  public SendableHelper<AnalogTrigger> {
28  friend class AnalogTriggerOutput;
29 
30  public:
37  explicit AnalogTrigger(int channel);
38 
47  explicit AnalogTrigger(AnalogInput* channel);
48 
54  explicit AnalogTrigger(DutyCycle* dutyCycle);
55 
56  ~AnalogTrigger() override;
57 
59  AnalogTrigger& operator=(AnalogTrigger&& rhs);
60 
69  void SetLimitsVoltage(double lower, double upper);
70 
79  void SetLimitsDutyCycle(double lower, double upper);
80 
90  void SetLimitsRaw(int lower, int upper);
91 
101  void SetAveraged(bool useAveragedValue);
102 
113  void SetFiltered(bool useFilteredValue);
114 
122  int GetIndex() const;
123 
131  bool GetInWindow();
132 
143  bool GetTriggerState();
144 
154  std::shared_ptr<AnalogTriggerOutput> CreateOutput(
155  AnalogTriggerType type) const;
156 
157  void InitSendable(SendableBuilder& builder) override;
158 
159  private:
160  hal::Handle<HAL_AnalogTriggerHandle> m_trigger;
161  AnalogInput* m_analogInput = nullptr;
162  DutyCycle* m_dutyCycle = nullptr;
163  bool m_ownsAnalog = false;
164 };
165 
166 } // namespace frc
frc::AnalogTrigger::GetTriggerState
bool GetTriggerState()
Return the TriggerState output of the analog trigger.
frc::AnalogTriggerOutput
Class to represent a specific output from an analog trigger.
Definition: AnalogTriggerOutput.h:49
frc::AnalogTrigger::SetLimitsRaw
void SetLimitsRaw(int lower, int upper)
Set the upper and lower limits of the analog trigger.
frc::AnalogTrigger::GetInWindow
bool GetInWindow()
Return the InWindow output of the analog trigger.
frc::AnalogTrigger
Definition: AnalogTrigger.h:25
frc::AnalogTrigger::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
frc::AnalogTrigger::CreateOutput
std::shared_ptr< AnalogTriggerOutput > CreateOutput(AnalogTriggerType type) const
Creates an AnalogTriggerOutput object.
frc::DutyCycle
Class to read a duty cycle PWM input.
Definition: DutyCycle.h:35
frc::AnalogTrigger::SetLimitsDutyCycle
void SetLimitsDutyCycle(double lower, double upper)
Set the upper and lower duty cycle limits of the analog trigger.
frc::ErrorBase
Base class for most objects.
Definition: ErrorBase.h:104
frc::AnalogTrigger::GetIndex
int GetIndex() const
Return the index of the analog trigger.
frc::Sendable
Interface for Sendable objects.
Definition: Sendable.h:17
frc::AnalogInput
Analog input class.
Definition: AnalogInput.h:37
frc
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
frc::AnalogTrigger::SetFiltered
void SetFiltered(bool useFilteredValue)
Configure the analog trigger to use a filtered value.
frc::AnalogTrigger::SetLimitsVoltage
void SetLimitsVoltage(double lower, double upper)
Set the upper and lower limits of the analog trigger.
frc::AnalogTrigger::SetAveraged
void SetAveraged(bool useAveragedValue)
Configure the analog trigger to use the averaged vs.
frc::SendableHelper
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
frc::SendableBuilder
Definition: SendableBuilder.h:23
frc::AnalogTrigger::AnalogTrigger
AnalogTrigger(int channel)
Constructor for an analog trigger given a channel number.