blob: 12296ca1e3e220b227f3194f5e8d8a2ee93b556b [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05002/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
Brian Silverman26e4e522015-12-17 01:56:40 -05003/* Open Source Software - may be modified and shared by FRC teams. The code */
Brian Silverman1a675112016-02-20 20:42:49 -05004/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
Brian Silverman26e4e522015-12-17 01:56:40 -05006/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05007
Brian Silverman26e4e522015-12-17 01:56:40 -05008#pragma once
9
10/**
11 * Interface for 3-axis accelerometers
12 */
13class Accelerometer {
14 public:
15 virtual ~Accelerometer() = default;
16
17 enum Range { kRange_2G = 0, kRange_4G = 1, kRange_8G = 2, kRange_16G = 3 };
18
19 /**
20 * Common interface for setting the measuring range of an accelerometer.
21 *
22 * @param range The maximum acceleration, positive or negative, that the
23 * accelerometer will measure. Not all accelerometers support all ranges.
24 */
25 virtual void SetRange(Range range) = 0;
26
27 /**
28 * Common interface for getting the x axis acceleration
29 *
30 * @return The acceleration along the x axis in g-forces
31 */
32 virtual double GetX() = 0;
33
34 /**
35 * Common interface for getting the y axis acceleration
36 *
37 * @return The acceleration along the y axis in g-forces
38 */
39 virtual double GetY() = 0;
40
41 /**
42 * Common interface for getting the z axis acceleration
43 *
44 * @return The acceleration along the z axis in g-forces
45 */
46 virtual double GetZ() = 0;
47};