WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
ADXL362.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-2017. 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 "LiveWindow/LiveWindowSendable.h"
14 #include "SPI.h"
15 #include "SensorBase.h"
16 #include "interfaces/Accelerometer.h"
17 
18 namespace frc {
19 
20 class DigitalInput;
21 class DigitalOutput;
22 
28 class ADXL362 : public Accelerometer, public LiveWindowSendable {
29  public:
30  enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
31  struct AllAxes {
32  double XAxis;
33  double YAxis;
34  double ZAxis;
35  };
36 
37  public:
38  explicit ADXL362(Range range = kRange_2G);
39  explicit ADXL362(SPI::Port port, Range range = kRange_2G);
40  virtual ~ADXL362() = default;
41 
42  ADXL362(const ADXL362&) = delete;
43  ADXL362& operator=(const ADXL362&) = delete;
44 
45  // Accelerometer interface
46  void SetRange(Range range) override;
47  double GetX() override;
48  double GetY() override;
49  double GetZ() override;
50 
51  virtual double GetAcceleration(Axes axis);
52  virtual AllAxes GetAccelerations();
53 
54  std::string GetSmartDashboardType() const override;
55  void InitTable(std::shared_ptr<ITable> subtable) override;
56  void UpdateTable() override;
57  std::shared_ptr<ITable> GetTable() const override;
58  void StartLiveWindowMode() override {}
59  void StopLiveWindowMode() override {}
60 
61  private:
62  SPI m_spi;
63  double m_gsPerLSB = 0.001;
64 
65  std::shared_ptr<ITable> m_table;
66 };
67 
68 } // namespace frc
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
Definition: ADXL362.cpp:138
void InitTable(std::shared_ptr< ITable > subtable) override
Initializes a table for this sendable object.
Definition: ADXL362.cpp:169
double GetY() override
Common interface for getting the y axis acceleration.
Definition: ADXL362.cpp:108
std::shared_ptr< ITable > GetTable() const override
Definition: ADXL362.cpp:182
std::string GetSmartDashboardType() const override
Definition: ADXL362.cpp:165
SPI bus interface class.
Definition: SPI.h:24
ADXL362 SPI Accelerometer.
Definition: ADXL362.h:28
Definition: ADXL362.h:31
void SetRange(Range range) override
Common interface for setting the measuring range of an accelerometer.
Definition: ADXL362.cpp:80
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: ADXL362.h:59
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: ADXL362.h:58
Class to write to digital outputs.
Definition: DigitalOutput.h:26
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: ADXL362.cpp:174
Interface for 3-axis accelerometers.
Definition: Accelerometer.h:15
Class to read a digital input.
Definition: DigitalInput.h:30
double GetX() override
Common interface for getting the x axis acceleration.
Definition: ADXL362.cpp:106
double GetZ() override
Common interface for getting the z axis acceleration.
Definition: ADXL362.cpp:110
ADXL362(Range range=kRange_2G)
Constructor.
Definition: ADXL362.cpp:40
virtual double GetAcceleration(Axes axis)
Get the acceleration of one axis in Gs.
Definition: ADXL362.cpp:118