sparkfun / MPU-9250_Breakout

66 stars 50 forks source link

Adding support for setting sensor scales #14

Open nalauder opened 6 years ago

nalauder commented 6 years ago

In the current implementation, it seems that the only way to change the scale of the sensors is to either directly modify the library or to create a child class of the library class.

I believe an easier solution to this is to add some simple methods that take the desired scale as arguments and set them as necessary.

These proposed changes ensure only valid scales can be written to each of the three sensors. They also achieve both writing the new scales to the device, and setting the scale value within the library itself.

nseidle commented 6 years ago

Looks pretty good. But how did AK8963_ADDRESS get in there?

nalauder commented 6 years ago

Was taken from the initAK8963 function. In order to write the new scale to the magnetometer

nseidle commented 6 years ago

Sorry - I should have looked at the source. I didn't realize there was an AK8963 in there for the mag.