WIP on collision detection and event emitter.
This commit is contained in:
parent
a50ccc6548
commit
06f307afc9
|
@ -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()
|
||||
|
|
|
@ -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: ->
|
||||
|
|
|
@ -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) ->
|
||||
|
|
Loading…
Reference in New Issue