cylon/examples/sphero_messages.coffee

39 lines
889 B
CoffeeScript
Raw Normal View History

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) ->
me.sphero.on 'connect', ->
Logger.info('Setting up Collision Detection...')
me.sphero.detectCollisions()
me.sphero.setRGB(0x00FF00)
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) ->
me.sphero.setRGB(0x0000FF)
2013-10-25 07:19:15 +08:00
Logger.info 'message:'
Logger.info data
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) ->
me.sphero.setRGB(0xFF0000)
2013-10-25 07:19:15 +08:00
Logger.info 'notification:'
Logger.info data
.start()