Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iotjs: fallback to array #14

Merged
merged 1 commit into from
Aug 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions bh1750.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ BH1750.prototype.readLight = function (cb) {
console.error("error: I/O failure on BH1750 - command: ", self.options.command);
return cb(err, null);
}
var hi = res.readUInt8(0);
var lo = res.readUInt8(1);
var hi = res[0];
var lo = res[1];
if (Buffer.isBuffer(res)) {
hi = res.readUInt8(0);
lo = res.readUInt8(1);
}

var lux = ((hi << 8) + lo)/1.2;
if (self.options.command === 0x11) {
lux = lux/2;
Expand Down