2013-10-25 07:19:15 +08:00
|
|
|
Cylon = require('..')
|
|
|
|
|
|
|
|
Cylon.robot
|
|
|
|
connection:
|
|
|
|
name: 'sphero', adaptor: 'sphero', port: '/dev/rfcomm0'
|
|
|
|
|
|
|
|
device:
|
|
|
|
name: 'sphero', driver: 'sphero'
|
|
|
|
|
|
|
|
work: (me) ->
|
2013-10-26 08:49:35 +08:00
|
|
|
|
2013-11-01 06:15:23 +08:00
|
|
|
|
|
|
|
me.sphero.on 'connect', ->
|
2013-10-26 08:49:35 +08:00
|
|
|
Logger.info('Setting up Collision Detection...')
|
|
|
|
me.sphero.detectCollisions()
|
|
|
|
me.sphero.setRGB(0x00FF00)
|
2013-11-01 06:15:23 +08:00
|
|
|
|
|
|
|
me.sphero.on 'update', (data) ->
|
|
|
|
Logger.info("Update event eventName -> #{ data } ")
|
|
|
|
Logger.info("Update event args -> ")
|
|
|
|
Logger.info(data)
|
2013-10-25 07:19:15 +08:00
|
|
|
|
|
|
|
me.sphero.on 'message', (data) ->
|
2013-10-26 08:49:35 +08:00
|
|
|
me.sphero.setRGB(0x0000FF)
|
2013-10-25 07:19:15 +08:00
|
|
|
Logger.info 'message:'
|
|
|
|
Logger.info data
|
|
|
|
|
2013-10-29 09:59:44 +08:00
|
|
|
me.sphero.on 'collision', (data) ->
|
|
|
|
me.sphero.setRGB(0xFF0000)
|
|
|
|
Logger.info 'collision:'
|
|
|
|
Logger.info data
|
|
|
|
|
2013-10-25 07:19:15 +08:00
|
|
|
me.sphero.on 'notification', (data) ->
|
2013-10-26 08:49:35 +08:00
|
|
|
me.sphero.setRGB(0xFF0000)
|
2013-10-25 07:19:15 +08:00
|
|
|
Logger.info 'notification:'
|
|
|
|
Logger.info data
|
|
|
|
|
|
|
|
.start()
|