Permalink
Browse files

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 11a7713979b6cfd2a04592e7049f764d7a0d8800
@@ -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 ?
});
View
@@ -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;
};
@@ -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
View
@@ -38,10 +38,10 @@ board.on("ready", function() {
} else {
last = 90;
}
- arm.move(last);
+ arm.to(last);
}
- claw.move(degrees);
+ claw.to(degrees);
});
});
View
@@ -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]);
};
});
@@ -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);
});
View
@@ -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);
});
}
View
@@ -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));
});
});
View
@@ -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));
});
});
@@ -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]);
};
});
@@ -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() {
View
@@ -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({
@@ -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);
};
@@ -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() {
@@ -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));
}
};
@@ -433,7 +433,7 @@ Navigator.prototype.pivot = function(which, time) {
}
- scanner.move(degrees);
+ scanner.to(degrees);
}
});
View
@@ -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({
@@ -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);
};
@@ -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() {
@@ -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));
}
};
@@ -406,7 +406,7 @@ board.on("ready", function() {
}
- scanner.move(degrees);
+ scanner.to(degrees);
}
});
View
@@ -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) {
@@ -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));
});
});
View
@@ -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) {
View
@@ -24,7 +24,7 @@ board.on("ready", function() {
fsr.scale([0, 180]).on("data", function() {
- servo.move(this.value);
+ servo.to(this.value);
});
});
View
@@ -65,7 +65,7 @@ board.on("ready", function() {
//
// set all servos to deg
//
- // eg. array.move( deg );
+ // eg. array.to( deg );
// stop()
//
View
@@ -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));
});
});
View
@@ -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
@@ -50,7 +50,7 @@ board.on("ready", function() {
//
// Moves the servo to position by degrees
//
- // servo.move( 90 );
+ // servo.to( 90 );
// sweep( obj )
//
View
@@ -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));
});
});
@@ -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));
});
});
View
@@ -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() {
@@ -112,7 +112,7 @@ board.on("ready", function() {
facing = "forward";
}
- scanner.move(degrees);
+ scanner.to(degrees);
}
});
View
@@ -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();
});
```
View
@@ -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() {

0 comments on commit 11a7713

Please sign in to comment.