Skip to content

Commit

Permalink
Compass: MAG3110 (incl. tests & diagrams)
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <[email protected]>
  • Loading branch information
rwaldron committed May 3, 2016
1 parent 4e13797 commit 495e815
Show file tree
Hide file tree
Showing 13 changed files with 780 additions and 170 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ To interactively navigate the examples, visit the [Johnny-Five examples](http://
- [Compass - HMC5883L](https://github.com/rwaldron/johnny-five/blob/master/docs/compass-hmc5883l.md)
- [Compass - HMC6352](https://github.com/rwaldron/johnny-five/blob/master/docs/compass-hmc6352.md)
- [Compass - Logger](https://github.com/rwaldron/johnny-five/blob/master/docs/magnetometer-log.md)
- [Compass - MAG3110](https://github.com/rwaldron/johnny-five/blob/master/docs/compass-MAG3110.md)
- [Compass - MAG3110 on Tessel 2](https://github.com/rwaldron/johnny-five/blob/master/docs/compass-MAG3110-tessel.md)
- [Compass / Magnetometer](https://github.com/rwaldron/johnny-five/blob/master/docs/magnetometer.md)

### Piezo
Expand Down
Binary file added docs/breadboard/compass-MAG3110-tessel.fzz
Binary file not shown.
Binary file added docs/breadboard/compass-MAG3110-tessel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/breadboard/compass-MAG3110.fzz
Binary file not shown.
Binary file added docs/breadboard/compass-MAG3110.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions docs/compass-MAG3110-tessel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<!--remove-start-->

# Compass - MAG3110 on Tessel 2

<!--remove-end-->






##### Breadboard for "Compass - MAG3110 on Tessel 2"



![docs/breadboard/compass-MAG3110-tessel.png](breadboard/compass-MAG3110-tessel.png)<br>

Fritzing diagram: [docs/breadboard/compass-MAG3110-tessel.fzz](breadboard/compass-MAG3110-tessel.fzz)

&nbsp;




Run this example from the command line with:
```bash
node eg/compass-MAG3110-tessel.js
```


```javascript
var Tessel = require("tessel-io");
var five = require("../");
var board = new five.Board({
io: new Tessel()
});

board.on("ready", function() {

var compass = new five.Compass({
controller: "MAG3110",
// Optionally pre-load the offsets
offsets: {
x: [-819, -335],
y: [702, 1182],
z: [-293, -13],
},
});

compass.on("calibrated", function(offsets) {
// Use this data with the optional "offsets" property above
console.log("calibrated:", offsets);
});

compass.on("change", function() {
console.log("change");
console.log(" heading : ", Math.floor(this.heading));
console.log(" bearing : ", this.bearing.name);
console.log("--------------------------------------");
});
});


```








&nbsp;

<!--remove-start-->

## License
Copyright (c) 2012, 2013, 2014 Rick Waldron <[email protected]>
Licensed under the MIT license.
Copyright (c) 2016 The Johnny-Five Contributors
Licensed under the MIT license.

<!--remove-end-->
80 changes: 80 additions & 0 deletions docs/compass-MAG3110.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!--remove-start-->

# Compass - MAG3110

<!--remove-end-->






##### Breadboard for "Compass - MAG3110"



![docs/breadboard/compass-MAG3110.png](breadboard/compass-MAG3110.png)<br>

Fritzing diagram: [docs/breadboard/compass-MAG3110.fzz](breadboard/compass-MAG3110.fzz)

&nbsp;




Run this example from the command line with:
```bash
node eg/compass-MAG3110.js
```


```javascript
var five = require("../");
var board = new five.Board();

board.on("ready", function() {

var compass = new five.Compass({
controller: "MAG3110",
// Optionally pre-load the offsets
offsets: {
x: [-819, -335],
y: [702, 1182],
z: [-293, -13],
},
});

compass.on("calibrated", function(offsets) {
// Use this data with the optional "offsets" property above
console.log("calibrated:", offsets);
});

compass.on("change", function() {
console.log("change");
console.log(" heading : ", Math.floor(this.heading));
console.log(" bearing : ", this.bearing.name);
console.log("--------------------------------------");
});
});


```








&nbsp;

<!--remove-start-->

## License
Copyright (c) 2012, 2013, 2014 Rick Waldron <[email protected]>
Licensed under the MIT license.
Copyright (c) 2016 The Johnny-Five Contributors
Licensed under the MIT license.

<!--remove-end-->
31 changes: 31 additions & 0 deletions eg/compass-MAG3110-tessel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var Tessel = require("tessel-io");
var five = require("../");
var board = new five.Board({
io: new Tessel()
});

board.on("ready", function() {

var compass = new five.Compass({
controller: "MAG3110",
// Optionally pre-load the offsets
offsets: {
x: [-819, -335],
y: [702, 1182],
z: [-293, -13],
},
});

compass.on("calibrated", function(offsets) {
// Use this data with the optional "offsets" property above
console.log("calibrated:", offsets);
});

compass.on("change", function() {
console.log("change");
console.log(" heading : ", Math.floor(this.heading));
console.log(" bearing : ", this.bearing.name);
console.log("--------------------------------------");
});
});

28 changes: 28 additions & 0 deletions eg/compass-MAG3110.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var five = require("../");
var board = new five.Board();

board.on("ready", function() {

var compass = new five.Compass({
controller: "MAG3110",
// Optionally pre-load the offsets
offsets: {
x: [-819, -335],
y: [702, 1182],
z: [-293, -13],
},
});

compass.on("calibrated", function(offsets) {
// Use this data with the optional "offsets" property above
console.log("calibrated:", offsets);
});

compass.on("change", function() {
console.log("change");
console.log(" heading : ", Math.floor(this.heading));
console.log(" bearing : ", this.bearing.name);
console.log("--------------------------------------");
});
});

Loading

0 comments on commit 495e815

Please sign in to comment.