-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
20 lines (16 loc) · 611 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//include the module
var hmc6343 = require('./src/hmc6343.js');
//create new instance
var compass = new hmc6343('/dev/i2c-3', 0x19);
//read in accelerometer data
compass.readAccel(function(accelData) {
console.log("Accel Data: " + accelData.ax + ", " + accelData.ay + ", " + accelData.az);
});
//read in magnetic data
compass.readMag(function(magData) {
console.log("Mag Data: " + magData.mx + ", " + magData.my + ", " + magData.mz);
});
//read in attitude data (in radians)
compass.readAtt(function(attData) {
console.log("Attitude: " + attData.heading + ", " + attData.pitch + ", " + attData.roll);
});