More examples please

This commit is contained in:
deadprogram 2013-10-24 16:19:15 -07:00
parent b0346204a0
commit 046c3578a5
2 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,22 @@
Cylon = require('..')
Cylon.robot
connection:
name: 'sphero', adaptor: 'sphero', port: '/dev/rfcomm0'
device:
name: 'sphero', driver: 'sphero'
work: (me) ->
me.sphero.on 'connect', ->
Logger.info 'party started...'
me.sphero.on 'message', (data) ->
Logger.info 'message:'
Logger.info data
me.sphero.on 'notification', (data) ->
Logger.info 'notification:'
Logger.info data
.start()

View File

@ -0,0 +1,31 @@
Cylon = require '..'
bots = [
{ port: '/dev/rfcomm0', name: 'Thelma' },
{ port: '/dev/rfcomm1', name: 'Louise' }
]
SpheroRobot =
connection:
name: 'Sphero', adaptor: 'sphero'
device:
name: 'sphero', driver: 'sphero'
work: (self) ->
color = 0x000050
every 1.second(), ->
#me.sphero.roll(60, Math.floor(Math.random() * 360), 1)
Logger.info self.name
self.sphero.setRGB(color, true)
color += 0x005000
color = 0x000050 if color > 0xFFFFFF
for bot in bots
robot = Object.create(SpheroRobot)
robot.connection.port = bot.port
robot.name = bot.name
Cylon.robot robot
Cylon.start()