Skip to content

Commit

Permalink
Examples: more updates, 2
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Jun 12, 2020
1 parent 0aaa7ec commit c81033f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 52 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ To get you up and running quickly, we provide a variety of examples for using ea

To interactively navigate the examples, visit the [Johnny-Five examples](http://johnny-five.io/examples/) page on the official website. If you want to link directly to the examples in this repo, you can use one of the following links.

**There are presently 363 example programs with code and diagrams!**
**There are presently 362 example programs with code and diagrams!**

<!--extract-start:examples-->

Expand Down Expand Up @@ -549,7 +549,6 @@ To interactively navigate the examples, visit the [Johnny-Five examples](http://
- [Wii Nunchuck](https://github.com/rwaldron/johnny-five/blob/master/docs/nunchuk.md)

### Complete Bots / Projects
- [BOE Bot](https://github.com/rwaldron/johnny-five/blob/master/docs/boe-test-servos.md)
- [Bug](https://github.com/rwaldron/johnny-five/blob/master/docs/bug.md)
- [Kinect Robotic Arm Controller](https://github.com/rwaldron/johnny-five/blob/master/docs/kinect-arm-controller.md)
- [Laser Trip Wire](https://github.com/rwaldron/johnny-five/blob/master/docs/laser-trip-wire.md)
Expand Down
8 changes: 4 additions & 4 deletions docs/custom-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ node eg/custom-properties.js


```javascript
var five = require("../");
var board = new five.Board();
const { Board, Sensor } = require("../");
const board = new Board();

board.on("ready", function() {
board.on("ready", () => {
// The "custom" property is available
// to all component class constructors
var sensor = new five.Sensor({
const sensor = new Sensor({
pin: "A0",
custom: {
a: 1,
Expand Down
19 changes: 9 additions & 10 deletions docs/led-chars-demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ node eg/led-chars-demo.js


```javascript
var five = require("johnny-five");
const { Board, Led } = require("johnny-five");
const board = new Board();

var board = new five.Board();
board.on("ready", () => {

board.on("ready", function() {

var matrix = new five.Led.Matrix({
const matrix = new Led.Matrix({
pins: {
data: 2,
clock: 3,
Expand All @@ -47,11 +46,11 @@ board.on("ready", function() {

matrix.on();

// type `draw("shape_name")` into the repl to see the shape!
this.repl.inject({
matrix: matrix,
draw: function(shape) {
matrix.draw(five.Led.Matrix.CHARS[shape]);
// type `draw("shape_name")` into the repl to see the shape!
board.repl.inject({
matrix,
draw(shape) {
matrix.draw(Led.Matrix.CHARS[shape]);
}
});
});
Expand Down
24 changes: 11 additions & 13 deletions docs/led-enumeratechars.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ node eg/led-enumeratechars.js


```javascript
var five = require("johnny-five");
const { Board, Led } = require("johnny-five");
const board = new Board();

var board = new five.Board();
board.on("ready", () => {

board.on("ready", function() {

var matrix = new five.Led.Matrix({
const matrix = new Led.Matrix({
pins: {
data: 2,
clock: 3,
Expand All @@ -47,13 +46,12 @@ board.on("ready", function() {

matrix.on();

var shapes = Object.keys(five.Led.Matrix.CHARS);

var enumerate = function() {
var i = 0;
board.loop(500, function() {
const shapes = Object.keys(Led.Matrix.CHARS);
const enumerate = () => {
let i = 0;
board.loop(500, () => {
if (i < shapes.length) {
matrix.draw(five.Led.Matrix.CHARS[shapes[i]]);
matrix.draw(Led.Matrix.CHARS[shapes[i]]);
i++;
}
});
Expand All @@ -62,8 +60,8 @@ board.on("ready", function() {
enumerate();

this.repl.inject({
matrix: matrix,
enumerate: enumerate
matrix,
enumerate
});
});

Expand Down
19 changes: 9 additions & 10 deletions eg/led-chars-demo.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
var five = require("../lib/johnny-five");
const { Board, Led } = require("../lib/johnny-five");
const board = new Board();

var board = new five.Board();
board.on("ready", () => {

board.on("ready", function() {

var matrix = new five.Led.Matrix({
const matrix = new Led.Matrix({
pins: {
data: 2,
clock: 3,
Expand All @@ -14,11 +13,11 @@ board.on("ready", function() {

matrix.on();

// type `draw("shape_name")` into the repl to see the shape!
this.repl.inject({
matrix: matrix,
draw: function(shape) {
matrix.draw(five.Led.Matrix.CHARS[shape]);
// type `draw("shape_name")` into the repl to see the shape!
board.repl.inject({
matrix,
draw(shape) {
matrix.draw(Led.Matrix.CHARS[shape]);
}
});
});
24 changes: 11 additions & 13 deletions eg/led-enumeratechars.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
var five = require("../lib/johnny-five");
const { Board, Led } = require("../lib/johnny-five");
const board = new Board();

var board = new five.Board();
board.on("ready", () => {

board.on("ready", function() {

var matrix = new five.Led.Matrix({
const matrix = new Led.Matrix({
pins: {
data: 2,
clock: 3,
Expand All @@ -14,13 +13,12 @@ board.on("ready", function() {

matrix.on();

var shapes = Object.keys(five.Led.Matrix.CHARS);

var enumerate = function() {
var i = 0;
board.loop(500, function() {
const shapes = Object.keys(Led.Matrix.CHARS);
const enumerate = () => {
let i = 0;
board.loop(500, () => {
if (i < shapes.length) {
matrix.draw(five.Led.Matrix.CHARS[shapes[i]]);
matrix.draw(Led.Matrix.CHARS[shapes[i]]);
i++;
}
});
Expand All @@ -29,7 +27,7 @@ board.on("ready", function() {
enumerate();

this.repl.inject({
matrix: matrix,
enumerate: enumerate
matrix,
enumerate
});
});

0 comments on commit c81033f

Please sign in to comment.