Skip to content

Commit

Permalink
Expander: skip pin normalization calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Jun 18, 2015
1 parent 59a6332 commit b63910c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,12 @@ Board.Component = function(opts, componentOpts) {
}
}

// Pin or Pins address(es)
opts = Board.Pins.normalize(opts, this.board);
componentOpts = Board.Component.initialization(componentOpts);

if (componentOpts.normalizePin) {
opts = Board.Pins.normalize(opts, this.board);
}

var requesting = [];

if (typeof opts.pins !== "undefined") {
Expand Down Expand Up @@ -901,7 +903,8 @@ Board.Component = function(opts, componentOpts) {

Board.Component.initialization = function(opts) {
var defaults = {
requestPin: true
requestPin: true,
normalizePin: true
};

return Object.assign({}, defaults, opts);
Expand Down
2 changes: 1 addition & 1 deletion lib/expander.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ function Expander(opts) {
}

Board.Component.call(
this, opts = Board.Options(opts)
this, opts = Board.Options(opts), { normalizePin: false }
);

if (typeof opts.controller === "undefined" && controllerValue) {
Expand Down
21 changes: 21 additions & 0 deletions test/expander.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ exports["Expander"] = {
test.done();
},

skipsPinNormalizationCall: function(test) {
test.expect(6);

this.normalize = sinon.spy(Board.Pins, "normalize");

[
"MCP23017",
"MCP23008",
"PCF8574",
"PCF8574A",
"PCF8575",
"PCA9685",
].forEach(function(controller) {
new Expander(controller);

test.equal(this.normalize.called, false);
}, this);

test.done();
},

noController: function(test) {
test.expect(1);

Expand Down

0 comments on commit b63910c

Please sign in to comment.