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