WPILibC++  2018.4.1-20180927001728-1207-gd5d744a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
ADXL362.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2018 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 "frc/ErrorBase.h"
11 #include "frc/SPI.h"
12 #include "frc/interfaces/Accelerometer.h"
13 #include "frc/smartdashboard/SendableBase.h"
14 
15 namespace frc {
16 
22 class ADXL362 : public ErrorBase, public SendableBase, public Accelerometer {
23  public:
24  enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
25  struct AllAxes {
26  double XAxis;
27  double YAxis;
28  double ZAxis;
29  };
30 
31  public:
37  explicit ADXL362(Range range = kRange_2G);
38 
45  explicit ADXL362(SPI::Port port, Range range = kRange_2G);
46 
47  virtual ~ADXL362() = default;
48 
49  ADXL362(ADXL362&&) = default;
50  ADXL362& operator=(ADXL362&&) = default;
51 
52  // Accelerometer interface
53  void SetRange(Range range) override;
54  double GetX() override;
55  double GetY() override;
56  double GetZ() override;
57 
64  virtual double GetAcceleration(Axes axis);
65 
72  virtual AllAxes GetAccelerations();
73 
74  void InitSendable(SendableBuilder& builder) override;
75 
76  private:
77  SPI m_spi;
78  double m_gsPerLSB = 0.001;
79 };
80 
81 } // namespace frc
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
ADXL362(Range range=kRange_2G)
Constructor.
virtual double GetAcceleration(Axes axis)
Get the acceleration of one axis in Gs.
double GetY() override
Common interface for getting the y axis acceleration.
SPI bus interface class.
Definition: SPI.h:31
ADXL362 SPI Accelerometer.
Definition: ADXL362.h:22
double GetX() override
Common interface for getting the x axis acceleration.
Definition: ADXL362.h:25
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
Base class for most objects.
Definition: ErrorBase.h:74
double GetZ() override
Common interface for getting the z axis acceleration.
Definition: SendableBase.h:19
Definition: SendableBuilder.h:23
Interface for 3-axis accelerometers.
Definition: Accelerometer.h:15
void SetRange(Range range) override
Common interface for setting the measuring range of an accelerometer.