diff --git a/docs/led-rgb-anode-PCA9685.md b/docs/led-rgb-anode-PCA9685.md index 5f783d87f..311d1eef3 100644 --- a/docs/led-rgb-anode-PCA9685.md +++ b/docs/led-rgb-anode-PCA9685.md @@ -32,19 +32,19 @@ node eg/led-rgb-anode-PCA9685.js ```javascript var five = require("johnny-five"); +var board = new five.Board(); - -five.Board().on("ready", function() { +board.on("ready", function() { // Initialize the RGB LED var led = new five.Led.RGB({ + controller: "PCA9685", + isAnode: true, pins: { red: 2, green: 1, blue: 0 }, - isAnode: true, - controller: "PCA9685" }); // RGB LED alternate constructor diff --git a/docs/led-rgb-intensity.md b/docs/led-rgb-intensity.md index 5be104614..990ef7c88 100644 --- a/docs/led-rgb-intensity.md +++ b/docs/led-rgb-intensity.md @@ -33,40 +33,47 @@ node eg/led-rgb-intensity.js ```javascript +var temporal = require("temporal"); var five = require("johnny-five"); var board = new five.Board(); board.on("ready", function() { // Initialize the RGB LED - var led = new five.Led.RGB([6,5,3]); + var led = new five.Led.RGB([6, 5, 3]); // Set to full intensity red console.log("100% red"); led.color("#FF0000"); - - // After 3 seconds, dim to 30% intensity - setTimeout(function() { - console.log("30% red"); - led.intensity(30); - - // 3 secs then turn blue, still 30% intensity - setTimeout(function() { - console.log("30% blue"); - led.color("#0000FF"); - + temporal.queue([ + { + // After 3 seconds, dim to 30% intensity + wait: 3000, + task: function() { + console.log("30% red"); + led.intensity(30); + } + }, + { + // 3 secs then turn blue, still 30% intensity + wait: 3000, + task: function() { + console.log("30% red"); + led.intensity(30); + } + }, + { // Another 3 seconds, go full intensity blue - setTimeout(function() { + wait: 3000, + task: function() { console.log("100% blue"); led.intensity(100); - }, 3000); - - }, 3000); - - }, 3000); - + } + }, + ]); }); + ``` diff --git a/docs/motor-PCA9685.md b/docs/motor-PCA9685.md index 19299608c..fe04d3c69 100644 --- a/docs/motor-PCA9685.md +++ b/docs/motor-PCA9685.md @@ -24,7 +24,7 @@ var five = require("johnny-five"), board = new five.Board(); /* - * The PCA9685 controller has been test on + * The PCA9685 controller has been tested on * the Adafruit Motor/Stepper/Servo Shield v2 */ diff --git a/docs/servo-PCA9685.md b/docs/servo-PCA9685.md index 172a07ed9..750a2f4ce 100644 --- a/docs/servo-PCA9685.md +++ b/docs/servo-PCA9685.md @@ -35,74 +35,16 @@ var board = new five.Board(); board.on("ready", function() { console.log("Connected"); - // Initialize the servo + // Initialize the servo instance var servo = new five.Servo({ address: 0x40, controller: "PCA9685", pin: 0, }); - // Add servo to REPL for live control (optional) - this.repl.inject({ - servo: servo - }); - - - // Servo API - - // min() - // - // set the servo to the minimum degrees - // defaults to 0 - // - // eg. servo.min(); - - // max() - // - // set the servo to the maximum degrees - // defaults to 180 - // - // eg. servo.max(); - - // center() - // - // centers the servo to 90° - // - // servo.center(); - - // to( deg[, duration] ) - // - // Moves the servo to position by degrees - // duration (optional) sets duration of movement. - // - // servo.to( 90 ); - - // step( deg ) - // - // Moves the servo step degrees relative to current position - // - // servo.step( -10 ); - - // sweep( obj ) - // - // Perform a min-max cycling servo sweep (defaults to 0-180) - // optionally accepts an object of sweep settings: - // { - // lapse: time in milliseconds to wait between moves - // defaults to 500ms - // degrees: distance in degrees to move - // defaults to 10° - // } - // servo.sweep(); - }); - -// References -// -// http://servocity.com/html/hs-7980th_servo.html - ``` diff --git a/eg/led-rgb-PCA9685.js b/eg/led-rgb-PCA9685.js index b275348e9..52001c18d 100644 --- a/eg/led-rgb-PCA9685.js +++ b/eg/led-rgb-PCA9685.js @@ -1,16 +1,16 @@ var five = require("../lib/johnny-five.js"); +var board = new five.Board(); - -five.Board().on("ready", function() { +board.on("ready", function() { // Initialize the RGB LED var led = new five.Led.RGB({ + controller: "PCA9685", pins: { red: 2, green: 1, blue: 0 }, - controller: "PCA9685" }); // RGB LED alternate constructor diff --git a/eg/led-rgb-anode-PCA9685.js b/eg/led-rgb-anode-PCA9685.js index 7a85371c3..0b549fb05 100644 --- a/eg/led-rgb-anode-PCA9685.js +++ b/eg/led-rgb-anode-PCA9685.js @@ -1,17 +1,17 @@ var five = require("../lib/johnny-five.js"); +var board = new five.Board(); - -five.Board().on("ready", function() { +board.on("ready", function() { // Initialize the RGB LED var led = new five.Led.RGB({ + controller: "PCA9685", + isAnode: true, pins: { red: 2, green: 1, blue: 0 }, - isAnode: true, - controller: "PCA9685" }); // RGB LED alternate constructor diff --git a/eg/led-rgb-intensity.js b/eg/led-rgb-intensity.js index 63032a722..960ecc037 100644 --- a/eg/led-rgb-intensity.js +++ b/eg/led-rgb-intensity.js @@ -1,34 +1,40 @@ +var temporal = require("temporal"); var five = require("../lib/johnny-five.js"); var board = new five.Board(); board.on("ready", function() { // Initialize the RGB LED - var led = new five.Led.RGB([6,5,3]); + var led = new five.Led.RGB([6, 5, 3]); // Set to full intensity red console.log("100% red"); led.color("#FF0000"); - - // After 3 seconds, dim to 30% intensity - setTimeout(function() { - console.log("30% red"); - led.intensity(30); - - // 3 secs then turn blue, still 30% intensity - setTimeout(function() { - console.log("30% blue"); - led.color("#0000FF"); - + temporal.queue([ + { + // After 3 seconds, dim to 30% intensity + wait: 3000, + task: function() { + console.log("30% red"); + led.intensity(30); + } + }, + { + // 3 secs then turn blue, still 30% intensity + wait: 3000, + task: function() { + console.log("30% red"); + led.intensity(30); + } + }, + { // Another 3 seconds, go full intensity blue - setTimeout(function() { + wait: 3000, + task: function() { console.log("100% blue"); led.intensity(100); - }, 3000); - - }, 3000); - - }, 3000); - -}); \ No newline at end of file + } + }, + ]); +}); diff --git a/eg/motor-PCA9685.js b/eg/motor-PCA9685.js index 0f10ad9ce..430851338 100644 --- a/eg/motor-PCA9685.js +++ b/eg/motor-PCA9685.js @@ -4,7 +4,7 @@ var five = require("../lib/johnny-five.js"), board = new five.Board(); /* - * The PCA9685 controller has been test on + * The PCA9685 controller has been tested on * the Adafruit Motor/Stepper/Servo Shield v2 */ diff --git a/eg/servo-PCA9685.js b/eg/servo-PCA9685.js index ebc3e325b..1eab319e7 100644 --- a/eg/servo-PCA9685.js +++ b/eg/servo-PCA9685.js @@ -4,70 +4,12 @@ var board = new five.Board(); board.on("ready", function() { console.log("Connected"); - // Initialize the servo + // Initialize the servo instance var servo = new five.Servo({ address: 0x40, controller: "PCA9685", pin: 0, }); - // Add servo to REPL for live control (optional) - this.repl.inject({ - servo: servo - }); - - - // Servo API - - // min() - // - // set the servo to the minimum degrees - // defaults to 0 - // - // eg. servo.min(); - - // max() - // - // set the servo to the maximum degrees - // defaults to 180 - // - // eg. servo.max(); - - // center() - // - // centers the servo to 90° - // - // servo.center(); - - // to( deg[, duration] ) - // - // Moves the servo to position by degrees - // duration (optional) sets duration of movement. - // - // servo.to( 90 ); - - // step( deg ) - // - // Moves the servo step degrees relative to current position - // - // servo.step( -10 ); - - // sweep( obj ) - // - // Perform a min-max cycling servo sweep (defaults to 0-180) - // optionally accepts an object of sweep settings: - // { - // lapse: time in milliseconds to wait between moves - // defaults to 500ms - // degrees: distance in degrees to move - // defaults to 10° - // } - // servo.sweep(); - }); - - -// References -// -// http://servocity.com/html/hs-7980th_servo.html