Skip to content

Use single dataReady() method, instead of accelDataReady/gyroDataReady #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2017

Conversation

eriknyquist
Copy link
Contributor

@eriknyquist eriknyquist commented Jan 30, 2017

This method is a bit more flexible. There is a version with no
parameters, which will return true if all enabled sensors have new
data. There is one overload, that takes a single 'flags' parameter,
which returns true if all enabled and selected sensors have new data.
Sensors are selectable through pre-defined bit flags. For example;

CurieIMU.dataReady() : this will return true if both the accel and gyro
are enabled, and both have new data ready.

CurieIMU.dataReady(ACCEL | GYRO) : this will return true if both the
accel and gyro have new data ready (if one of the passed sensors is not
enabled, it is ignored and the function will behave as if that sensor was not
specified)

CurieIMU.dataReady(GYRO) : this will return true if the gyro is
enabled and has new data ready.

CurieIMU.dataReady(ACCEL) : this will return true if the accel is
enabled and has new data ready.

This also involved changing the 'begin' method to allow selective
enabling of sensors, e.g.

CurieIMU.begin() : same as it always has, initializes IMU, enabling
both accel and gyro

CurieIMU.begin(ACCEL | GYRO) : initializes IMU, enabling both accel
and gyro

CurieIMU.begin(ACCEL) : initializes IMU, enabling accel only

CurieIMU.begin(GYRO) : initializes IMU, enabling  gyro only

@eriknyquist eriknyquist requested review from russmcinnis and removed request for russmcinnis February 9, 2017 21:58
@eriknyquist
Copy link
Contributor Author

@russmcinnis to verify

@eriknyquist eriknyquist force-pushed the drdy branch 5 times, most recently from 778d17a to 8021366 Compare February 17, 2017 21:57
This method is a bit more flexible. There is a version with no
parameters, which will return true if all enabled sensors have new
data. There is one overload, that takes a single 'flags' parameter,
which returns true if all enabled *and* selected sensors have new data.
Sensors are selectable through bit flags. For example;

    CurieIMU.dataReady() : this will return true if both the accel and gyro
    are enabled, and both have new data ready.

    CurieIMU.dataReady(ACCEL | GYRO) : this will return true if both the
    accel and gyro are enabled, and both have new data ready.

    CurieIMU.dataReady(GYRO) : this will return true if the gyro is
    enabled and has new data ready.

    CurieIMU.dataReady(ACCEL) : this will return true if the accel is
    enabled and has new data ready.

This also involved changing the 'begin' method to allow selective
enabling of sensors, e.g.

    CurieIMU.begin() : same as it always has, initializes IMU, enabling
    both accel and gyro

    CurieIMU.begin(ACCEL | GYRO) : initializes IMU, enabling both accel
    and gyro

    CurieIMU.begin(ACCEL) : initializes IMU, enabling accel only
@eriknyquist eriknyquist merged commit ee08a03 into arduino:master Feb 22, 2017
@eriknyquist eriknyquist deleted the drdy branch February 22, 2017 19:12
@PaulStoffregen
Copy link

Just curious, why dataReady?

In the Arduino world, isn't the well established convention to name this "available"?

@eriknyquist
Copy link
Contributor Author

dataReady() because it does what it says on the tin..... available generally tells you how many buffered incoming items are available. dataReady() just tells you whether the next un-read sample is available from a particular sensor, no buffering. True or false.

@eriknyquist
Copy link
Contributor Author

@PaulStoffregen also, @facchinm and @tigoe and I discussed this back and forth for a bit, and this API is the one we all agreed on :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants