Skip to content

Commit

Permalink
Merge 6191ec8 into b988b27
Browse files Browse the repository at this point in the history
  • Loading branch information
dtex authored Sep 11, 2019
2 parents b988b27 + 6191ec8 commit 01321da
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 88 deletions.
19 changes: 9 additions & 10 deletions docs/shift-register-daisy-chain-anode.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@ node eg/shift-register-daisy-chain-anode.js


```javascript
var five = require("johnny-five");
var async = require("async");
var _ = require("lodash");
var board = new five.Board();
const {Board, Button, ShiftRegister} = require("johnny-five");
const {eachSeries} = require("async");
const board = new Board();

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

/**
* While we may have multiple ShiftRegisters,
* we only need one to control them both.
*/
var register = new five.ShiftRegister({
const register = new ShiftRegister({
isAnode: true,
size: 2,
pins: {
Expand All @@ -54,7 +53,7 @@ board.on("ready", function() {
/**
* Pressing this button will trigger the die roll.
*/
var button = new five.Button(8);
var button = new Button(8);

/**
* Sends a random number to the shift register.
Expand All @@ -79,12 +78,12 @@ board.on("ready", function() {
register.reset();
register.clear();

button.on("press", function() {
button.on("press", () => {
console.log("Rolling...");
register.clear();
async.eachSeries(delays, function(delay, done) {
eachSeries(delays, (delay, done) => {
randomNumber();
setTimeout(function() {
setTimeout(() => {
register.clear();
done();
}, delay);
Expand Down
21 changes: 10 additions & 11 deletions docs/shift-register-daisy-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@ node eg/shift-register-daisy-chain.js


```javascript
var five = require("johnny-five");
var async = require("async");
var _ = require("lodash");
var board = new five.Board();
const {Board, Button, ShiftRegister} = require("johnny-five");
const {eachSeries} = require("async");
const board = new Board();

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

