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

Get accuracy of compass #4

Open
draperunner opened this issue Dec 5, 2017 · 6 comments
Open

Get accuracy of compass #4

draperunner opened this issue Dec 5, 2017 · 6 comments

Comments

@draperunner
Copy link

draperunner commented Dec 5, 2017

In order to check whether the user needs to recalibrate the compass or not, it would be nice to get some information about the accuracy of the measurements.

It seems likenewHeading.headingAccuracy on iOS and public void onAccuracyChanged(Sensor sensor, int accuracy) on Android are the ways to get the accuracy. This could for instance be sent as a second parameter in the event handler callback: RNSimpleCompass.start(degree_update_rate, (degree, accuracy) => { ...

A problem is that "accuracy" is not the same thing on iOS and Android... Android uses four integer values, while on iOS uses floating point values that might be negative.

An alternative to getting the accuracy value is to dispatch an event when the compass is giving an invalid value, and will probably need calibration. This is when the accuracy is negative on iOS or 0 on Android.

What do you think?

@pashute
Copy link

pashute commented May 3, 2018

@draperunner But if you DO know that it needs calibration, is there a way to calibrate it via the api ?
How can I get a new calibration done (after the user moves the app in a figure 8)?

It seems no-one has dealt with this problem. For the longest time I'm getting no answer here: https://stackoverflow.com/questions/50178675/how-can-i-calibrate-the-compass-with-a-native-react-api

@draperunner
Copy link
Author

@pashute If you have the compass accuracy, you know the compass has been calibrated when its accuracy is high again. You could show the calibration instruction figure while the accuracy is below your chosen threshold.

@pashute
Copy link

pashute commented Sep 5, 2018 via email

@draperunner
Copy link
Author

Yes. By moving your phone around like that, the compass will get calibrated automatically, without having to manually start a calibration process. Here's a good explanation of why it works: https://android.stackexchange.com/a/30341

@pashute
Copy link

pashute commented Sep 11, 2018 via email

@Lelelo1
Copy link

Lelelo1 commented May 1, 2019

I exposed the headingAccuracy on ios. I got a reading of 25 and sometimes 35. Nothing in between. Walking 35 mins in a city. When major disturbances in magnetic field occurred it was not reflected in the accuracy value in any way.

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

3 participants