Skip to content

Commit 4d6c89a

Browse files
committed
Examples: make Light example output consistent
1 parent e846248 commit 4d6c89a

6 files changed

+30
-18
lines changed

eg/light-ambient-BH1750.js

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

44
board.on("ready", () => {
5-
const light = new Light({
5+
const ambient = new Light({
66
controller: "BH1750",
77
});
88

9-
light.on("data", (data) => {
10-
console.log("Lux: ", data.lux);
9+
ambient.on("change", () => {
10+
console.log("Ambient Light Level: ");
11+
console.log(" level : ", ambient.level);
12+
console.log("-----------------");
1113
});
1214
});

eg/light-ambient-EVS_EV3.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ const { Board, Light } = require("../lib/johnny-five");
22
const board = new Board();
33

44
board.on("ready", () => {
5-
const light = new Light({
5+
const ambient = new Light({
66
controller: "EVS_EV3",
77
pin: "BAS1"
88
});
99

10-
light.on("change", (data) => {
11-
console.log("Ambient Light Level: ", data.level);
10+
ambient.on("change", () => {
11+
console.log("Ambient Light Level: ");
12+
console.log(" level : ", ambient.level);
13+
console.log("-----------------");
1214
});
1315
});

eg/light-ambient-EVS_NXT.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ const { Board, Light } = require("../lib/johnny-five");
22
const board = new Board();
33

44
board.on("ready", () => {
5-
const light = new Light({
5+
const ambient = new Light({
66
controller: "EVS_NXT",
77
pin: "BAS2"
88
});
99

10-
light.on("change", (data) => {
11-
console.log("Ambient Light Level: ", data.level);
10+
ambient.on("change", () => {
11+
console.log("Ambient Light Level: ");
12+
console.log(" level : ", ambient.level);
13+
console.log("-----------------");
1214
});
1315
});

eg/light-ambient-TSL2561.js

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

44
board.on("ready", () => {
5-
const light = new Light({
5+
const ambient = new Light({
66
controller: "TSL2561",
77
});
88

9-
light.on("data", (data) => {
10-
console.log("Lux: ", data.lux);
9+
ambient.on("change", () => {
10+
console.log("Ambient Light Level: ");
11+
console.log(" level : ", ambient.level);
12+
console.log("-----------------");
1113
});
1214
});

eg/light-reflected-EVS_EV3.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ const { Board, Light } = require("../lib/johnny-five");
22
const board = new Board();
33

44
board.on("ready", () => {
5-
const reflect = new Light({
5+
const reflected = new Light({
66
controller: "EVS_EV3",
77
pin: "BAS1",
88
mode: "reflected"
99
});
1010

11-
reflect.on("change", (data) => {
12-
console.log("Light Reflection Level: ", data.level);
11+
reflected.on("change", () => {
12+
console.log("Reflected Light Level: ");
13+
console.log(" level : ", reflected.level);
14+
console.log("-----------------");
1315
});
1416
});

eg/light-reflected-EVS_NXT.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ const { Board, Light } = require("../lib/johnny-five");
22
const board = new Board();
33

44
board.on("ready", () => {
5-
const reflect = new Light({
5+
const reflected = new Light({
66
controller: "EVS_NXT",
77
pin: "BBS1",
88
mode: "reflected"
99
});
1010

11-
reflect.on("change", (data) => {
12-
console.log("Light Reflection Level: ", data.level);
11+
reflected.on("change", () => {
12+
console.log("Reflected Light Level: ");
13+
console.log(" level : ", reflected.level);
14+
console.log("-----------------");
1315
});
1416
});

0 commit comments

Comments
 (0)