-
Notifications
You must be signed in to change notification settings - Fork 0
/
bmp183.js
38 lines (24 loc) · 1.13 KB
/
bmp183.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const LynxariDevice = require(process.lynxari.device);
const device = require('@agilatech/bmp183');
module.exports = class Bmp183 extends LynxariDevice {
constructor(config) {
// The bus/file must be defined. If not supplied in config options, then default to /dev/spidev1.0
const bus = config['bus'] || "/dev/spidev1.0";
// defaults to sea-level, which is very inaccurate for anything besides sea-level
const altitude = config['altitude'] || 0;
const mode = config['mode'] || 3; // defaults to ultra-high-res mode
const hardware = new device.Bmp183(bus, altitude, mode);
super(hardware, config);
}
addDeviceFunctionsToStates(config, onAllow, offAllow) {
onAllow.push('change-mode');
config.map('change-mode', this.changeMode, [{name:'mode'}]);
}
changeMode(mode, callback) {
const success = this.hardware.operatingMode(mode);
if (success) {
this.info("New BMP183 Operating Mode:" + mode, {"mode":mode});
}
callback();
}
}