Skip to content

Commit ca469ef

Browse files
committed
Regenerate all of the doc/example files
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
1 parent e449678 commit ca469ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+919
-862
lines changed

docs/accelerometer-pan-tilt.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ node eg/accelerometer-pan-tilt.js
88

99
```javascript
1010
var five = require("johnny-five"),
11-
board;
11+
board;
1212

1313
board = new five.Board();
1414

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

1717
var range, pan, tilt, accel;
1818

19-
range = [ 0, 170 ];
19+
range = [0, 170];
2020

2121
// Servo to control panning
2222
pan = new five.Servo({
@@ -32,18 +32,18 @@ board.on("ready", function() {
3232

3333
// Accelerometer to control pan/tilt
3434
accel = new five.Accelerometer({
35-
pins: [ "A3", "A4", "A5" ],
35+
pins: ["A3", "A4", "A5"],
3636
freq: 250
3737
});
3838

3939
// Center all servos
4040
(five.Servos()).center();
4141

42-
accel.on("acceleration", function( err, timestamp ) {
42+
accel.on("acceleration", function(err, timestamp) {
4343
// console.log( "acceleration", this.axis );
4444

45-
tilt.move( Math.abs( Math.ceil(170 * this.pitch.toFixed(2)) - 180 ) );
46-
pan.move( Math.ceil(170 * this.roll.toFixed(2)) );
45+
tilt.move(Math.abs(Math.ceil(170 * this.pitch.toFixed(2)) - 180));
46+
pan.move(Math.ceil(170 * this.roll.toFixed(2)));
4747

4848
// TODO: Math.abs(v - 180) as inversion function ?
4949
});

docs/accelerometer.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ node eg/accelerometer.js
88

99
```javascript
1010
var five = require("johnny-five"),
11-
board, accel;
11+
board, accel;
1212

1313
board = new five.Board();
1414

