diff options
-rw-r--r-- | sensors/gyroscope.vala | 11 | ||||
-rw-r--r-- | sensors/gyroscope/Makefile | 2 | ||||
-rw-r--r-- | sensors/gyroscope/itg3200.vala | 8 |
3 files changed, 8 insertions, 13 deletions
diff --git a/sensors/gyroscope.vala b/sensors/gyroscope.vala index 07452ec..1ef10b2 100644 --- a/sensors/gyroscope.vala +++ b/sensors/gyroscope.vala @@ -14,16 +14,7 @@ */ public interface Gyroscope : Device { -#if 0 - double[] rate = {0.0, 0.0, 0.0}; - int[] zero = {0, 0, 0}; - long[] sample = {0, 0, 0}; - double smoothFactor = 1.0; - double scaleFactor = 0.0; - double heading = 0.0; - ulong gyroLastMesuredTime = 0; -#endif public abstract void init(KeyFile cfg) throws Error; public abstract void get_data(out double x, out double y, out double z) throws I2CError; - public abstract int[] rate { get; set; } + public abstract double[] rate { get; set; } } diff --git a/sensors/gyroscope/Makefile b/sensors/gyroscope/Makefile index 09ec45f..46435ec 100644 --- a/sensors/gyroscope/Makefile +++ b/sensors/gyroscope/Makefile @@ -6,7 +6,7 @@ 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 ../../enums.vala + $(VALAC) -g --pkg gmodule-2.0 --pkg posix --pkg linux -C $< ../gyroscope.vala ../../hw/i2c-device.vala ../../hw/device.vala ../../enums.vala ../../utils.vala ITG3200.so: itg3200.c $(CC) -g -shared -fPIC `pkg-config --cflags --libs glib-2.0 gobject-2.0 gmodule-2.0` -o $@ $< diff --git a/sensors/gyroscope/itg3200.vala b/sensors/gyroscope/itg3200.vala index e616848..bc99769 100644 --- a/sensors/gyroscope/itg3200.vala +++ b/sensors/gyroscope/itg3200.vala @@ -14,7 +14,7 @@ */ public class ITG3200 : I2CDevice, Gyroscope { - public int[] rate { get; set; } + public double[] rate { get; set; } private int[] zero = new int[3]; /* ITG3200 14.375 LSBs per °/sec in radians */ @@ -37,7 +37,7 @@ public class ITG3200 : I2CDevice, Gyroscope { } public void init(KeyFile cfg) throws KeyFileError, I2CError { - rate = new int[3]; + rate = new double[3]; var adapter = cfg.get_uint64("ITG3200", "i2c-adapter"); var address = cfg.get_uint64("ITG3200", "i2c-address"); @@ -88,6 +88,10 @@ public class ITG3200 : I2CDevice, Gyroscope { x = ((int16) get_big_word(0x1d)-zero[AXIS.X]) / scale; y = ((int16) get_big_word(0x1f)-zero[AXIS.Y]) / scale; z = ((int16) get_big_word(0x21)-zero[AXIS.Z]) / scale; + + rate[AXIS.X] = radians(x); + rate[AXIS.Y] = radians(y); + rate[AXIS.Z] = radians(z); } } |