blob: f8491eb768b8597606fdba2826ee028391516646 [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2014-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
10namespace frc {
11
12/**
13 * Interface for 3-axis accelerometers
14 */
15class Accelerometer {
16 public:
17 virtual ~Accelerometer() = default;
18
19 enum Range { kRange_2G = 0, kRange_4G = 1, kRange_8G = 2, kRange_16G = 3 };
20
21 /**
22 * Common interface for setting the measuring range of an accelerometer.
23 *
24 * @param range The maximum acceleration, positive or negative, that the
25 * accelerometer will measure. Not all accelerometers support all ranges.
26 */
27 virtual void SetRange(Range range) = 0;
28
29 /**
30 * Common interface for getting the x axis acceleration
31 *
32 * @return The acceleration along the x axis in g-forces
33 */
34 virtual double GetX() = 0;
35
36 /**
37 * Common interface for getting the y axis acceleration
38 *
39 * @return The acceleration along the y axis in g-forces
40 */
41 virtual double GetY() = 0;
42
43 /**
44 * Common interface for getting the z axis acceleration
45 *
46 * @return The acceleration along the z axis in g-forces
47 */
48 virtual double GetZ() = 0;
49};
50
51} // namespace frc