diff options
Diffstat (limited to 'sensors/compass')
-rw-r--r-- | sensors/compass/Makefile | 14 | ||||
-rw-r--r-- | sensors/compass/hmc5843.vala (renamed from sensors/compass/compass-hmc5843.vala) | 13 |
2 files changed, 26 insertions, 1 deletions
diff --git a/sensors/compass/Makefile b/sensors/compass/Makefile new file mode 100644 index 0000000..178ae55 --- /dev/null +++ b/sensors/compass/Makefile @@ -0,0 +1,14 @@ +include ../../config.mk + +all: HMC5843.so + +clean: + rm -f *.c *.so + +hmc5843.c: hmc5843.vala + $(VALAC) --pkg gmodule-2.0 --pkg posix --pkg linux -C $< ../compass.vala ../../hw/i2c-device.vala ../../hw/device.vala + +HMC5843.so: hmc5843.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/compass/compass-hmc5843.vala b/sensors/compass/hmc5843.vala index b09b054..393f985 100644 --- a/sensors/compass/compass-hmc5843.vala +++ b/sensors/compass/hmc5843.vala @@ -15,7 +15,13 @@ public class HMC5843 : I2CDevice, Compass { public HMC5843(uint8 dev, uint8 addr = 0x1e) throws I2CError { - base(dev, addr); + setup(dev, addr); + } + + public void init(KeyFile cfg) throws KeyFileError, I2CError { + var adapter = cfg.get_uint64("HMC5843", "i2c-adapter"); + var address = cfg.get_uint64("HMC5843", "i2c-address"); + setup((uint8) adapter, (uint8) address); } public void get_data(out uint16 x, out uint16 y, out uint16 z) throws I2CError { @@ -24,3 +30,8 @@ public class HMC5843 : I2CDevice, Compass { z = get_big_word(0x07); } } + +public Type register_plugin (Module module) { + // types are registered automatically + return typeof(HMC5843); +} |