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