summaryrefslogtreecommitdiffstats
path: root/sensors/barometer
diff options
context:
space:
mode:
Diffstat (limited to 'sensors/barometer')
-rw-r--r--sensors/barometer/Makefile14
-rw-r--r--sensors/barometer/bmp085.vala (renamed from sensors/barometer/barometer-bmp085.vala)14
2 files changed, 27 insertions, 1 deletions
diff --git a/sensors/barometer/Makefile b/sensors/barometer/Makefile
new file mode 100644
index 0000000..9a23671
--- /dev/null
+++ b/sensors/barometer/Makefile
@@ -0,0 +1,14 @@
+include ../../config.mk
+
+all: BMP085.so
+
+clean:
+ rm -f *.c *.so
+
+bmp085.c: bmp085.vala
+ $(VALAC) --pkg gmodule-2.0 --pkg posix --pkg linux -C $< ../barometer.vala ../../hw/i2c-device.vala ../../hw/device.vala
+
+BMP085.so: bmp085.c
+ $(CC) -shared -fPIC `pkg-config --cflags --libs glib-2.0 gobject-2.0 gmodule-2.0` -o $@ $<
+
+.PHONY: all clean
diff --git a/sensors/barometer/barometer-bmp085.vala b/sensors/barometer/bmp085.vala
index 92ea917..f0da790 100644
--- a/sensors/barometer/barometer-bmp085.vala
+++ b/sensors/barometer/bmp085.vala
@@ -38,10 +38,17 @@ public class BMP085 : I2CDevice, Barometer {
}
public BMP085(uint8 dev, uint8 addr = 0x77) throws I2CError {
- base(dev, addr);
+ setup(dev, addr);
read_calibration_values();
}
+ public void init(KeyFile cfg) throws KeyFileError, I2CError {
+ var adapter = cfg.get_uint64("BMP085", "i2c-adapter");
+ var address = cfg.get_uint64("BMP085", "i2c-address");
+ setup((uint8) adapter, (uint8) address);
+ read_calibration_values();
+ }
+
private void read_calibration_values() throws I2CError {
var data = get_block(0xaa, 22);
cal.AC1 = data[0] << 8 | data[1];
@@ -126,3 +133,8 @@ public class BMP085 : I2CDevice, Barometer {
return (int32) p;
}
}
+
+public Type register_plugin (Module module) {
+ // types are registered automatically
+ return typeof(BMP085);
+}