WPILibC++  2020.2.2-33-g65eab93
AnalogPotentiometer.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-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 <memory>
11 
12 #include "frc/AnalogInput.h"
13 #include "frc/ErrorBase.h"
14 #include "frc/interfaces/Potentiometer.h"
15 #include "frc/smartdashboard/Sendable.h"
16 #include "frc/smartdashboard/SendableHelper.h"
17 
18 namespace frc {
19 
20 class SendableBuilder;
21 
29  public Potentiometer,
30  public Sendable,
31  public SendableHelper<AnalogPotentiometer> {
32  public:
52  explicit AnalogPotentiometer(int channel, double fullRange = 1.0,
53  double offset = 0.0);
54 
74  explicit AnalogPotentiometer(AnalogInput* input, double fullRange = 1.0,
75  double offset = 0.0);
76 
96  explicit AnalogPotentiometer(std::shared_ptr<AnalogInput> input,
97  double fullRange = 1.0, double offset = 0.0);
98 
99  ~AnalogPotentiometer() override = default;
100 
102  AnalogPotentiometer& operator=(AnalogPotentiometer&&) = default;
103 
110  double Get() const override;
111 
117  double PIDGet() override;
118 
119  void InitSendable(SendableBuilder& builder) override;
120 
121  private:
122  std::shared_ptr<AnalogInput> m_analog_input;
123  double m_fullRange, m_offset;
124 };
125 
126 } // namespace frc
frc::AnalogPotentiometer::PIDGet
double PIDGet() override
Implement the PIDSource interface.
frc::AnalogPotentiometer::AnalogPotentiometer
AnalogPotentiometer(int channel, double fullRange=1.0, double offset=0.0)
Construct an Analog Potentiometer object from a channel number.
frc::AnalogPotentiometer
Class for reading analog potentiometers.
Definition: AnalogPotentiometer.h:28
frc::Potentiometer
Interface for potentiometers.
Definition: Potentiometer.h:17
frc::AnalogPotentiometer::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
frc::ErrorBase
Base class for most objects.
Definition: ErrorBase.h:104
frc::Sendable
Interface for Sendable objects.
Definition: Sendable.h:17
frc::AnalogInput
Analog input class.
Definition: AnalogInput.h:37
frc
WPILib FRC namespace.
Definition: AnalogOutSim.h:16
frc::AnalogPotentiometer::Get
double Get() const override
Get the current reading of the potentiomer.
frc::SendableHelper
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
frc::SendableBuilder
Definition: SendableBuilder.h:23