Devices need pin

This commit is contained in:
deadprogram 2013-10-25 20:29:11 -07:00
parent 9bfd8ce57d
commit 5e6bf8763b
2 changed files with 11 additions and 2 deletions

8
dist/device.js vendored
View File

@ -28,13 +28,19 @@
this.self = this; this.self = this;
this.robot = opts.robot; this.robot = opts.robot;
this.name = opts.name; this.name = opts.name;
this.pin = opts.pin;
this.connection = this.determineConnection(opts.connection) || this.defaultConnection(); this.connection = this.determineConnection(opts.connection) || this.defaultConnection();
this.driver = this.requireDriver(opts.driver); this.driver = this.requireDriver(opts.driver);
this.addCommands(this.driver); this.addCommands(this.driver);
} }
Device.prototype.start = function() { Device.prototype.start = function() {
Logger.info("Starting driver " + this.driver.name); var msg;
msg = "Starting device '" + this.name + "'";
if (this.pin != null) {
msg += " on pin " + this.pin;
}
Logger.info(msg);
return this.driver.start(); return this.driver.start();
}; };

View File

@ -16,12 +16,15 @@ module.exports = class Device extends EventEmitter
@self = this @self = this
@robot = opts.robot @robot = opts.robot
@name = opts.name @name = opts.name
@pin = opts.pin
@connection = @determineConnection(opts.connection) or @defaultConnection() @connection = @determineConnection(opts.connection) or @defaultConnection()
@driver = @requireDriver(opts.driver) @driver = @requireDriver(opts.driver)
@addCommands(@driver) @addCommands(@driver)
start: -> start: ->
Logger.info "Starting driver #{ @driver.name }" msg = "Starting device '#{ @name }'"
msg += " on pin #{@pin}" if @pin?
Logger.info msg
@driver.start() @driver.start()
determineConnection: (c) -> determineConnection: (c) ->