Skip to content

Commit

Permalink
Remove bogus null arguments from emitters. Fixes gh-561
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Oct 20, 2015
1 parent 5868321 commit abb2f3a
Show file tree
Hide file tree
Showing 57 changed files with 256 additions and 307 deletions.
2 changes: 1 addition & 1 deletion docs/accelerometer-pan-tilt.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ board.on("ready", function() {
// Center all servos
(five.Servos()).center();

accel.on("acceleration", function(err, timestamp) {
accel.on("acceleration", function() {
// console.log( "acceleration", this.axis );

tilt.to(Math.abs(Math.ceil(170 * this.pitch.toFixed(2)) - 180));
Expand Down
6 changes: 3 additions & 3 deletions docs/classic-controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ board.on("ready", function() {
// Fired when the joystick detects a change in
// axis position.
//
nunchuk.joystick.left.on("change", function(err, event) {
nunchuk.joystick.left.on("change", function(event) {
console.log(
"Left joystick " + event.axis,
event.target[event.axis],
event.axis, event.direction
);
});

nunchuk.joystick.right.on("change", function(err, event) {
nunchuk.joystick.right.on("change", function(event) {
console.log(
"Right joystick " + event.axis,
event.target[event.axis],
Expand Down Expand Up @@ -98,7 +98,7 @@ board.on("ready", function() {

["down", "up", "hold"].forEach(function(type) {

nunchuk.on(type, function(err, event) {
nunchuk.on(type, function(event) {
console.log(
event.target.which + " is " + type,

Expand Down
6 changes: 3 additions & 3 deletions docs/ir-motion.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ board.on("ready", function() {

// "calibrated" occurs once, at the beginning of a session,
motion.on("calibrated", function() {
console.log("calibrated");
console.log("calibrated", Date.now());
});

// "motionstart" events are fired when the "calibrated"
// proximal area is disrupted, generally by some form of movement
motion.on("motionstart", function() {
console.log("motionstart");
console.log("motionstart", Date.now());
});

// "motionend" events are fired following a "motionstart" event
// when no movement has occurred in X ms
motion.on("motionend", function() {
console.log("motionend");
console.log("motionend", Date.now());
});
});

Expand Down
4 changes: 2 additions & 2 deletions docs/ir-reflect-array.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ five.Board().on("ready", function() {

// calibrate for two seconds
eyes.calibrateUntil(function() { return !calibrating; });
setTimeout(function() { calibrating = false; }, 2000);
setTimeout(function() { calibrating = false; }, 2000);

eyes.enable();

// "line"
//
// Fires continuously once calibrated
//
eyes.on("line", function(err, line) {
eyes.on("line", function(line) {
console.log("line: ", line);
});
});
Expand Down
2 changes: 1 addition & 1 deletion docs/ir-reflect.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ five.Board().on("ready", function() {
//
// Fires continuously, every 66ms.
//
ir.on("data", function(err, timestamp) {
ir.on("data", function() {
console.log("data");
});
});
Expand Down
2 changes: 1 addition & 1 deletion docs/joystick-motor-led.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ board.on("ready", function() {

// Pushing the joystick to up position should start the motor,
// releasing it will turn the motor off.
joystick.on("axismove", function(err, timestamp) {
joystick.on("axismove", function() {

if (!motor.isOn && this.axis.y > 0.51) {
motor.start();
Expand Down
24 changes: 12 additions & 12 deletions docs/motor-3-pin.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ board.on("ready", function() {
pwm: 9
dir: 8
cdir: 11
Motor B
pwm: 10
dir: 12
Expand All @@ -51,7 +51,7 @@ board.on("ready", function() {
pwm: 6
dir: 5
cdir: 7
Motor B
pwm: 4
dir: 3
Expand All @@ -75,29 +75,29 @@ board.on("ready", function() {
motor: motor
});

motor.on("start", function(err, timestamp) {
console.log("start", timestamp);
motor.on("start", function() {
console.log("start", Date.now());
});

motor.on("stop", function(err, timestamp) {
console.log("automated stop on timer", timestamp);
motor.on("stop", function() {
console.log("automated stop on timer", Date.now());
});

motor.on("brake", function(err, timestamp) {
console.log("automated brake on timer", timestamp);
motor.on("brake", function() {
console.log("automated brake on timer", Date.now());
});

motor.on("forward", function(err, timestamp) {
console.log("forward", timestamp);
motor.on("forward", function() {
console.log("forward", Date.now());

// demonstrate switching to reverse after 5 seconds
board.wait(5000, function() {
motor.reverse(255);
});
});

motor.on("reverse", function(err, timestamp) {
console.log("reverse", timestamp);
motor.on("reverse", function() {
console.log("reverse", Date.now());

// demonstrate braking after 5 seconds
board.wait(5000, function() {
Expand Down
4 changes: 2 additions & 2 deletions docs/motor-PCA9685.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ board.on("ready", function() {

// "start" events fire when the motor is started.
motor.on("start", function() {
console.log("start");
console.log("start", Date.now());

// Demonstrate motor stop in 2 seconds
board.wait(2000, function() {
Expand All @@ -57,7 +57,7 @@ board.on("ready", function() {

// "stop" events fire when the motor is started.
motor.on("stop", function() {
console.log("stop");
console.log("stop", Date.now());
});

// Motor API
Expand Down
10 changes: 5 additions & 5 deletions docs/motor-brake.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ board.on("ready", function() {
});

motor.on("start", function() {
console.log("start");
console.log("start", Date.now());
});

motor.on("stop", function() {
console.log("automated stop on timer");
console.log("automated stop on timer", Date.now());
});

motor.on("brake", function() {
console.log("automated brake on timer");
console.log("automated brake on timer", Date.now());
});

motor.on("forward", function() {
console.log("forward");
console.log("forward", Date.now());

// demonstrate switching to reverse after 5 seconds
board.wait(5000, function() {
Expand All @@ -82,7 +82,7 @@ board.on("ready", function() {
});

motor.on("reverse", function() {
console.log("reverse");
console.log("reverse", Date.now());

// demonstrate stopping after 5 seconds
board.wait(5000, function() {
Expand Down
10 changes: 5 additions & 5 deletions docs/motor-current.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,19 @@ board.on("ready", function() {
});

motor.on("start", function() {
console.log("start");
console.log("start", Date.now());
});

motor.on("stop", function() {
console.log("automated stop on timer");
console.log("automated stop on timer", Date.now());
});

motor.on("brake", function() {
console.log("automated brake on timer");
console.log("automated brake on timer", Date.now());
});

motor.on("forward", function() {
console.log("forward");
console.log("forward", Date.now());

// demonstrate switching to reverse after 5 seconds
board.wait(5000, function() {
Expand All @@ -95,7 +95,7 @@ board.on("ready", function() {
});

motor.on("reverse", function() {
console.log("reverse");
console.log("reverse", Date.now());

// demonstrate stopping after 5 seconds
board.wait(5000, function() {
Expand Down
8 changes: 4 additions & 4 deletions docs/motor-directional.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ board.on("ready", function() {
});

motor.on("start", function() {
console.log("start");
console.log("start", Date.now());
});

motor.on("stop", function() {
console.log("automated stop on timer");
console.log("automated stop on timer", Date.now());
});

motor.on("forward", function() {
console.log("forward");
console.log("forward", Date.now());

// demonstrate switching to reverse after 5 seconds
board.wait(5000, function() {
Expand All @@ -109,7 +109,7 @@ board.on("ready", function() {
});

motor.on("reverse", function() {
console.log("reverse");
console.log("reverse", Date.now());

// demonstrate stopping after 5 seconds
board.wait(5000, function() {
Expand Down
8 changes: 4 additions & 4 deletions docs/motor-hbridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ board.on("ready", function() {
});

motor.on("start", function() {
console.log("start");
console.log("start", Date.now());
});

motor.on("stop", function() {
console.log("automated stop on timer");
console.log("automated stop on timer", Date.now());
});

motor.on("forward", function() {
console.log("forward");
console.log("forward", Date.now());

// demonstrate switching to reverse after 5 seconds
board.wait(5000, function() {
Expand All @@ -82,7 +82,7 @@ board.on("ready", function() {
});

motor.on("reverse", function() {
console.log("reverse");
console.log("reverse", Date.now());

// demonstrate stopping after 5 seconds
board.wait(5000, function() {
Expand Down
4 changes: 2 additions & 2 deletions docs/motor.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ board.on("ready", function() {

// "start" events fire when the motor is started.
motor.on("start", function() {
console.log("start");
console.log("start", Date.now());

// Demonstrate motor stop in 2 seconds
board.wait(2000, function() {
Expand All @@ -61,7 +61,7 @@ board.on("ready", function() {

// "stop" events fire when the motor is stopped.
motor.on("stop", function() {
console.log("stop");
console.log("stop", Date.now());
});

// Motor API
Expand Down
2 changes: 1 addition & 1 deletion docs/navigator.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ Navigator.prototype.pivot = function(which, time) {
// distance reading has changed since the previous reading
//
// TODO: Avoid false positives?
ping.on("data", function(err) {
ping.on("data", function() {
var release = 750,
distance = Math.abs(this.inches),
isReverse = false,
Expand Down
6 changes: 3 additions & 3 deletions docs/nunchuk.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ board.on("ready", function() {
// Fired when the joystick detects a change in
// axis position.
//
nunchuk.joystick.on("change", function(err, event) {
nunchuk.joystick.on("change", function(event) {
console.log(
"joystick " + event.axis,
event.target[event.axis],
Expand All @@ -68,7 +68,7 @@ board.on("ready", function() {
// Fired when the accelerometer detects a change in
// axis position.
//
nunchuk.accelerometer.on("change", function(err, event) {
nunchuk.accelerometer.on("change", function(event) {
console.log(
"accelerometer " + event.axis,
event.target[event.axis],
Expand Down Expand Up @@ -100,7 +100,7 @@ board.on("ready", function() {

["down", "up", "hold"].forEach(function(type) {

nunchuk.on(type, function(err, event) {
nunchuk.on(type, function(event) {
console.log(
event.target.which + " is " + type,

Expand Down
1 change: 0 additions & 1 deletion docs/ping.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ board.on("ready", function() {
// Calculated distance to object in centimeters
//


ping.on("change", function() {
console.log("Object is " + this.in + " inches away");
});
Expand Down
28 changes: 7 additions & 21 deletions docs/servo-slider.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,18 @@ node eg/servo-slider.js


```javascript
var five = require("johnny-five"),
board, slider, servo, scalingRange;

board = new five.Board();
var five = require("johnny-five");
var board = new five.Board();

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

scalingRange = [0, 170];

slider = new five.Sensor({
pin: "A0",
freq: 50
});

servo = new five.Servo({
pin: 10,
range: scalingRange
});


// The slider's value will be scaled to match the servo's movement range

slider.scale(scalingRange).on("slide", function(err, value) {
var slider = new five.Sensor("A0");
var tilt = new five.Servo(9);

servo.to(Math.floor(this.value));
slider.scale([0, 180]).on("slide", function() {

// The slider's value will be scaled to match the tilt servo range
tilt.to(this.value);
});
});

Expand Down
Loading

0 comments on commit abb2f3a

Please sign in to comment.