WPILibC++  unspecified
ADXRS450_Gyro.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2015-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 <stdint.h>
11 
12 #include "GyroBase.h"
13 #include "SPI.h"
14 
15 namespace frc {
16 
28 class ADXRS450_Gyro : public GyroBase {
29  public:
30  ADXRS450_Gyro();
31  explicit ADXRS450_Gyro(SPI::Port port);
32  virtual ~ADXRS450_Gyro() = default;
33 
34  double GetAngle() const override;
35  double GetRate() const override;
36  void Reset() override;
37  void Calibrate() override;
38 
39  private:
40  SPI m_spi;
41 
42  uint16_t ReadRegister(int reg);
43 };
44 
45 } // namespace frc
Definition: Timer.cpp:18
SPI bus interface class.
Definition: SPI.h:28
double GetRate() const override
Return the rate of rotation of the gyro.
Definition: ADXRS450_Gyro.cpp:152
ADXRS450_Gyro()
Gyro constructor on onboard CS0.
Definition: ADXRS450_Gyro.cpp:58
double GetAngle() const override
Return the actual angle in degrees that the robot is currently facing.
Definition: ADXRS450_Gyro.cpp:141
void Reset() override
Reset the gyro.
Definition: ADXRS450_Gyro.cpp:127
GyroBase is the common base class for Gyro implementations such as AnalogGyro.
Definition: GyroBase.h:25
void Calibrate() override
Initialize the gyro.
Definition: ADXRS450_Gyro.cpp:43
Use a rate gyro to return the robots heading relative to a starting position.
Definition: ADXRS450_Gyro.h:28