Skip to content

Commit

Permalink
Examples: make Thermometer example output consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Sep 10, 2019
1 parent 4af585a commit 9dccdc3
Show file tree
Hide file tree
Showing 20 changed files with 140 additions and 85 deletions.
11 changes: 6 additions & 5 deletions eg/temperature-BMP180.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`Thermometer
celsius : ${thermometer.celsius}
fahrenheit : ${thermometer.fahrenheit}
kelvin : ${thermometer.kelvin}
--------------------------------------`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});
11 changes: 6 additions & 5 deletions eg/temperature-DHT11_I2C_NANO_BACKPACK.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`Thermometer
celsius : ${thermometer.celsius}
fahrenheit : ${thermometer.fahrenheit}
kelvin : ${thermometer.kelvin}
--------------------------------------`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

11 changes: 6 additions & 5 deletions eg/temperature-DHT21_I2C_NANO_BACKPACK.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`Thermometer");
celsius : ${thermometer.celsius}
fahrenheit : ${thermometer.fahrenheit}
kelvin : ${thermometer.kelvin}
--------------------------------------`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

11 changes: 6 additions & 5 deletions eg/temperature-DHT22_I2C_NANO_BACKPACK.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`Thermometer
celsius : ${thermometer.celsius}
fahrenheit : ${thermometer.fahrenheit}
kelvin : ${thermometer.kelvin}
--------------------------------------`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

11 changes: 6 additions & 5 deletions eg/temperature-HIH6130.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`Thermometer
celsius : ${thermometer.celsius}
fahrenheit : ${thermometer.fahrenheit}
kelvin : ${thermometer.kelvin}
--------------------------------------`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

11 changes: 6 additions & 5 deletions eg/temperature-MCP9808.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`Thermometer
celsius : ${thermometer.celsius}
fahrenheit : ${thermometer.fahrenheit}
kelvin : ${thermometer.kelvin}
--------------------------------------`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});
11 changes: 6 additions & 5 deletions eg/temperature-MS5611.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`Thermometer
celsius : ${thermometer.celsius}
fahrenheit : ${thermometer.fahrenheit}
kelvin : ${thermometer.kelvin}
--------------------------------------`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});
12 changes: 9 additions & 3 deletions eg/temperature-SI7020.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ const board = new Board({
});

board.on("ready", () => {
const temp = new Thermometer({
const thermometer = new Thermometer({
controller: "SI7020",
port: "A"
});

temp.on("change", () => {
console.log(`${temp.celsius}°C ${temp.fahrenheit}°F`);
thermometer.on("change", () => {
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

12 changes: 9 additions & 3 deletions eg/temperature-SI7021.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ const board = new Board({
});

board.on("ready", () => {
const temp = new Thermometer({
const thermometer = new Thermometer({
controller: "SI7021",
port: "A"
});

temp.on("change", () => {
console.log(`${temp.celsius}°C ${temp.fahrenheit}°F`);
thermometer.on("change", () => {
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

12 changes: 7 additions & 5 deletions eg/temperature-TH02.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`Thermometer
celsius : ${thermometer.celsius}
fahrenheit : ${thermometer.fahrenheit}
kelvin : ${thermometer.kelvin}
--------------------------------------`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

15 changes: 8 additions & 7 deletions eg/temperature-bmp085.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ const {Board, Thermometer} = require("../lib/johnny-five");
const board = new Board();

board.on("ready", () => {
const temp = new Thermometer({
const thermometer = new Thermometer({
controller: "BMP085"
});

temp.on("change", () => {
console.log(`Thermometer
celsius : ${temp.celsius}
fahrenheit : ${temp.fahrenheit}
kelvin : ${temp.kelvin}
--------------------------------------`);
thermometer.on("change", () => {
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});
8 changes: 6 additions & 2 deletions eg/temperature-ds18b20.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`${thermometer.celsius}°C`);
// console.log("0x" + this.address.toString(16));
const {address, celsius, fahrenheit, kelvin} = thermometer;
console.log(`Thermometer at address: 0x${address.toString(16)}`);
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

Expand Down
15 changes: 12 additions & 3 deletions eg/temperature-dual-ds18b20.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,22 @@ board.on("ready", () => {
address: 0x6893a41
});


thermometerA.on("change", () => {
console.log(`A ${thermometerA.celsius}°C`);
const {address, celsius, fahrenheit, kelvin} = thermometerA;
console.log(`Thermometer A at address: 0x${address.toString(16)}`);
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});

thermometerB.on("change", () => {
console.log(`B ${thermometerB.celsius}°C`);
const {address, celsius, fahrenheit, kelvin} = thermometerB;
console.log(`Thermometer B at address: 0x${address.toString(16)}`);
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

Expand Down
7 changes: 6 additions & 1 deletion eg/temperature-htu21d.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`${thermometer.celsius}°C ${thermometer.fahrenheit}°F`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

Expand Down
7 changes: 6 additions & 1 deletion eg/temperature-lm335.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`${thermometer.celsius}°C ${thermometer.fahrenheit}°F`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

Expand Down
11 changes: 8 additions & 3 deletions eg/temperature-lm35.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ const {Board, Thermometer} = require("../lib/johnny-five");
const board = new Board();

board().on("ready", () => {
const temperature = new Thermometer({
const thermometer = new Thermometer({
controller: "LM35",
pin: "A0"
});

temperature.on("change", () => {
console.log(`${temperature.celsius}°C ${temperature.fahrenheit}°F`);
thermometer.on("change", () => {
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

Expand Down
15 changes: 8 additions & 7 deletions eg/temperature-max31850k.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ const board = new Board();

board.on("ready", () => {
// This requires OneWire support using the ConfigurableFirmata
const temperature = new Thermometer({
const thermometer = new Thermometer({
controller: "MAX31850K",
pin: 2
});

temperature.on("change", () => {
console.log(`temperature at address: 0x${temperature.address.toString(16)}
celsius : ${temperature.celsius}
fahrenheit : ${temperature.fahrenheit}
kelvin : ${temperature.kelvin}
--------------------------------------`);
thermometer.on("change", () => {
const {address, celsius, fahrenheit, kelvin} = thermometer;
console.log(`Thermometer at address: 0x${address.toString(16)}`);
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

Expand Down
12 changes: 7 additions & 5 deletions eg/temperature-mpl115a2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`Thermometer
celsius : ${thermometer.celsius}
fahrenheit : ${thermometer.fahrenheit}
kelvin : ${thermometer.kelvin}
--------------------------------------`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});


/* @markdown
- [MPL115A2 - I2C Barometric Pressure/Temperature Sensor](https://www.adafruit.com/product/992)
@markdown */
11 changes: 6 additions & 5 deletions eg/temperature-mpl3115a2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`Thermometer
celsius : ${thermometer.celsius}
fahrenheit : ${thermometer.fahrenheit}
kelvin : ${thermometer.kelvin}
--------------------------------------`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

Expand Down
11 changes: 6 additions & 5 deletions eg/temperature-mpu6050.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ board.on("ready", () => {
});

thermometer.on("change", () => {
console.log(`Thermometer
celsius : ${thermometer.celsius}
fahrenheit : ${thermometer.fahrenheit}
kelvin : ${thermometer.kelvin}
--------------------------------------`);
const {celsius, fahrenheit, kelvin} = thermometer;
console.log("Thermometer");
console.log(" celsius : ", celsius);
console.log(" fahrenheit : ", fahrenheit);
console.log(" kelvin : ", kelvin);
console.log("--------------------------------------");
});
});

Expand Down

0 comments on commit 9dccdc3

Please sign in to comment.