Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9be6359

Browse files
committed
No defaults FIFO methods for gyroscope.
The data provided from gyroscope has no sense without timing information. This means that a correct FIFO or rate-limiting must be implemented from the sub-class. Close #1
1 parent 0a96c9a commit 9be6359

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

‎api/MotionSense.h‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,25 @@
2020
#ifndef ARDUINO_MOTION_SENSE_H
2121
#define ARDUINO_MOTION_SENSE_H
2222

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+
};
2637

2738
// 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.
2842
class Accelerometer {
2943
// Read an acceleration sample from the FIFO or wait until one is available.
3044
// Results are in G (earth gravity).
@@ -37,20 +51,10 @@ class Accelerometer {
3751
virtual unsigned long sampleRateAcceleration() { return 0; }
3852
};
3953

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-
5354
// 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.
5458
class Magnetometer {
5559
// Read a magnetometer sample from the FIFO or wait until one is available.
5660
// Results are in uT (micro Tesla).

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /