summaryrefslogtreecommitdiffstats
path: root/sensors/gyroscope
diff options
context:
space:
mode:
Diffstat (limited to 'sensors/gyroscope')
-rw-r--r--sensors/gyroscope/Makefile14
-rw-r--r--sensors/gyroscope/itg3200.vala (renamed from sensors/gyroscope/gyroscope-itg3200.vala)17
2 files changed, 30 insertions, 1 deletions
diff --git a/sensors/gyroscope/Makefile b/sensors/gyroscope/Makefile
new file mode 100644
index 0000000..f7add97
--- /dev/null
+++ b/sensors/gyroscope/Makefile
@@ -0,0 +1,14 @@
+include ../../config.mk
+
+all: ITG3200.so
+
+clean:
+ rm -f *.c *.so
+
+itg3200.c: itg3200.vala
+ $(VALAC) -g --pkg gmodule-2.0 --pkg posix --pkg linux -C $< ../gyroscope.vala ../../hw/i2c-device.vala ../../hw/device.vala
+
+ITG3200.so: itg3200.c
+ $(CC) -g -shared -fPIC `pkg-config --cflags --libs glib-2.0 gobject-2.0 gmodule-2.0` -o $@ $<
+
+.PHONY: all clean
diff --git a/sensors/gyroscope/gyroscope-itg3200.vala b/sensors/gyroscope/itg3200.vala
index c57aa55..2b7f03e 100644
--- a/sensors/gyroscope/gyroscope-itg3200.vala
+++ b/sensors/gyroscope/itg3200.vala
@@ -14,8 +14,18 @@
*/
public class ITG3200 : I2CDevice, Gyroscope {
+ public int[] rate { get; set; }
+
public ITG3200(uint8 dev, uint8 addr = 0x68) throws I2CError {
- base(dev, addr);
+ setup(dev, addr);
+ }
+
+ public void init(KeyFile cfg) throws KeyFileError, I2CError {
+ rate = new int[3];
+
+ var adapter = cfg.get_uint64("ITG3200", "i2c-adapter");
+ var address = cfg.get_uint64("ITG3200", "i2c-address");
+ setup((uint8) adapter, (uint8) address);
}
public uint8 get_address() throws I2CError {
@@ -46,3 +56,8 @@ public class ITG3200 : I2CDevice, Gyroscope {
z = (int16) get_big_word(0x21);
}
}
+
+public Type register_plugin (Module module) {
+ // types are registered automatically
+ return typeof(ITG3200);
+}