WPILibC++  unspecified
AnalogPotentiometer.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-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 #include <string>
12 
13 #include "AnalogInput.h"
14 #include "LiveWindow/LiveWindowSendable.h"
15 #include "interfaces/Potentiometer.h"
16 #include "networktables/NetworkTableEntry.h"
17 
18 namespace frc {
19 
27  public:
46  explicit AnalogPotentiometer(int channel, double fullRange = 1.0,
47  double offset = 0.0);
48 
49  explicit AnalogPotentiometer(AnalogInput* input, double fullRange = 1.0,
50  double offset = 0.0);
51 
52  explicit AnalogPotentiometer(std::shared_ptr<AnalogInput> input,
53  double fullRange = 1.0, double offset = 0.0);
54 
55  virtual ~AnalogPotentiometer() = default;
56 
62  double Get() const override;
63 
69  double PIDGet() override;
70 
71  /*
72  * Live Window code, only does anything if live window is activated.
73  */
74  std::string GetSmartDashboardType() const override;
75  void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
76  void UpdateTable() 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  nt::NetworkTableEntry m_valueEntry;
94 };
95 
96 } // namespace frc
AnalogPotentiometer(int channel, double fullRange=1.0, double offset=0.0)
AnalogPotentiometer constructor.
Definition: AnalogPotentiometer.cpp:24
Definition: Timer.cpp:18
void StopLiveWindowMode() override
AnalogPotentiometers don&#39;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:99
double Get() const override
Get the current reading of the potentiomer.
Definition: AnalogPotentiometer.cpp:66
Class for reading analog potentiometers.
Definition: AnalogPotentiometer.h:26
Interface for potentiometers.
Definition: Potentiometer.h:17
NetworkTables Entry.
Definition: NetworkTableEntry.h:30
Analog input class.
Definition: AnalogInput.h:36
void InitTable(std::shared_ptr< nt::NetworkTable > 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&#39;t have to do anything special when entering the LiveWindow.
Definition: AnalogPotentiometer.h:82