/**
* While we may have multiple ShiftRegisters,
* we only need one to control them both.
*/
var register = new five.ShiftRegister({
const register = new ShiftRegister({
size: 2,
pins: {
data: 2,
Expand All @@ -53,7 +52,7 @@ board.on("ready", function() {
/**
* Pressing this button will trigger the die roll.
*/
var button = new five.Button(8);
const button = new Button(8);

/**
* Sends a random number to the shift register.
Expand All @@ -69,7 +68,7 @@ board.on("ready", function() {
* we'll iterate over this array and display a random number after the
* delay. This simulates a die bouncing on a table.
*/
var delays = new Array(10).fill(16)
const delays = new Array(10).fill(16)
.concat(new Array(8).fill(32))
.concat(new Array(6).fill(64))
.concat(new Array(4).fill(128))
Expand All @@ -79,12 +78,12 @@ board.on("ready", function() {
register.reset();
register.clear();

button.on("press", function() {
button.on("press", () => {
console.log("Rolling...");
register.clear();
async.eachSeries(delays, function(delay, done) {
eachSeries(delays, (delay, done) => {
randomNumber();
setTimeout(function() {
setTimeout(() => {
register.clear();
done();
}, delay);
Expand Down
14 changes: 7 additions & 7 deletions docs/shift-register-seven-segment-anode.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ node eg/shift-register-seven-segment-anode.js


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

board.on("ready", function() {
var register = new five.ShiftRegister({
board.on("ready", () => {
const register = new ShiftRegister({
isAnode: true,
pins: {
data: 2,
Expand All @@ -42,15 +42,15 @@ board.on("ready", function() {
reset: 9,
}
});
var number = 0;
var decimal = 0;
let number = 0;
let decimal = 0;

register.reset();

// Display numbers 0-9, one at a time in a loop.
// Shows just the number for a half second, then
// the number + a decimal point for a half second.
setInterval(function() {
setInterval(() => {
register.display(number + (decimal && "."));

if (decimal) {
Expand Down
14 changes: 7 additions & 7 deletions docs/shift-register-seven-segment.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@ node eg/shift-register-seven-segment.js


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

board.on("ready", function() {
var register = new five.ShiftRegister({
board.on("ready", () => {
const register = new ShiftRegister({
pins: {
data: 2,
clock: 3,
latch: 4,
}
});
var number = 0;
var decimal = 0;
let number = 0;
let decimal = 0;

// Display numbers 0-9, one at a time in a loop.
// Shows just the number for a half second, then
// the number + a decimal point for a half second.
setInterval(function() {
setInterval(() => {
register.display(number + (decimal && "."));

if (decimal) {
Expand Down
12 changes: 6 additions & 6 deletions docs/shift-register.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ node eg/shift-register.js


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

// For use with 74HC595 chip

board.on("ready", function() {
var register = new five.ShiftRegister({
board.on("ready", () => {
const register = new ShiftRegister({
pins: {
data: 2,
clock: 3,
latch: 4
}
});

var value = 0;
let value = 0;

setInterval(function() {
setInterval(() => {
value = value > 0x11 ? value >> 1 : 0x88;
register.send(value);
}, 200);
Expand Down
2 changes: 1 addition & 1 deletion eg/.jshintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"esversion": 6,
"curly": true,
"eqeqeq": true,
"immed": true,
Expand All @@ -11,7 +12,6 @@
"eqnull": true,
"node": true,
"strict": false,
"esnext": true,
"quotmark": "double",
"globals": {
"exports": true,
Expand Down
19 changes: 9 additions & 10 deletions eg/shift-register-daisy-chain-anode.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
var five = require("../lib/johnny-five.js");
var async = require("async");
var _ = require("lodash");
var board = new five.Board();
const {Board, Button, ShiftRegister} = require("../lib/johnny-five.js");
const {eachSeries} = require("async");
const board = new Board();

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

/**
* While we may have multiple ShiftRegisters,
* we only need one to control them both.
*/
var register = new five.ShiftRegister({
const register = new ShiftRegister({
isAnode: true,
size: 2,
pins: {
Expand All @@ -23,7 +22,7 @@ board.on("ready", function() {
/**
* Pressing this button will trigger the die roll.
*/
var button = new five.Button(8);
var button = new Button(8);

/**
* Sends a random number to the shift register.
Expand All @@ -48,12 +47,12 @@ board.on("ready", function() {
register.reset();
register.clear();

button.on("press", function() {
button.on("press", () => {
console.log("Rolling...");
register.clear();
async.eachSeries(delays, function(delay, done) {
eachSeries(delays, (delay, done) => {
randomNumber();
setTimeout(function() {
setTimeout(() => {
register.clear();
done();
}, delay);
Expand Down
21 changes: 10 additions & 11 deletions eg/shift-register-daisy-chain.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
var five = require("../lib/johnny-five.js");
var async = require("async");
var _ = require("lodash");
var board = new five.Board();
const {Board, Button, ShiftRegister} = require("../lib/johnny-five.js");
const {eachSeries} = require("async");
const board = new Board();

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

/**
* While we may have multiple ShiftRegisters,
* we only need one to control them both.
*/
var register = new five.ShiftRegister({
const register = new ShiftRegister({
size: 2,
pins: {
data: 2,
Expand All @@ -22,7 +21,7 @@ board.on("ready", function() {
/**
* Pressing this button will trigger the die roll.
*/
var button = new five.Button(8);
const button = new Button(8);

/**
* Sends a random number to the shift register.
Expand All @@ -38,7 +37,7 @@ board.on("ready", function() {
* we'll iterate over this array and display a random number after the
* delay. This simulates a die bouncing on a table.
*/
var delays = new Array(10).fill(16)
const delays = new Array(10).fill(16)
.concat(new Array(8).fill(32))
.concat(new Array(6).fill(64))
.concat(new Array(4).fill(128))
Expand All @@ -48,12 +47,12 @@ board.on("ready", function() {
register.reset();
register.clear();

button.on("press", function() {
button.on("press", () => {
console.log("Rolling...");
register.clear();
async.eachSeries(delays, function(delay, done) {
eachSeries(delays, (delay, done) => {
randomNumber();
setTimeout(function() {
setTimeout(() => {
register.clear();
done();
}, delay);
Expand Down
14 changes: 7 additions & 7 deletions eg/shift-register-seven-segment-anode.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var five = require("../lib/johnny-five.js");
var board = new five.Board();
const {Board, ShiftRegister} = require("../lib/johnny-five.js");
const board = new Board();

board.on("ready", function() {
var register = new five.ShiftRegister({
board.on("ready", () => {
const register = new ShiftRegister({
isAnode: true,
pins: {
data: 2,
Expand All @@ -11,15 +11,15 @@ board.on("ready", function() {
reset: 9,
}
});
var number = 0;
var decimal = 0;
let number = 0;
let decimal = 0;

register.reset();

// Display numbers 0-9, one at a time in a loop.
// Shows just the number for a half second, then
// the number + a decimal point for a half second.
setInterval(function() {
setInterval(() => {
register.display(number + (decimal && "."));

if (decimal) {
Expand Down
14 changes: 7 additions & 7 deletions eg/shift-register-seven-segment.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
var five = require("../lib/johnny-five.js");
var board = new five.Board();
const {Board, ShiftRegister} = require("../lib/johnny-five.js");
const board = new Board();

board.on("ready", function() {
var register = new five.ShiftRegister({
board.on("ready", () => {
const register = new ShiftRegister({
pins: {
data: 2,
clock: 3,
latch: 4,
}
});
var number = 0;
var decimal = 0;
let number = 0;
let decimal = 0;

// Display numbers 0-9, one at a time in a loop.
// Shows just the number for a half second, then
// the number + a decimal point for a half second.
setInterval(function() {
setInterval(() => {
register.display(number + (decimal && "."));

if (decimal) {
Expand Down
Loading

0 comments on commit 01321da

Please sign in to comment.