Skip to content

Commit

Permalink
update examples to use chalk
Browse files Browse the repository at this point in the history
  • Loading branch information
julianduque committed Mar 13, 2015
1 parent 225d964 commit 8e0a32d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 40 deletions.
5 changes: 3 additions & 2 deletions docs/magnetometer-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ node eg/magnetometer-log.js
<!--remove-end-->

```javascript
var color = require("colors"),
var chalk = require("chalk"),
five = require("johnny-five"),
board, colors, servo, mag, count, dirs, lock;

Expand Down Expand Up @@ -60,11 +60,12 @@ var color = require("colors"),
// As the heading changes, log heading value
mag.on("headingchange", function() {
var log;
var color = colors[this.bearing.abbr];

log = (this.bearing.name + " " + Math.floor(this.heading) + "°");

console.log(
log[colors[this.bearing.abbr]]
chalk[color](log)
);


Expand Down
41 changes: 3 additions & 38 deletions docs/magnetometer-north.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ node eg/magnetometer-north.js
<!--remove-end-->

```javascript
var color = require("colors"),
var chalk = require("chalk"),
five = require("johnny-five"),
board, colors, servo, mag, count, dirs, isNorth, isSeeking, last;
board, servo, mag, count, dirs, isNorth, isSeeking, last;

board = new five.Board();

Expand Down Expand Up @@ -71,7 +71,7 @@ board.on("ready", function() {
isNorth = false;

if (!isSeeking) {
console.log("find north!".red, heading);
console.log(chalk.red("find north!"), heading);
isSeeking = true;
}

Expand All @@ -85,41 +85,6 @@ board.on("ready", function() {
});
});

colors = {
N: "red",
NbE: "red",
NNE: "red",
NEbN: "red",
NE: "yellow",
NEbE: "yellow",
ENE: "yellow",
EbN: "yellow",
E: "green",
EbS: "green",
ESE: "green",
SEbE: "green",
SE: "green",
SEbS: "cyan",
SSE: "cyan",
SbE: "cyan",
S: "cyan",
SbW: "cyan",
SSW: "cyan",
SWbS: "blue",
SW: "blue",
SWbW: "blue",
WSW: "blue",
WbS: "blue",
W: "magenta",
WbN: "magenta",
WNW: "magenta",
NWbW: "magenta",
NW: "magenta",
NWbN: "magenta",
NNW: "magenta",
NbW: "red"
};

```


Expand Down

0 comments on commit 8e0a32d

Please sign in to comment.