20
20
#ifndef ARDUINO_MOTION_SENSE_H
21
21
#define ARDUINO_MOTION_SENSE_H
22
22
23
- // Sensors that doesn't implement a FIFO can use the default
24
- // implementation of availableXxx() and sampleRateXxx() and
25
- // always return the last valid sample.
23
+ // Base class for gyroscope
24
+ class Gyroscope {
25
+ // Read a gyro sample from the FIFO or wait until one is available.
26
+ // Results are in degrees/second.
27
+ virtual bool readGyroscope (float &x, float &y, float &z) = 0;
28
+
29
+ // Number of samples in the FIFO.
30
+ // Sensors without a FIFO should return 1 only if the sensor has
31
+ // produced a new measurement since the most recent read.
32
+ virtual unsigned int availableGyroscope () = 0;
33
+
34
+ // Sampling rate of the sensor.
35
+ virtual unsigned long sampleRateGyroscope () = 0;
36
+ };
26
37
27
38
// Base class for accelerometers
39
+ // Sensors without a FIFO can use the default implementation of
40
+ // availableXxx() and sampleRateXxx() and always return the last
41
+ // valid measurement.
28
42
class Accelerometer {
29
43
// Read an acceleration sample from the FIFO or wait until one is available.
30
44
// Results are in G (earth gravity).
@@ -37,20 +51,10 @@ class Accelerometer {
37
51
virtual unsigned long sampleRateAcceleration () { return 0 ; }
38
52
};
39
53
40
- // Base class for gyroscope
41
- class Gyroscope {
42
- // Read a gyro sample from the FIFO or wait until one is available.
43
- // Results are in degrees/second.
44
- virtual bool readGyroscope (float &x, float &y, float &z) = 0;
45
-
46
- // Number of samples in the FIFO.
47
- virtual unsigned int availableGyroscope () { return 1 ; }
48
-
49
- // Sampling rate of the sensor.
50
- virtual unsigned long sampleRateGyroscope () { return 0 ; }
51
- };
52
-
53
54
// Base class for magnetometers
55
+ // Sensors without a FIFO can use the default implementation of
56
+ // availableXxx() and sampleRateXxx() and always return the last
57
+ // valid measurement.
54
58
class Magnetometer {
55
59
// Read a magnetometer sample from the FIFO or wait until one is available.
56
60
// Results are in uT (micro Tesla).
0 commit comments