11-22-2011 05:21 PM
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.
11-23-2011 09:29 AM
Azimuth is magnetic north. You'll need to apply the declination if you require true north.
11-23-2011 03:30 PM
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.
02-18-2012 06:51 PM
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-
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.