PaulStoffregen / NXPMotionSense

NXP Motion Sensors for Teensy and Arduino
69 stars 51 forks source link

Altitude/Temp & Pressure made visible #10

Open mjs513 opened 4 years ago

mjs513 commented 4 years ago

Hi Paul

In the thread, https://forum.pjrc.com/threads/40346-Teensy-3-2-w-Prop-Shield-Pressure-Sensor-causing-sketch-to-run-very-slow, and one of the Issues some folks wanted to make data from the MPL sensor visible to the user and improve speed.

I made some changes, but not sure best, that reduces the Over Sample rate down to 32ms from 512ms that you currently use. In addition I added three functions:

    void setSeaPressure(float pascal);   // allows user to set local sea level pressure
    void readPressure();  // reads pressure in millibars
    void readAltitude();  // reads altitude in meters and temperature in degrees centigrade

readPressure and readAltitude functions lifted from Kris Winers MPL3115A2 code. setSeaPressure from adafruit library since it was already there (just sets a register).

So now if a user wants MPL data they have to specifically ask for it so I removed the MPL3115_read call in the Update function. The code defaults to altimeter mode. When you call readPressure it switches to barometer mode and then back to altimeter mode. I also added a an example.

Let me know if you want anything changed.

mjs513 commented 3 years ago

@PaulStoffregen - looks like I have the code in the PR to expose the Quaternion as well that was shown in PR https://github.com/PaulStoffregen/NXPMotionSense/pull/2