Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update generated servo example programs
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Dec 17, 2013
1 parent e95147c commit 11a7713
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 60 deletions.
4 changes: 2 additions & 2 deletions docs/accelerometer-pan-tilt.md
Expand Up @@ -42,8 +42,8 @@ board.on("ready", function() {
accel.on("acceleration", function(err, timestamp) {
// console.log( "acceleration", this.axis );

tilt.move(Math.abs(Math.ceil(170 * this.pitch.toFixed(2)) - 180));
pan.move(Math.ceil(170 * this.roll.toFixed(2)));
tilt.to(Math.abs(Math.ceil(170 * this.pitch.toFixed(2)) - 180));
pan.to(Math.ceil(170 * this.roll.toFixed(2)));

// TODO: Math.abs(v - 180) as inversion function ?
});
Expand Down
8 changes: 4 additions & 4 deletions docs/bug.md
Expand Up @@ -65,8 +65,8 @@ Bug.prototype.idle = function() {
}

// set to center position°
this.front.move(90);
this.rear.move(90);
this.front.to(90);
this.rear.to(90);

//return this;
};
Expand Down Expand Up @@ -111,8 +111,8 @@ Bug.prototype.step = function(opts) {
rear = 90 + move[1];

// Write position° to servos
this.front.move(front);
this.rear.move(rear);
this.front.to(front);
this.rear.to(rear);

// Allow half step or full if provided,
// defaults to full
Expand Down
4 changes: 2 additions & 2 deletions docs/claw.md
Expand Up @@ -38,10 +38,10 @@ board.on("ready", function() {
} else {
last = 90;
}
arm.move(last);
arm.to(last);
}

claw.move(degrees);
claw.to(degrees);
});
});

