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

Magnetometer BLE service calibration states #425

Open
ukBaz opened this issue Feb 23, 2019 · 2 comments
Open

Magnetometer BLE service calibration states #425

ukBaz opened this issue Feb 23, 2019 · 2 comments

Comments

@ukBaz
Copy link

ukBaz commented Feb 23, 2019

The calibration behaviour has been changed on the magnetometer... no auto-calibration when you instantiate the magnetometer service like previously. This results in no notifications or readings until calibration has been performed.
I can trigger a calibration by sending 0x01 to the new characteristic (e95db358-251d-470a-a062-fa1922dfa9a8).
I am writing Python on a Raspberry Pi to interact with the micro:bit. Not sure how to modify my code to handle this change. After issuing the 'calibrate' command, there does not seem a clean way to know when the calibration is finished. Also there doesn't seem to be a clean way to tell if this is the first time the device has been used and needs calibration. Anyone got any thoughts on this?

@ukBaz
Copy link
Author

ukBaz commented Mar 2, 2019

Thanks @microbit-sam for updating the docs (as noted in #412 (comment)) with some more information about calibration and values.
The docs now answer the question about knowing if the calibration has been successful or not.

It does not answer the question about how I detect if I need to calibrate the magnetometer or not.

The introduction of this calibration characteristic seems a backwards and unnecessary development.

When I use the magnetometer without Bluetooth I do not have manage if the device needs calibration. If I use the heading value the device promotes for calibration if it needs it. Previously that is what the Bluetooth magnetometer service also did. When I started the service it would prompt the user to calibrate the magnetometer if it required it.
Why has this changed to a manual step? It seems to complicate the code I need to write for no gain and is inconsistent with the non-Bluetooth mode usage.

I have tried to have a discussion about this on Slack and now here.
To ask a direct question:
Is there a possibility that we can revert the Bluetooth magnetometer service so it manages if it needs calibration or not?
@jaustin is this something you can answer?

@microbit-sam
Copy link
Contributor

Hi Barry, sorry I'm not very active on Slack so will have missed any discussion on there

This commit prevents the compass from automatically triggering calibration, I think (may be misremembering) this was added so for cases where a device has a malfunctioning mag/acc would not be able to get past the calibration screen, although if that is the case perhaps a timeout / escape key would be better.. @finneyj is that right?
lancaster-university/microbit@d54e26f#diff-6047755bfccc64c91f0d390dd2f1061e

Calling compass.heading() should trigger a calibration, or compass.calibrate() immediately after creating the MagnetometerService could be a possible workaround for now

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