Skip to content
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

Missing public method accelerometer.whoAmI() #447

Open
bobwilmes opened this issue Jun 26, 2019 · 3 comments
Open

Missing public method accelerometer.whoAmI() #447

bobwilmes opened this issue Jun 26, 2019 · 3 comments

Comments

@bobwilmes
Copy link

The file microbit-dal/source/drivers/MicroBitAccelerometer.cpp appears to be missing a declaration for the public method accelerometer.whoAmI() as described in the documentation here:
https://lancaster-university.github.io/microbit-docs/ubit/accelerometer/#whoami

@martinwork
Copy link
Contributor

I think this is the case. In fact the whoAmI function is not implemented yet. PR #373 was to implement whatAmI.

From https://lancaster-university.github.io/microbit-docs/ubit/accelerometer/
"There are two variants of the micro:bit , one uses the MMA8653 and the other a uses the LSM303 combined accelerometer and magnetometer."

If you need to determine which accelerometer is in use now, as a temporary workaround, you could try using the isDetected functions. These functions make a call to I2C to see what hardware is present, whereas whoAmI/whatAmI would return the previously detected state.

For example,

#include "LSM303Accelerometer.h"
int isLSM303 = LSM303Accelerometer::isDetected(uBit.i2c);

static int isDetected(MicroBitI2C &i2c, uint16_t address = MMA8653_DEFAULT_ADDR);

static int isDetected(MicroBitI2C &i2c, uint16_t address = LSM303_A_DEFAULT_ADDR);

static int isDetected(MicroBitI2C &i2c, uint16_t address = FXOS8700_DEFAULT_ADDR);

@bobwilmes
Copy link
Author

Thank you Martin - I tried the work around and it works. Slight nit - on the public class names for the accelerometer - the MMA8653 and the FXOS8700 use class name's based on the device as in
::isDetected.

The LSM303 uses LSM303Accelerometer::isDetected.

@martinwork
Copy link
Contributor

Not sure I understand, but yes, we should only need to use functions in MicroBitAccelerometer (ie. uBit.accelerometer). Accessing the device specific class is the only workaround I can see, until whoAmI gets added.

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

No branches or pull requests

2 participants