diff --git a/dist/device.js b/dist/device.js index 7ea6f63..072c8a1 100644 --- a/dist/device.js +++ b/dist/device.js @@ -34,7 +34,8 @@ } Device.prototype.start = function() { - return Logger.info("started"); + Logger.info("Starting driver " + this.driver.name); + return this.driver.start(); }; Device.prototype.determineConnection = function(c) { diff --git a/dist/robot.js b/dist/robot.js index e111503..8df43b8 100644 --- a/dist/robot.js +++ b/dist/robot.js @@ -114,6 +114,7 @@ for (n in _ref) { device = _ref[n]; Logger.info("Starting device '" + device.name + "'..."); + device.start(); _results.push(this[device.name] = device); } return _results; diff --git a/examples/pure_spheron.coffee b/examples/pure_spheron.coffee new file mode 100644 index 0000000..b8fc28c --- /dev/null +++ b/examples/pure_spheron.coffee @@ -0,0 +1,34 @@ +spheron = require('spheron') +sphero = spheron.sphero() +spheroPort = '/dev/rfcomm0' +COLORS = spheron.toolbelt.COLORS + +sphero.on('open', -> + console.log('EVENT OPEN!') + sphero.configureCollisionDetection(0x01, 0x20, 0x20, 0x20, 0x20, 0x50) + sphero.setRGB(COLORS.GREEN, false) +) + +sphero.on('close', -> + console.log('EVENT CLOSE!') +) + +sphero.on('end', -> + console.log('EVENT END!') +) + +sphero.on('error', -> + console.log('EVENT ERROR!') +) + +sphero.on('notification', (packet) -> + console.log('Packet contents:') + console.log(packet) +) + +sphero.on('message', (packet) -> + console.log('Packet contents:') + console.log(packet) +) + +sphero.open(spheroPort) diff --git a/examples/sphero_messages.coffee b/examples/sphero_messages.coffee index 09da42c..e059c7b 100644 --- a/examples/sphero_messages.coffee +++ b/examples/sphero_messages.coffee @@ -8,14 +8,20 @@ Cylon.robot name: 'sphero', driver: 'sphero' work: (me) -> - me.sphero.on 'connect', -> - Logger.info 'party started...' + + me.sphero.on('connect', -> + Logger.info('Setting up Collision Detection...') + me.sphero.detectCollisions() + me.sphero.setRGB(0x00FF00) + ) me.sphero.on 'message', (data) -> + me.sphero.setRGB(0x0000FF) Logger.info 'message:' Logger.info data me.sphero.on 'notification', (data) -> + me.sphero.setRGB(0xFF0000) Logger.info 'notification:' Logger.info data diff --git a/src/device.coffee b/src/device.coffee index f02385d..f4492ca 100644 --- a/src/device.coffee +++ b/src/device.coffee @@ -21,7 +21,8 @@ module.exports = class Device extends EventEmitter @addCommands(@driver) start: -> - Logger.info "started" + Logger.info "Starting driver #{ @driver.name }" + @driver.start() determineConnection: (c) -> @robot.connections[c] if c diff --git a/src/robot.coffee b/src/robot.coffee index 697194b..66563b2 100644 --- a/src/robot.coffee +++ b/src/robot.coffee @@ -67,6 +67,7 @@ module.exports = class Robot Logger.info "Starting devices..." for n, device of @devices Logger.info "Starting device '#{ device.name }'..." + device.start() this[device.name] = device requireAdaptor: (adaptorName, connection) ->