More examples please
This commit is contained in:
parent
b0346204a0
commit
046c3578a5
|
@ -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()
|
|
@ -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()
|
Loading…
Reference in New Issue