WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
AnalogPotentiometer.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2016. 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 #include <string>
12 
13 #include "AnalogInput.h"
14 #include "LiveWindow/LiveWindowSendable.h"
15 #include "interfaces/Potentiometer.h"
16 
17 namespace frc {
18 
26  public:
45  explicit AnalogPotentiometer(int channel, double fullRange = 1.0,
46  double offset = 0.0);
47 
48  explicit AnalogPotentiometer(AnalogInput* input, double fullRange = 1.0,
49  double offset = 0.0);
50 
51  explicit AnalogPotentiometer(std::shared_ptr<AnalogInput> input,
52  double fullRange = 1.0, double offset = 0.0);
53 
54  virtual ~AnalogPotentiometer() = default;
55 
61  double Get() const override;
62 
68  double PIDGet() override;
69 
70  /*
71  * Live Window code, only does anything if live window is activated.
72  */
73  std::string GetSmartDashboardType() const override;
74  void InitTable(std::shared_ptr<ITable> subtable) override;
75  void UpdateTable() override;
76  std::shared_ptr<ITable> GetTable() const override;
77 
82  void StartLiveWindowMode() override {}
83 
88  void StopLiveWindowMode() override {}
89 
90  private:
91  std::shared_ptr<AnalogInput> m_analog_input;
92  double m_fullRange, m_offset;
93  std::shared_ptr<ITable> m_table;
94 };
95 
96 } // namespace frc
AnalogPotentiometer(int channel, double fullRange=1.0, double offset=0.0)
AnalogPotentiometer constructor.
Definition: AnalogPotentiometer.cpp:24
void StopLiveWindowMode() override
AnalogPotentiometers don't have to do anything special when exiting the LiveWindow.
Definition: AnalogPotentiometer.h:88
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
double PIDGet() override
Implement the PIDSource interface.
Definition: AnalogPotentiometer.cpp:77
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: AnalogPotentiometer.cpp:94
double Get() const override
Get the current reading of the potentiomer.
Definition: AnalogPotentiometer.cpp:66
std::shared_ptr< ITable > GetTable() const override
Definition: AnalogPotentiometer.cpp:100
Class for reading analog potentiometers.
Definition: AnalogPotentiometer.h:25
Interface for potentiometers.
Definition: Potentiometer.h:17
Analog input class.
Definition: AnalogInput.h:32
void InitTable(std::shared_ptr< ITable > subtable) override
Live Window code, only does anything if live window is activated.
Definition: AnalogPotentiometer.cpp:89
std::string GetSmartDashboardType() const override
Definition: AnalogPotentiometer.cpp:82
void StartLiveWindowMode() override
AnalogPotentiometers don't have to do anything special when entering the LiveWindow.
Definition: AnalogPotentiometer.h:82