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