Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Prop Shield Altimeter

  1. #1

    Prop Shield Altimeter

    I see a function in the NXPMotionSense library to read altitude from the pressure sensor, but it's private:
    Code:
    private:
    	void update();
    	bool FXOS8700_begin();
    	bool FXAS21002_begin();
    	bool MPL3115_begin();
    	bool FXOS8700_read(int16_t *data);
    	bool FXAS21002_read(int16_t *data);
    	bool MPL3115_read(int32_t *altitude, int16_t *temperature);
    ...
    So, how can I read the altitude in my sketch?

  2. #2
    I found two workarounds. First, just
    Code:
    #define private public
    which is naughty.

    Second, make local copies of the functions
    Code:
    bool MPL3115_read(int32_t *altitude, int16_t *temperature)
    static bool read_regs(uint8_t i2c, uint8_t addr, uint8_t *data, uint8_t num)
    static bool read_regs(uint8_t i2c, uint8_t *data, uint8_t num)
    which is a last resort.

    Paul, may I ask you to make it public?

  3. #3
    I see now someone else has branched the library and made the changes:
    https://github.com/mjs513/NXPMotionSense

    Thanks!

  4. #4
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    7,549
    Quote Originally Posted by Citabria View Post
    I see now someone else has branched the library and made the changes:
    https://github.com/mjs513/NXPMotionSense

    Thanks!
    There is an open PR for that as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •