Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 2 | /* Copyright (c) FIRST 2014-2016. All Rights Reserved. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 6 | /*----------------------------------------------------------------------------*/ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 7 | |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 8 | #pragma once |
| 9 | |
| 10 | /** |
| 11 | * Interface for 3-axis accelerometers |
| 12 | */ |
| 13 | class 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 | }; |