2014-12-14 08:19:25 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var Cylon = require("../..");
|
2014-02-19 12:33:10 +08:00
|
|
|
|
|
|
|
Cylon.robot({
|
2014-11-11 04:37:33 +08:00
|
|
|
connections: {
|
2014-12-14 08:19:25 +08:00
|
|
|
digispark: { adaptor: "digispark" },
|
|
|
|
leapmotion: { adaptor: "leapmotion" }
|
2014-11-11 04:37:33 +08:00
|
|
|
},
|
2014-02-19 12:33:10 +08:00
|
|
|
|
2014-11-11 04:37:33 +08:00
|
|
|
devices: {
|
2014-12-14 08:19:25 +08:00
|
|
|
servo1: { driver: "servo", pin: 0, connection: "digispark" },
|
|
|
|
servo2: { driver: "servo", pin: 1, connection: "digispark" },
|
|
|
|
leapmotion: { driver: "leapmotion", connection: "leapmotion" }
|
2014-11-11 04:37:33 +08:00
|
|
|
},
|
2014-02-19 12:33:10 +08:00
|
|
|
|
|
|
|
work: function(my) {
|
2014-11-26 01:45:20 +08:00
|
|
|
my.x = 90;
|
|
|
|
my.z = 90;
|
2014-02-19 12:33:10 +08:00
|
|
|
|
2014-12-14 08:19:25 +08:00
|
|
|
my.leapmotion.on("hand", function(hand) {
|
2014-11-26 01:45:20 +08:00
|
|
|
my.x = hand.palmX.fromScale(-300, 300).toScale(30, 150);
|
|
|
|
my.z = hand.palmZ.fromScale(-300, 300).toScale(30, 150);
|
2014-02-19 12:33:10 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
every(100, function() {
|
2014-11-26 01:45:20 +08:00
|
|
|
my.servo1.angle(my.x);
|
|
|
|
my.servo2.angle(my.z);
|
2014-02-19 12:33:10 +08:00
|
|
|
|
2014-12-14 08:19:25 +08:00
|
|
|
var str = "Current Angle: ";
|
|
|
|
str += my.servo1.currentAngle();
|
|
|
|
str += ", ";
|
|
|
|
str += my.servo2.currentAngle();
|
|
|
|
|
|
|
|
console.log(str);
|
2014-02-19 12:33:10 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}).start();
|