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: Port to alt runtime using async-lite #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 19 additions & 1 deletion bmp085-sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,25 @@ module.exports = function BMP085(options) {
units: 'metric'
};
options.address = options.address || 0x77;
var wire = new i2c(options.address);
var wire;
if (!process.iotjs) {
wire = new i2c(options.address);
} else {
options.bus = options.bus || 1;
options.device = options.device || '/dev/i2c-1';
wire = i2c.openSync(options);
wire.writeBytes = function(offset, bytes, callback) {
var bytes = [offset].concat(bytes);
this.writeSync(bytes);
callback && callback(null);
}
wire.readBytes = function(offset, len, callback) {
this.writeSync([offset]);
this.read(len, function(err, res) {
callback && callback(err, res);
});
}
}
var cal = {};

var BMP085_CONTROL_REGISTER = 0xF4;
Expand Down