Re: [magnetometer] Why magneticFieldX instead of x?

> We could have a high-level "Compass API" along the lines of J5 to go
 with the low-level Magnetometer. Actually, discussed this briefly at 
F2F yesterday.

What would be the distinction? Why not just provide one: 

```
Magnetometer {
  heading,
  x,
  y,
  z,
}
```


> How do J5 apps that require true north handle magnetic declination

They would have to: 

1. Include a GPS to be of any use at all
2. Use lat/long to determine present local magnetic declination angle
3. Add or subtract the angle from the value of the `heading` property


Just now I ran a program that prints the heading in degrees as read 
from an HMC5883L, with the sensor on my desk. On the other side of my 
keyboard, I placed my iPhone with the compass app open and lined it up
 to north. Then I lined up the sensor's x axis to north (which was 
off). From there, I looked my present declination angle on 
http://www.magnetic-declination.com/ (at the moment, I'm in Boston), 
and it was -14 degrees. So my program looked like this: 


```js
const five = require("../");
const board = new five.Board();

board.on("ready", () => {
  const mag = new five.Magnetometer({
    controller: "HMC5883L"
  });

  mag.on("change", () => {
    console.log(Math.round(mag.heading - 14));
  });
});
```


I'm sure a phone or pc with gps could expose that data in an elegant 
way. 

-- 
GitHub Notification of comment by rwaldron
Please view or discuss this issue at 
https://github.com/w3c/magnetometer/issues/3#issuecomment-248978243 
using your GitHub account

Received on Thursday, 22 September 2016 17:54:24 UTC