Skip to content

Commit

Permalink
Merge pull request #14 from TizenTeam/sandbox/rzr/review/master
Browse files Browse the repository at this point in the history
iotjs: fallback to array
  • Loading branch information
miroRucka authored Aug 24, 2018
2 parents 2aa72da + 5f1b37d commit 4e8d0a7
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit 4e8d0a7

Please sign in to comment.