Add example(s) for Leap Motion controlled LED via Skynet

This commit is contained in:
deadprogram 2014-02-21 22:00:27 -08:00
parent af7207dad3
commit 10c5e12f8d
2 changed files with 30 additions and 3 deletions

View File

@ -0,0 +1,28 @@
Cylon = require '../..'
Cylon.robot
connections: [
{ name: 'leapmotion', adaptor: 'leapmotion', port: '127.0.0.1:6437' },
{ name: 'skynet', adaptor: 'skynet', uuid: "0675b9d1-9b7e-11e3-af21-030ff142869f", token: "yr2oi19yyspmbo6rcgkp7gov5i2j4i" },
]
device:
{ name: 'leapmotion', driver: 'leapmotion', connection: 'leapmotion' }
work: (my) ->
my.leapmotion.on 'frame', (frame) ->
if frame.hands.length > 0
console.log 'on'
my.skynet.message
"devices": ["742401f1-87a4-11e3-834d-670dadc0ddbf"],
"message":
'red': 'on'
else
console.log 'off'
my.skynet.message
"devices": ["742401f1-87a4-11e3-834d-670dadc0ddbf"],
"message":
'red': 'off'
.start()

View File

@ -3,17 +3,16 @@ Cylon = require '../..'
Cylon.robot
connections: [
{ name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' },
# { name: 'skynet', adaptor: 'skynet', uuid: "742401f1-87a4-11e3-834d-670dadc0ddbf", token: "xjq9h3yzhemf5hfrme8y08fh0sm50zfr" }
{ name: 'skynet', adaptor: 'skynet', host: 'localhost', portNumber: 3000, uuid: "18676eb1-9997-11e3-8c2a-f18a07a72684", token: "vbeo289aik65hfr1lns8vst273nmi" }
{ name: 'skynet', adaptor: 'skynet', uuid: "742401f1-87a4-11e3-834d-670dadc0ddbf", token: "xjq9h3yzhemf5hfrme8y08fh0sm50zfr" }
]
device: { name: 'led', driver: 'led', pin: 13, connection: 'arduino' }
work: (my) ->
Logger.info "connected..."
my.connections['skynet'].on 'message', (channel, data) ->
console.log(data)
data = JSON.parse(data)
if data.red is 'on'
console.log("red on request received from skynet");
my.led.turnOn()