Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
MauriceRice
Posts: 425
Registered: ‎03-17-2011
My Device: Developer
My Carrier: Telus

Magnetometer correction

It's nice to finally get access to PB's magnetometer. The documentation is clear that data from the sensor is calibrated in the background. But I assume by absence of information, that the azimuth is not corrected for magnetic declination (AKA magnetic variation) to yield azimuth relative to the geographic north pole (as opposed to magnetic north). Can anyone confirm this?

 

If it is not corrected for declination, no biggie- I know how to accomplish this feat. If anyone is interested, please let me know.

 

 

_________________________
In the dark and need a sky map?
Discover What's up at App World.
Follow What's up on Facebook

Please use plain text.
Administrator
MSohm
Posts: 14,517
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Magnetometer correction

Azimuth is magnetic north.  You'll need to apply the declination if you require true north.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
MauriceRice
Posts: 425
Registered: ‎03-17-2011
My Device: Developer
My Carrier: Telus

Re: Magnetometer correction

Thanks Mark. This is an important consideration if one wants to get reasonable results. Magnetic north can vary from true north by 10, 20 or even more degrees depending on where you are on the surface of the earth.

 

For those interested there are examples (Java and c++) on the NOAA website that can determine declination, at any latitude and longitude, using the World Magnetic Model (WMM).coefficient file.  Here is the URL:

 

http://www.ngdc.noaa.gov/geomag/WMM/soft.shtml

 

I have already ported the Java version to AS3 and updated the coefficients to current values - it works very well. I will be includingc a c version of the calculator in my ANE but it may take a while as I go through the learning curve. Check out the above link if you want to get an earlier start.

 

Now if I could just get my hqnds on some concrete examples of how to dispatch events from my ANE to AIR handlers, I would be off to the races. I downloaded the ANE from Adobe in PDF format but a lot of it is Greek to me. Example code would definitely help.

 

 

 

 

_________________________
In the dark and need a sky map?
Discover What's up at App World.
Follow What's up on Facebook

Please use plain text.
Contributor
bezineb
Posts: 17
Registered: ‎01-08-2012
My Device: BlackBerry Playbook - developer
My Carrier: Virgin Mobile

Re: Magnetometer correction

Hello,

 

To send back your data in an event, I suggest you to check the Gyroscope ANE example Adobe provides (but only for android/iOS): http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/gyroscope.html

It's a good source of inspiration for the magnetometer ANE.

 

Basically, what they do on the native side is to call the FREDispatchStatusEventAsync method with the event name and the event data as a string:

 

sprintf(buffer, "%f&%f&%f", x, y, z);

if(ctx != NULL) {
 FREDispatchStatusEventAsync(ctx, (uint8_t*)"CHANGE", (uint8_t*)buffer);
}

 

I hope this helps and it's not too late...

 

By the way, do you manage to access the sensors from the ANE? Whenever I try to call the sensor_* methods from an ANE, the library no longer loads. Am I missing some permission? Any advice would be appreciated.

Please use plain text.