Update examples for new Connection/Device syntax
This commit is contained in:
parent
f1b982fedd
commit
e93e27989a
|
@ -84,16 +84,16 @@ Cylon.robot({
|
|||
var Cylon = require('cylon');
|
||||
|
||||
Cylon.robot({
|
||||
connections: [
|
||||
{ name: 'digispark', adaptor: 'digispark'},
|
||||
{ name: 'leapmotion', adaptor: 'leapmotion' }
|
||||
],
|
||||
connections: {
|
||||
digispark: { adaptor: 'digispark' },
|
||||
leapmotion: { adaptor: 'leapmotion' }
|
||||
},
|
||||
|
||||
devices: [
|
||||
{ name: 'servo1', driver: 'servo', pin: 0, connection: 'digispark' },
|
||||
{ name: 'servo2', driver: 'servo', pin: 1, connection: 'digispark' },
|
||||
{ name: 'leapmotion', driver: 'leapmotion', connection: 'leapmotion' }
|
||||
],
|
||||
devices: {
|
||||
servo1: { driver: 'servo', pin: 0, connection: 'digispark' },
|
||||
servo2: { driver: 'servo', pin: 1, connection: 'digispark' },
|
||||
leapmotion: { driver: 'leapmotion', connection: 'leapmotion' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
my.x = 90;
|
||||
|
|
|
@ -15,11 +15,12 @@ Arduino = (function(){
|
|||
})();
|
||||
|
||||
skynet = {
|
||||
connections: [
|
||||
{ name: 'skynet',
|
||||
adaptor: 'skynet',
|
||||
uuid: "96630051-a3dc-11e3-8442-5bf31d98c912", token: "2s67o7ek98pycik98f43reqr90t6s9k9" }
|
||||
],
|
||||
connection: {
|
||||
name: 'skynet',
|
||||
adaptor: 'skynet',
|
||||
uuid: "96630051-a3dc-11e3-8442-5bf31d98c912",
|
||||
token: "2s67o7ek98pycik98f43reqr90t6s9k9"
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
console.log("Skynet is listening...");
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
var Cylon = require('../..');
|
||||
|
||||
Cylon.robot({
|
||||
connections: [
|
||||
{ name: 'digispark', adaptor: 'digispark'},
|
||||
{ name: 'leapmotion', adaptor: 'leapmotion' }
|
||||
],
|
||||
connections: {
|
||||
digispark: { adaptor: 'digispark' },
|
||||
leapmotion: { adaptor: 'leapmotion' }
|
||||
},
|
||||
|
||||
devices: [
|
||||
{name: 'servo1', driver: 'servo', pin: 0, connection: 'digispark'},
|
||||
{name: 'servo2', driver: 'servo', pin: 1, connection: 'digispark'},
|
||||
{name: 'leapmotion', driver: 'leapmotion', connection: 'leapmotion'}
|
||||
],
|
||||
devices: {
|
||||
servo1: { driver: 'servo', pin: 0, connection: 'digispark' },
|
||||
servo2: { driver: 'servo', pin: 1, connection: 'digispark' },
|
||||
leapmotion: { driver: 'leapmotion', connection: 'leapmotion' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
my['x'] = 90;
|
||||
|
|
|
@ -10,16 +10,16 @@ Now that we have Cylon imported, we can start defining our robot
|
|||
|
||||
Let's define the connections and devices:
|
||||
|
||||
connections: [
|
||||
{ name: 'digispark', adaptor: 'digispark'},
|
||||
{ name: 'leapmotion', adaptor: 'leapmotion' }
|
||||
],
|
||||
connections: {
|
||||
digispark: { adaptor: 'digispark' },
|
||||
leapmotion: { adaptor: 'leapmotion' }
|
||||
},
|
||||
|
||||
devices: [
|
||||
{name: 'servo1', driver: 'servo', pin: 0, connection: 'digispark'},
|
||||
{name: 'servo2', driver: 'servo', pin: 1, connection: 'digispark'},
|
||||
{name: 'leapmotion', driver: 'leapmotion', connection: 'leapmotion'}
|
||||
],
|
||||
devices: {
|
||||
servo1: { driver: 'servo', pin: 0, connection: 'digispark' },
|
||||
servo2: { driver: 'servo', pin: 1, connection: 'digispark' },
|
||||
leapmotion: { driver: 'leapmotion', connection: 'leapmotion' }
|
||||
},
|
||||
|
||||
Now that Cylon knows about the necessary hardware we're going to be using, we'll
|
||||
tell it what work we want to do:
|
||||
|
|
|
@ -25,17 +25,17 @@ var handStartPosition = [],
|
|||
var handWasClosedInLastFrame = false;
|
||||
|
||||
Cylon.robot({
|
||||
connections: [
|
||||
{ name: 'leapmotion', adaptor: 'leapmotion' },
|
||||
{ name: 'ardrone', adaptor: 'ardrone', port: '192.168.1.1' },
|
||||
{ name: 'keyboard', adaptor: 'keyboard' }
|
||||
],
|
||||
connections: {
|
||||
leapmotion: { adaptor: 'leapmotion' },
|
||||
ardrone: { adaptor: 'ardrone', port: '192.168.1.1' },
|
||||
keyboard: { adaptor: 'keyboard' }
|
||||
},
|
||||
|
||||
devices: [
|
||||
{ name: 'drone', driver: 'ardrone', connection: 'ardrone' },
|
||||
{ name: 'leapmotion', driver: 'leapmotion', connection: 'leapmotion' },
|
||||
{ name: 'keyboard', driver: 'keyboard', connection: 'keyboard'}
|
||||
],
|
||||
devices: {
|
||||
drone: { driver: 'ardrone', connection:'ardrone' },
|
||||
leapmotion: { driver: 'leapmotion', connection:'leapmotion' },
|
||||
keyboard: { driver: 'keyboard', connection:'keyboard' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
my.keyboard.on('right', my.drone.rightFlip);
|
||||
|
|
|
@ -12,16 +12,17 @@ Now that we have Cylon imported, we can start defining our robot
|
|||
|
||||
Let's define the connections and devices:
|
||||
|
||||
connections: [
|
||||
{ name: 'leapmotion', adaptor: 'leapmotion' },
|
||||
{ name: 'ardrone', adaptor: 'ardrone', port: '192.168.1.1' },
|
||||
{ name: 'keyboard', adaptor: 'keyboard' }
|
||||
],
|
||||
devices: [
|
||||
{ name: 'drone', driver: 'ardrone', connection:'ardrone' },
|
||||
{ name: 'leapmotion', driver: 'leapmotion', connection:'leapmotion' },
|
||||
{ name: 'keyboard', driver: 'keyboard', connection:'keyboard'}
|
||||
],
|
||||
connections: {
|
||||
leapmotion: { adaptor: 'leapmotion' },
|
||||
ardrone: { adaptor: 'ardrone', port: '192.168.1.1' },
|
||||
keyboard: { adaptor: 'keyboard' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
drone: { driver: 'ardrone', connection:'ardrone' },
|
||||
leapmotion: { driver: 'leapmotion', connection:'leapmotion' },
|
||||
keyboard: { driver: 'keyboard', connection:'keyboard' }
|
||||
},
|
||||
|
||||
Now that Cylon knows about the necessary hardware we're going to be using, we'll
|
||||
tell it what work we want to do:
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
var Cylon = require('../..');
|
||||
|
||||
Cylon.robot({
|
||||
connections: [{ name: 'leapmotion', adaptor: 'leapmotion' },
|
||||
{ name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' }],
|
||||
connections: {
|
||||
arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' }
|
||||
leapmotion: { adaptor: 'leapmotion' },
|
||||
},
|
||||
|
||||
devices: [{ name: 'leapmotion', driver: 'leapmotion', connection: 'leapmotion' },
|
||||
{ name: 'led', driver: 'led', pin: 13, connection: 'arduino' }],
|
||||
devices: {
|
||||
led: { driver: 'led', pin: 13, connection: 'arduino' }
|
||||
leapmotion: { driver: 'leapmotion', connection: 'leapmotion' },
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
my.leapmotion.on('frame', function(frame) {
|
||||
|
|
|
@ -10,15 +10,15 @@ Now that we have Cylon imported, we can start defining our robot
|
|||
|
||||
Let's define the connections and devices:
|
||||
|
||||
connections: [
|
||||
{ name: 'leapmotion', adaptor: 'leapmotion' },
|
||||
{ name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' }
|
||||
],
|
||||
connections: {
|
||||
leapmotion: { adaptor: 'leapmotion' },
|
||||
arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' }
|
||||
},
|
||||
|
||||
devices: [
|
||||
{ name: 'leapmotion', driver: 'leapmotion', connection: 'leapmotion' },
|
||||
{ name: 'led', driver: 'led', pin: 13, connection: 'arduino' }
|
||||
],
|
||||
devices: {
|
||||
leapmotion: { driver: 'leapmotion', connection: 'leapmotion' },
|
||||
led: { driver: 'led', pin: 13, connection: 'arduino' }
|
||||
},
|
||||
|
||||
Now that Cylon knows about the necessary hardware we're going to be using, we'll
|
||||
tell it what work we want to do:
|
||||
|
|
|
@ -2,8 +2,10 @@ var Cylon = require('../..');
|
|||
|
||||
Cylon.robot({
|
||||
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyUSB0' },
|
||||
devices: [{name: 'led', driver: 'led', pin: 17},
|
||||
{ name: 'servo', driver: 'servo', pin: 2, range: { min: 30, max: 150 } }],
|
||||
devices: {
|
||||
led: { driver: 'led', pin: 17 },
|
||||
servo: { driver: 'servo', pin: 2, range: { min: 30, max: 150 } }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
my.led.turnOn();
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
var Cylon = require('../..');
|
||||
|
||||
Cylon.robot({
|
||||
connections: [
|
||||
{ name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' },
|
||||
{ name: 'skynet', adaptor: 'skynet',
|
||||
uuid: "96630051-a3dc-11e3-8442-5bf31d98c912", token: "2s67o7ek98pycik98f43reqr90t6s9k9" }
|
||||
],
|
||||
connections: {
|
||||
arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' },
|
||||
skynet: {
|
||||
adaptor: 'skynet',
|
||||
uuid: "96630051-a3dc-11e3-8442-5bf31d98c912",
|
||||
token: "2s67o7ek98pycik98f43reqr90t6s9k9"
|
||||
}
|
||||
},
|
||||
|
||||
device: { name: 'led13', driver: 'led', pin: 13, connection: 'arduino' },
|
||||
|
||||
|
|
|
@ -10,19 +10,14 @@ Now that we have Cylon imported, we can start defining our robot
|
|||
|
||||
Let's define the connections and devices:
|
||||
|
||||
connections: [
|
||||
{
|
||||
name: 'arduino',
|
||||
adaptor: 'firmata',
|
||||
port: '/dev/ttyACM0'
|
||||
},
|
||||
{
|
||||
name: 'skynet',
|
||||
connections: {
|
||||
arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' },
|
||||
skynet: {
|
||||
adaptor: 'skynet',
|
||||
uuid: "96630051-a3dc-11e3-8442-5bf31d98c912",
|
||||
token: "2s67o7ek98pycik98f43reqr90t6s9k9"
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
device: { name: 'led13', driver: 'led', pin: 13, connection: 'arduino' },
|
||||
|
||||
|
|
Loading…
Reference in New Issue