WIP on collision detection and event emitter.

This commit is contained in:
Edgar O Silva 2013-10-24 14:46:43 -05:00
parent a50ccc6548
commit 06f307afc9
3 changed files with 12 additions and 8 deletions

View File

@ -1,6 +1,6 @@
Cylon = require('..')
cylon = Cylon.robot
Cylon.robot
connection:
name: 'sphero', adaptor: 'sphero', port: '/dev/rfcomm0'
@ -8,9 +8,15 @@ cylon = Cylon.robot
name: 'sphero', driver: 'sphero'
work: (me) ->
every 1.second(), -> me.sphero.roll(60, Math.floor(Math.random() * 360), 1)
cylon.connections['sphero'].on('connected', ->
console.log('CONNECTED EVENT TRIGGERED!')
)
cylon.start()
me.sphero.on 'message', (data) ->
Logger.info 'message:'
Logger.info data
me.sphero.on 'notification', (data) ->
Logger.info 'notification:'
Logger.info data
me.sphero.configureCollisionDetection()
.start()

View File

@ -24,7 +24,6 @@ module.exports = class Connection extends EventEmitter
connect: ->
Logger.info "Connecting to '#{@name}' on port '#{@port.toString()}'..."
@self.emit('connected')
@adaptor.connect(@self)
disconnect: ->

View File

@ -34,7 +34,6 @@ module.exports = class Device extends EventEmitter
requireDriver: (driverName) ->
Logger.info "dynamic load driver"
@self.emit('driver_load')
@robot.requireDriver(driverName, @self)
addCommands: (object) ->