WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
AnalogAccelerometer.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-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 "AnalogInput.h"
11 #include "SensorBase.h"
12 #include "PIDSource.h"
13 #include "LiveWindow/LiveWindowSendable.h"
14 
15 #include <memory>
16 
26  public PIDSource,
27  public LiveWindowSendable {
28  public:
29  explicit AnalogAccelerometer(int32_t channel);
30  explicit AnalogAccelerometer(AnalogInput *channel);
31  explicit AnalogAccelerometer(std::shared_ptr<AnalogInput> channel);
32  virtual ~AnalogAccelerometer() = default;
33 
34  float GetAcceleration() const;
35  void SetSensitivity(float sensitivity);
36  void SetZero(float zero);
37  double PIDGet() override;
38 
39  void UpdateTable() override;
40  void StartLiveWindowMode() override;
41  void StopLiveWindowMode() override;
42  std::string GetSmartDashboardType() const override;
43  void InitTable(std::shared_ptr<ITable> subTable) override;
44  std::shared_ptr<ITable> GetTable() const override;
45 
46  private:
47  void InitAccelerometer();
48 
49  std::shared_ptr<AnalogInput> m_analogInput;
50  float m_voltsPerG = 1.0;
51  float m_zeroGVoltage = 2.5;
52 
53  std::shared_ptr<ITable> m_table;
54 };
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: AnalogAccelerometer.cpp:115
void InitTable(std::shared_ptr< ITable > subTable) override
Initializes a table for this sendable object.
Definition: AnalogAccelerometer.cpp:123
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:18
Handle operation of an analog accelerometer.
Definition: AnalogAccelerometer.h:25
void SetZero(float zero)
Set the voltage that corresponds to 0 G.
Definition: AnalogAccelerometer.cpp:100
std::shared_ptr< ITable > GetTable() const override
Definition: AnalogAccelerometer.cpp:128
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: AnalogAccelerometer.cpp:117
Base class for all sensors.
Definition: SensorBase.h:20
double PIDGet() override
Get the Acceleration for the PID Source parent.
Definition: AnalogAccelerometer.cpp:107
AnalogAccelerometer(int32_t channel)
Create a new instance of an accelerometer.
Definition: AnalogAccelerometer.cpp:28
PIDSource interface is a generic sensor source for the PID class.
Definition: PIDSource.h:18
Analog input class.
Definition: AnalogInput.h:32
float GetAcceleration() const
Return the acceleration in Gs.
Definition: AnalogAccelerometer.cpp:74
std::string GetSmartDashboardType() const override
Definition: AnalogAccelerometer.cpp:119
void SetSensitivity(float sensitivity)
Set the accelerometer sensitivity.
Definition: AnalogAccelerometer.cpp:88
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: AnalogAccelerometer.cpp:109