Skip to content

Commit 8f1bfef

Browse files
ryanjgillrwaldron
authored andcommitted
update syntax for led examples
1 parent a0dd3ed commit 8f1bfef

9 files changed

+17
-19
lines changed

eg/led-PCA9685.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const {Board, Led} = require("../lib/johnny-five.js");
22
const board = new Board();
33

4-
board.on("ready", function() {
4+
board.on("ready", () => {
55
const led = new Led({
66
pin: process.argv[2] || 0,
77
address: 0x40,
@@ -16,7 +16,7 @@ board.on("ready", function() {
1616
// Defaults to "standard".
1717

1818
// Add LED to REPL (optional)
19-
this.repl.inject({ led });
19+
board.repl.inject({ led });
2020

2121
led.pulse();
2222
});

eg/led-blink.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const {Board, Led} = require("../lib/johnny-five.js");
22
const board = new Board();
33

4-
board.on("ready", function() {
4+
board.on("ready", () => {
55
const led = new Led(13);
66

77
// "blink" the led in 500ms on-off phase periods

eg/led-demo-sequence.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function execute(step) {
7676
});
7777
}
7878

79-
board.on("ready", function () {
79+
board.on("ready", () => {
8080
// Defaults to pin 11 (must be PWM)
8181
led = new Led(process.argv[2] || 11);
8282

eg/led-fade-animation.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
const {Board, Led} = require("../lib/johnny-five.js");
22
const board = new Board();
33

4-
board.on("ready", function() {
4+
board.on("ready", () => {
55
const led = new Led(11);
66

77
led.fade({
88
easing: "linear",
99
duration: 1000,
1010
cuePoints: [0, 0.2, 0.4, 0.6, 0.8, 1],
1111
keyFrames: [0, 250, 25, 150, 100, 125],
12-
onstop: () => {
12+
onstop() {
1313
console.log("Animation stopped");
1414
}
1515
});
1616

1717
// Toggle the led after 2 seconds (shown in ms)
18-
this.wait(2000, () => {
18+
board.wait(2000, () => {
1919
led.fadeOut();
2020
});
2121
});

eg/led-fade-callback.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const {Board, Leds} = require("../lib/johnny-five.js");
22
const board = new Board();
33

4-
board.on("ready", function() {
4+
board.on("ready", () => {
55
// Set up the following PWM pins as LEDs.
66
// Fade an LED out, and the complete callback will start
77
// fading the next LED in sequence out, and so on.

eg/led-fade.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const {Board, Led} = require("../lib/johnny-five.js");
22
const board = new Board();
33

4-
board.on("ready", function() {
4+
board.on("ready", () => {
55
const led = new Led(11);
66

77
led.fadeIn();
88

99
// Toggle the led after 5 seconds (shown in ms)
10-
this.wait(5000, () => {
10+
board.wait(5000, () => {
1111
led.fadeOut();
1212
});
1313
});

eg/led-pulse-animation.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const {Board, Led} = require("../lib/johnny-five.js");
22
const board = new Board();
33

4-
board.on("ready", function() {
4+
board.on("ready", () => {
55
// Create a standard `led` component
66
// on a valid pwm pin
77
const led = new Led(11);
@@ -14,14 +14,14 @@ board.on("ready", function() {
1414
duration: 3000,
1515
cuePoints: [0, 0.2, 0.4, 0.6, 0.8, 1],
1616
keyFrames: [0, 10, 0, 50, 0, 255],
17-
onstop: () => {
17+
onstop() {
1818
console.log("Animation stopped");
1919
}
2020
});
2121

2222
// Stop and turn off the led pulse loop after
2323
// 12 seconds (shown in ms)
24-
this.wait(12000, () => {
24+
board.wait(12000, () => {
2525

2626
// stop() terminates the interval
2727
// off() shuts the led off

eg/led-pulse.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const {Board, Led} = require("../lib/johnny-five.js");
22
const board = new Board();
33

4-
board.on("ready", function() {
4+
board.on("ready", () => {
55
// Create a standard `led` component
66
// on a valid pwm pin
77
const led = new Led(11);
@@ -10,7 +10,7 @@ board.on("ready", function() {
1010

1111
// Stop and turn off the led pulse loop after
1212
// 10 seconds (shown in ms)
13-
this.wait(10000, () => {
13+
board.wait(10000, () => {
1414

1515
// stop() terminates the interval
1616
// off() shuts the led off

eg/led-tessel-servo-module.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const board = new Board({
55
io: new Tessel()
66
});
77

8-
board.on("ready", function() {
8+
board.on("ready", () => {
99
const led = new Led({
1010
pin: process.argv[2] || 1,
1111
address: 0x73,
@@ -22,9 +22,7 @@ board.on("ready", function() {
2222
// port: The Tessel port being used "A" or "B"
2323

2424
// Add LED to REPL (optional)
25-
this.repl.inject({
26-
led: led
27-
});
25+
board.repl.inject({ led });
2826

2927
led.pulse();
3028
});

0 commit comments

Comments
 (0)