Expand Down
4 changes: 2 additions & 2 deletions docs/continuous-clock.md
Expand Up @@ -20,7 +20,7 @@ board.on("ready", function() {

].forEach(function(def) {
five.Servo.prototype[def[1]] = function() {
this.move(def[0]);
this.to(def[0]);
};
});

Expand All @@ -46,7 +46,7 @@ board.on("ready", function() {
// move( speed )
// Set the speed at which the continuous rotation
// servo will rotate at.
servo.move(90);
servo.to(90);

});

Expand Down
4 changes: 2 additions & 2 deletions docs/gripper.md
Expand Up @@ -22,10 +22,10 @@ var five = require("johnny-five"),


function slice() {
wrist.move(100);
wrist.to(100);

compulsive.wait(100, function() {
wrist.move(120);
wrist.to(120);
});
}

Expand Down
4 changes: 2 additions & 2 deletions docs/joystick-claw.md
Expand Up @@ -25,13 +25,13 @@ board.on("ready", function() {

// Set the claw degrees to half way
// (the joystick deadzone)
claw.move(90);
claw.to(90);

joystick.on("axismove", function() {
// Open/close the claw by setting degrees according
// to Y position of joystick.
// limit to 170 on medium servos (ei. the servo used on the claw)
claw.move(Math.ceil(170 * this.fixed.y));
claw.to(Math.ceil(170 * this.fixed.y));
});
});

Expand Down
4 changes: 2 additions & 2 deletions docs/joystick-laser.md
Expand Up @@ -42,8 +42,8 @@ board.on("ready", function() {

joystick.on("axismove", function() {

tilt.move(Math.ceil(170 * this.fixed.y));
pan.move(Math.ceil(170 * this.fixed.x));
tilt.to(Math.ceil(170 * this.fixed.y));
pan.to(Math.ceil(170 * this.fixed.x));

});
});
Expand Down
4 changes: 2 additions & 2 deletions docs/magnetometer-north.md
Expand Up @@ -26,7 +26,7 @@ board.on("ready", function() {

].forEach(function(def) {
five.Servo.prototype[def[1]] = function() {
this.move(def[0]);
this.to(def[0]);
};
});

Expand All @@ -50,7 +50,7 @@ board.on("ready", function() {
});

// set the continuous servo to stopped
servo.move(90);
servo.to(90);

// As the heading changes, log heading value
mag.on("data", function() {
Expand Down
18 changes: 9 additions & 9 deletions docs/navigator.md
Expand Up @@ -108,8 +108,8 @@ Navigator.prototype.move = function(right, left) {
// Servos are mounted opposite of each other,
// the values for left and right will be in
// opposing directions.
this.servos.right.move(right);
this.servos.left.move(left);
this.servos.right.to(right);
this.servos.left.to(left);

// Push a record object into the history
this.history.push({
Expand Down Expand Up @@ -182,7 +182,7 @@ Navigator.prototype.stop = function() {
this.speed = this.center;
this.which = "stop";

return this.move(this.center, this.center);
return this.to(this.center, this.center);
};


Expand Down Expand Up @@ -214,7 +214,7 @@ Navigator.prototype.stop = function() {
this.isTurning = true;

// Send turning command
this.move(actual, actual);
this.to(actual, actual);

// Cap turning time
setTimeout(function() {
Expand Down Expand Up @@ -268,16 +268,16 @@ Navigator.prototype.pivot = function(which, time) {

directions = {
"forward-right": function() {
this.move(this.center, scaled);
this.to(this.center, scaled);
},
"forward-left": function() {
this.move(this.center - (scaled - this.center), this.center);
this.to(this.center - (scaled - this.center), this.center);
},
"reverse-right": function() {
this.move(scaled, this.center);
this.to(scaled, this.center);
},
"reverse-left": function() {
this.move(this.center, this.center - (scaled - this.center));
this.to(this.center, this.center - (scaled - this.center));
}
};

Expand Down Expand Up @@ -433,7 +433,7 @@ Navigator.prototype.pivot = function(which, time) {
}


scanner.move(degrees);
scanner.to(degrees);
}
});

Expand Down
18 changes: 9 additions & 9 deletions docs/nodeconf-navigator.md
Expand Up @@ -105,8 +105,8 @@ Navigator.prototype.move = function(right, left) {
// Servos are mounted opposite of each other,
// the values for left and right will be in
// opposing directions.
this.servos.right.move(right);
this.servos.left.move(left);
this.servos.right.to(right);
this.servos.left.to(left);

// Push a record object into the history
this.history.push({
Expand Down Expand Up @@ -179,7 +179,7 @@ Navigator.prototype.stop = function() {
this.speed = this.center;
this.which = "stop";

return this.move(this.center, this.center);
return this.to(this.center, this.center);
};


Expand Down Expand Up @@ -209,7 +209,7 @@ Navigator.prototype.stop = function() {
this.isTurning = true;

// Send turning command
this.move(actual, actual);
this.to(actual, actual);

// Cap turning time
setTimeout(function() {
Expand Down Expand Up @@ -263,16 +263,16 @@ Navigator.prototype.pivot = function(which, time) {

directions = {
"forward-right": function() {
this.move(this.center, scaled);
this.to(this.center, scaled);
},
"forward-left": function() {
this.move(this.center - (scaled - this.center), this.center);
this.to(this.center - (scaled - this.center), this.center);
},
"reverse-right": function() {
this.move(scaled, this.center);
this.to(scaled, this.center);
},
"reverse-left": function() {
this.move(this.center, this.center - (scaled - this.center));
this.to(this.center, this.center - (scaled - this.center));
}
};

Expand Down Expand Up @@ -406,7 +406,7 @@ board.on("ready", function() {
}


scanner.move(degrees);
scanner.to(degrees);
}
});

Expand Down
2 changes: 1 addition & 1 deletion docs/nodeconf-radar.md
Expand Up @@ -110,7 +110,7 @@ board.on("ready", function() {
degrees += step;

// Update servo position
scanner.move(degrees);
scanner.to(degrees);
});

io.sockets.on("connection", function(socket) {
Expand Down
2 changes: 1 addition & 1 deletion docs/photoresistor-servo.md
Expand Up @@ -51,7 +51,7 @@ board.on("ready", function() {
//console.log( "Normalized value: " + this.normalized + " Scaled Value: " + this.scaled );

//tell the servo arm to move the scaled value.
servo.move(Math.floor(this.scaled));
servo.to(Math.floor(this.scaled));
});

});
Expand Down
2 changes: 1 addition & 1 deletion docs/radar.md
Expand Up @@ -110,7 +110,7 @@ board.on("ready", function() {
degrees += step;

// Update servo position
scanner.move(degrees);
scanner.to(degrees);
});

io.sockets.on("connection", function(socket) {
Expand Down
2 changes: 1 addition & 1 deletion docs/sensor-fsr-servo.md
Expand Up @@ -24,7 +24,7 @@ board.on("ready", function() {

fsr.scale([0, 180]).on("data", function() {

servo.move(this.value);
servo.to(this.value);

});
});
Expand Down
2 changes: 1 addition & 1 deletion docs/servo-array.md
Expand Up @@ -65,7 +65,7 @@ board.on("ready", function() {
//
// set all servos to deg
//
// eg. array.move( deg );
// eg. array.to( deg );

// stop()
//
Expand Down
2 changes: 1 addition & 1 deletion docs/servo-digital.md
Expand Up @@ -37,7 +37,7 @@ board.on("ready", function() {
// update the servo's position
slider.scale(range).on("slide", function() {

servo.move(Math.floor(this.value));
servo.to(Math.floor(this.value));

});
});
Expand Down
8 changes: 4 additions & 4 deletions docs/servo.md
Expand Up @@ -20,9 +20,9 @@ board.on("ready", function() {
// Inject the `servo` hardware into
// the Repl instance's context;
// allows direct command line access
board.repl.inject({
servo: servo
});
// board.repl.inject({
// servo: servo
// });

// Servo API

Expand Down Expand Up @@ -50,7 +50,7 @@ board.on("ready", function() {
//
// Moves the servo to position by degrees
//
// servo.move( 90 );
// servo.to( 90 );

// sweep( obj )
//
Expand Down
2 changes: 1 addition & 1 deletion docs/slider-pan.md
Expand Up @@ -30,7 +30,7 @@ board.on("ready", function() {

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

tilt.move(Math.floor(this.value));
tilt.to(Math.floor(this.value));

});
});
Expand Down
2 changes: 1 addition & 1 deletion docs/slider-servo-control.md
Expand Up @@ -31,7 +31,7 @@ board.on("ready", function() {

slider.scale(scalingRange).on("slide", function(err, value) {

servo.move(Math.floor(this.value));
servo.to(Math.floor(this.value));

});
});
Expand Down
6 changes: 3 additions & 3 deletions docs/sonar-scan.md
Expand Up @@ -74,8 +74,8 @@ board.on("ready", function() {
// lower and upper bound
scanner.center();

servos.right.move(90);
servos.left.move(90);
servos.right.to(90);
servos.left.to(90);

// Scanner/Panning loop
this.loop(100, function() {
Expand Down Expand Up @@ -112,7 +112,7 @@ board.on("ready", function() {
facing = "forward";
}

scanner.move(degrees);
scanner.to(degrees);
}
});

Expand Down
26 changes: 18 additions & 8 deletions docs/stepper-sweep.md
Expand Up @@ -18,14 +18,24 @@ five.Board().on("ready", function() {
pins: [11, 12]
});

function sweep() {
// 200 stepsPerRev / 2 = 100 (180degree sweeps)
stepper[++k % 2 === 0 ? "ccw" : "cw"]().step(100, function() {
sweep();
});
}

sweep();
// function sweep() {
// // 200 stepsPerRev / 2 = 100 (180degree sweeps)
// stepper[++k % 2 === 0 ? "ccw" : "cw"]().step(100, function() {
// sweep();
// });
// }

stepper.rpm(180).ccw().step(2000, function() {
console.log( "done" );
});

this.repl.inject({
stepper: stepper
});



// sweep();
});

```
Expand Down
2 changes: 1 addition & 1 deletion docs/tinkerkit-combo.md
Expand Up @@ -36,7 +36,7 @@ new five.Board().on("ready", function() {
servos = new five.Servo.Array();

slider.scale(0, 180).on("change", function() {
servos.move(this.value);
servos.to(this.value);
});

accel.on("acceleration", function() {
Expand Down

0 comments on commit 11a7713

Please sign in to comment.