Skip to content

Commit

Permalink
Examples: just some nit picking
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Jul 8, 2015
1 parent f13f78f commit e1dc526
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 170 deletions.
8 changes: 4 additions & 4 deletions docs/led-rgb-anode-PCA9685.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 26 additions & 19 deletions docs/led-rgb-intensity.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,47 @@ node eg/led-rgb-intensity.js


```javascript
var temporal = require("temporal");

This comment has been minimized.

Copy link
@Resseguie

Resseguie Jul 10, 2015

Collaborator

Ok, good. I started to do this in the first place but wasn't sure which was more obvious for a simple example.

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);

}
},
]);
});

```


Expand Down
2 changes: 1 addition & 1 deletion docs/motor-PCA9685.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
60 changes: 1 addition & 59 deletions docs/servo-PCA9685.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```


Expand Down
6 changes: 3 additions & 3 deletions eg/led-rgb-PCA9685.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions eg/led-rgb-anode-PCA9685.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
46 changes: 26 additions & 20 deletions eg/led-rgb-intensity.js
Original file line number Diff line number Diff line change
@@ -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);

This comment has been minimized.

Copy link
@derekwheee

derekwheee Jul 10, 2015

Collaborator

@rwaldron Methinks this is not quite the task you meant to write :)

This comment has been minimized.

Copy link
@rwaldron

rwaldron Jul 10, 2015

Author Owner

nope, not at all! copy pasta!!

This comment has been minimized.

Copy link
@rwaldron

rwaldron Jul 10, 2015

Author Owner

What the hell would I do without you all??

}
},
{
// Another 3 seconds, go full intensity blue
setTimeout(function() {
wait: 3000,
task: function() {
console.log("100% blue");
led.intensity(100);
}, 3000);

}, 3000);

}, 3000);

});
}
},
]);
});
2 changes: 1 addition & 1 deletion eg/motor-PCA9685.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
60 changes: 1 addition & 59 deletions eg/servo-PCA9685.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e1dc526

Please sign in to comment.