Skip to content

Commit

Permalink
Light: ALSPT19
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Oct 8, 2015
1 parent 534dba9 commit 2b3cdf1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/light.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,14 @@ var Controllers = {
},
toIntensityLevel: {
value: function(raw) {
//

console.log("???", raw);
return __.scale(raw, 0.1, 40000, 0, 100);
}
}
},
};

Controllers.ALSPT19 = Controllers["ALS-PT19"] = Controllers.DEFAULT;


/**
* Light
Expand All @@ -190,8 +189,8 @@ function Light(opts) {
var controller = null;
var state = {};
var raw = 0;
var freq = opts.freq || 25;
var last = 0;
var freq = opts.freq || 25;

Board.Device.call(
this, opts = Board.Options(opts)
Expand Down Expand Up @@ -224,6 +223,10 @@ function Light(opts) {
return this.toIntensityLevel(raw);
}
},
// TODO:
//
// lux?
//
});

if (typeof this.initialize === "function") {
Expand Down
42 changes: 42 additions & 0 deletions test/light.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,48 @@ exports["Light"] = {
}
};

exports["Light: ALSPT19"] = {
setUp: function(done) {
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.light = new Light({
controller: "ALSPT19",
pin: "A1",
freq: 100,
board: this.board
});

done();
},

tearDown: function(done) {
Board.purge();
restore(this);
done();
},

shape: function(test) {
test.expect(proto.length + instance.length);

proto.forEach(function(method) {
test.equal(typeof this.light[method.name], "function");
}, this);

instance.forEach(function(property) {
test.notEqual(typeof this.light[property.name], 0);
}, this);

test.done();
},

emitter: function(test) {
test.expect(1);
test.ok(this.light instanceof Emitter);
test.done();
}
};

exports["Light: EVS_EV3, Ambient (Default)"] = {
setUp: function(done) {
this.board = newBoard();
Expand Down

0 comments on commit 2b3cdf1

Please sign in to comment.