@@ -25,7 +25,7 @@ board.on("ready", function() {
2525
//
2626

2727
accel = new five.Accelerometer({
28-
pins: [ "A3", "A4", "A5" ],
28+
pins: ["A3", "A4", "A5"],
2929
freq: 100,
3030
threshold: 0.2
3131
});
@@ -37,18 +37,18 @@ board.on("ready", function() {
3737
// Fires once every N ms, equal to value of freg
3838
// Defaults to 500ms
3939
//
40-
accel.on("acceleration", function( err, data ) {
40+
accel.on("acceleration", function(err, data) {
4141

42-
console.log( "acceleration", data.smooth );
42+
console.log("acceleration", data.smooth);
4343
});
4444

4545
// "axischange"
4646
//
4747
// Fires only when X, Y or Z has changed
4848
//
49-
accel.on("axischange", function( err, timestamp ) {
49+
accel.on("axischange", function(err, timestamp) {
5050

51-
console.log( "axischange", this.raw );
51+
console.log("axischange", this.raw);
5252
});
5353
});
5454

docs/board-multi.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ node eg/board-multi.js
1010
var five = require("johnny-five");
1111

1212
// Create 2 board instances with IDs "A" & "B"
13-
new five.Boards([ "A", "B" ]).on("ready", function() {
13+
new five.Boards(["A", "B"]).on("ready", function() {
1414

1515
// Both "A" and "B" are initialized
1616
// (connected and available for communication)
@@ -21,7 +21,10 @@ new five.Boards([ "A", "B" ]).on("ready", function() {
2121

2222
// Initialize an Led instance on pin 13 of
2323
// each initialized board and strobe it.
24-
new five.Led({ pin: 13, board: board }).strobe();
24+
new five.Led({
25+
pin: 13,
26+
board: board
27+
}).strobe();
2528
});
2629
});
2730

docs/board-with-port.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@ node eg/board-with-port.js
88

99
```javascript
1010
var five = require("johnny-five"),
11-
board;
11+
board;
1212

1313
// Johnny-Five will try its hardest to detect the port for you,
1414
// however you may also explicitly specify the port by passing
1515
// it as an optional property to the Board constructor:
16-
board = new five.Board({ port: "/dev/cu.usbmodem411" });
16+
board = new five.Board({
17+
port: "/dev/cu.usbmodem411"
18+
});
1719

1820
// The board's pins will not be accessible until
1921
// the board has reported that it is ready
2022
board.on("ready", function() {
2123
var val = 0;
2224

2325
// Set pin 13 to OUTPUT mode
24-
this.pinMode( 13, 1 );
26+
this.pinMode(13, 1);
2527

2628
// Mode Table
2729
// INPUT: 0
@@ -31,8 +33,8 @@ board.on("ready", function() {
3133
// SERVO: 4
3234

3335
// Create a loop to "flash/blink/strobe" an led
34-
this.loop( 50, function() {
35-
this.digitalWrite( 13, (val = val ? 0 : 1) );
36+
this.loop(50, function() {
37+
this.digitalWrite(13, (val = val ? 0 : 1));
3638
});
3739
});
3840

docs/board.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ five.Board().on("ready", function() {
1515
var val = 0;
1616

1717
// Set pin 13 to OUTPUT mode
18-
this.pinMode( 13, 1 );
18+
this.pinMode(13, 1);
1919

2020
// Create a loop to "flash/blink/strobe" an led
21-
this.loop( 100, function() {
22-
this.digitalWrite( 13, (val = val ? 0 : 1) );
21+
this.loop(100, function() {
22+
this.digitalWrite(13, (val = val ? 0 : 1));
2323
});
2424
});
2525

docs/bug.md

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ node eg/bug.js
99
```javascript
1010
var five = require("johnny-five");
1111

12-
function Bug( servos ) {
12+
function Bug(servos) {
1313
var part, k;
1414

1515
this.isMoving = false;
1616

1717
// Initialize list of body parts
18-
this.parts = [ "front", "left", "right", "rear" ];
18+
this.parts = ["front", "left", "right", "rear"];
1919

2020
// Servo positions
2121
this.history = [];
@@ -28,10 +28,10 @@ function Bug( servos ) {
2828

2929
k = -1;
3030
// Initialize Servo properties from "servos" argument
31-
while ( ++k < this.parts.length ) {
32-
part = this.parts[ k ];
31+
while (++k < this.parts.length) {
32+
part = this.parts[k];
3333

34-
this[ part ] = servos[ part ] || null;
34+
this[part] = servos[part] || null;
3535
}
3636

3737
// Unwind and wait ~10ms, center servos
@@ -43,12 +43,12 @@ function Bug( servos ) {
4343
Bug.STEP_MAP = {
4444
// steps
4545
fwd: [
46-
[ 10, -30 ],
47-
[ -15, 30 ]
46+
[10, -30],
47+
[-15, 30]
4848
],
4949
rev: [
50-
[ -15, 30 ],
51-
[ 15, -30 ]
50+
[-15, 30],
51+
[15, -30]
5252
]
5353
};
5454

@@ -60,13 +60,13 @@ Bug.prototype.idle = function() {
6060

6161
// If the bug is actually in motion,
6262
// stop the servo intervals
63-
if ( this.isMoving ) {
63+
if (this.isMoving) {
6464
this.stop();
6565
}
6666

6767
// set to center position°
68-
this.front.move( 90 );
69-
this.rear.move( 90 );
68+
this.front.move(90);
69+
this.rear.move(90);
7070

7171
//return this;
7272
};
@@ -79,22 +79,23 @@ Bug.prototype.idle = function() {
7979
* dir {String}
8080
* @return {Bug}
8181
*/
82-
Bug.prototype.step = function( opts ) {
82+
Bug.prototype.step = function(opts) {
8383
var dir, move, last, front, rear, step;
8484

8585
opts = opts || {};
8686

8787
// Get last move from history if any history exists
8888
// Provide a "fake" history if needed (first call)
8989
last = this.history.length ?
90-
this.history[ this.history.length - 1 ] :
91-
{ step: 1 };
90+
this.history[this.history.length - 1] : {
91+
step: 1
92+
};
9293

9394
// increment the last step
9495
step = last.step + 1;
9596

9697
// If step is too high, step back to 0
97-
if ( step > 1 ) {
98+
if (step > 1) {
9899
step = 0;
99100
}
100101

@@ -103,20 +104,20 @@ Bug.prototype.step = function( opts ) {
103104
dir = opts.dir || "fwd";
104105

105106
// Derive position° for next move
106-
move = Bug.STEP_MAP[ dir ][ step ];
107+
move = Bug.STEP_MAP[dir][step];
107108

108109
// Assign position° from center
109110
front = 90 + move[0];
110111
rear = 90 + move[1];
111112

112113
// Write position° to servos
113-
this.front.move( front );
114-
this.rear.move( rear );
114+
this.front.move(front);
115+
this.rear.move(rear);
115116

116117
// Allow half step or full if provided,
117118
// defaults to full
118119
// enum(false|null|undefined)
119-
if ( !opts.half ) {
120+
if (!opts.half) {
120121
// Wait one second and move servos back to
121122
// center idling position, 90°
122123
setTimeout(function() {
@@ -129,7 +130,12 @@ Bug.prototype.step = function( opts ) {
129130
this.history.push(
130131
// NOTE: this is a great use case example for
131132
// ES.next concise object initializers
132-
{ dir: dir, step: step, front: front, rear: rear }
133+
{
134+
dir: dir,
135+
step: step,
136+
front: front,
137+
rear: rear
138+
}
133139
);
134140
};
135141

@@ -138,9 +144,9 @@ Bug.prototype.step = function( opts ) {
138144
* @return {Bug}
139145
*/
140146
Bug.prototype.stop = function() {
141-
Object.keys( this.intervals ).forEach(function( key ) {
142-
if ( this.intervals[ key ] ) {
143-
clearInterval( this.intervals[ key ] );
147+
Object.keys(this.intervals).forEach(function(key) {
148+
if (this.intervals[key]) {
149+
clearInterval(this.intervals[key]);
144150
}
145151
}, this);
146152
//return this;
@@ -159,15 +165,18 @@ Bug.prototype.stop = function() {
159165
*/
160166
"rev"
161167

162-
].forEach(function( dir, k ) {
168+
].forEach(function(dir, k) {
163169

164-
Bug.prototype[ dir ] = function() {
170+
Bug.prototype[dir] = function() {
165171

166172
this.isMoving = true;
167173

168-
this.intervals[ dir ] = setInterval(function() {
169-
this.step({ dir: dir, half: true });
170-
}.bind(this), 750 );
174+
this.intervals[dir] = setInterval(function() {
175+
this.step({
176+
dir: dir,
177+
half: true
178+
});
179+
}.bind(this), 750);
171180

172181
// //return this;
173182
};

docs/button-bumper.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ node eg/button-bumper.js
88

99
```javascript
1010
var five = require("johnny-five"),
11-
bumper, led;
11+
bumper, led;
1212

1313
five.Board().on("ready", function() {
1414

docs/button-options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ node eg/button-options.js
88

99
```javascript
1010
var five = require("johnny-five"),
11-
board, button;
11+
board, button;
1212

1313
board = new five.Board();
1414

docs/button-pullup.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ node eg/button-pullup.js
2020
// https://learn.sparkfun.com/tutorials/pull-up-resistors
2121

2222
var five = require("../lib/johnny-five"),
23-
button, led;
23+
button, led;
2424

2525
five.Board().on("ready", function() {
2626

@@ -31,11 +31,11 @@ five.Board().on("ready", function() {
3131

3232
led = new five.Led(13);
3333

34-
button.on("down", function(value){
34+
button.on("down", function(value) {
3535
led.on();
3636
});
3737

38-
button.on("up", function(){
38+
button.on("up", function() {
3939
led.off();
4040
});
4141

docs/button.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ node eg/button.js
88

99
```javascript
1010
var five = require("johnny-five"),
11-
board, button;
11+
board, button;
1212

1313
board = new five.Board();
1414

0 commit comments

Comments
 (0)