Skip to content

Commit

Permalink
update syntax for led examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjgill authored and rwaldron committed Aug 21, 2019
1 parent a0dd3ed commit 8f1bfef
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions eg/led-PCA9685.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {Board, Led} = require("../lib/johnny-five.js");
const board = new Board();

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

// Add LED to REPL (optional)
this.repl.inject({ led });
board.repl.inject({ led });

led.pulse();
});
2 changes: 1 addition & 1 deletion eg/led-blink.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {Board, Led} = require("../lib/johnny-five.js");
const board = new Board();

board.on("ready", function() {
board.on("ready", () => {
const led = new Led(13);

// "blink" the led in 500ms on-off phase periods
Expand Down
2 changes: 1 addition & 1 deletion eg/led-demo-sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function execute(step) {
});
}

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

Expand Down
6 changes: 3 additions & 3 deletions eg/led-fade-animation.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const {Board, Led} = require("../lib/johnny-five.js");
const board = new Board();

board.on("ready", function() {
board.on("ready", () => {
const led = new Led(11);

led.fade({
easing: "linear",
duration: 1000,
cuePoints: [0, 0.2, 0.4, 0.6, 0.8, 1],
keyFrames: [0, 250, 25, 150, 100, 125],
onstop: () => {
onstop() {
console.log("Animation stopped");
}
});

// Toggle the led after 2 seconds (shown in ms)
this.wait(2000, () => {
board.wait(2000, () => {
led.fadeOut();
});
});
2 changes: 1 addition & 1 deletion eg/led-fade-callback.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {Board, Leds} = require("../lib/johnny-five.js");
const board = new Board();

board.on("ready", function() {
board.on("ready", () => {
// Set up the following PWM pins as LEDs.
// Fade an LED out, and the complete callback will start
// fading the next LED in sequence out, and so on.
Expand Down
4 changes: 2 additions & 2 deletions eg/led-fade.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const {Board, Led} = require("../lib/johnny-five.js");
const board = new Board();

board.on("ready", function() {
board.on("ready", () => {
const led = new Led(11);

led.fadeIn();

// Toggle the led after 5 seconds (shown in ms)
this.wait(5000, () => {
board.wait(5000, () => {
led.fadeOut();
});
});
6 changes: 3 additions & 3 deletions eg/led-pulse-animation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {Board, Led} = require("../lib/johnny-five.js");
const board = new Board();

board.on("ready", function() {
board.on("ready", () => {
// Create a standard `led` component
// on a valid pwm pin
const led = new Led(11);
Expand All @@ -14,14 +14,14 @@ board.on("ready", function() {
duration: 3000,
cuePoints: [0, 0.2, 0.4, 0.6, 0.8, 1],
keyFrames: [0, 10, 0, 50, 0, 255],
onstop: () => {
onstop() {
console.log("Animation stopped");
}
});

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

// stop() terminates the interval
// off() shuts the led off
Expand Down
4 changes: 2 additions & 2 deletions eg/led-pulse.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {Board, Led} = require("../lib/johnny-five.js");
const board = new Board();

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

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

// stop() terminates the interval
// off() shuts the led off
Expand Down
6 changes: 2 additions & 4 deletions eg/led-tessel-servo-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const board = new Board({
io: new Tessel()
});

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

// Add LED to REPL (optional)
this.repl.inject({
led: led
});
board.repl.inject({ led });

led.pulse();
});

0 comments on commit 8f1bfef

Please sign in to comment.