-
Notifications
You must be signed in to change notification settings - Fork 281
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
The Wire.requestFrom does not need a Wire.beginTransmission, no Wire.endTransmission and no waiting. #4
Comments
I agree with Koepel, the loops also cause the Arduino to hang if the MPU6050 disconnects (either because of cable or power failure) |
If he can fix it, why can't you ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the file MPU6050.cpp the use of Wire.requestFrom can be improved.
The Wire.beginTransmission and Wire.endTransmission are only needed when writing data. They should not be used with Wire.requestFrom and can be removed. In two places there is Wire.beginTransmission, and in three places both the Wire.beginTransmission and Wire.endTransmission with the Wire.requestFrom. They can all be removed.
The Wire.requestFrom is a complete I2C transaction on its own. It stores the received data in a buffer in the Wire library and returns when the I2C transaction completely has finished. It is therefor not needed to wait for something. In four places there is a while-loop after Wire.requestFrom. Those while-loops can be removed.
The text was updated successfully, but these errors were encountered: