summaryrefslogtreecommitdiffstats
path: root/sensors/gyroscope/itg3200.vala
diff options
context:
space:
mode:
Diffstat (limited to 'sensors/gyroscope/itg3200.vala')
-rw-r--r--sensors/gyroscope/itg3200.vala11
1 files changed, 7 insertions, 4 deletions
diff --git a/sensors/gyroscope/itg3200.vala b/sensors/gyroscope/itg3200.vala
index d00c853..ac3e2f0 100644
--- a/sensors/gyroscope/itg3200.vala
+++ b/sensors/gyroscope/itg3200.vala
@@ -16,6 +16,9 @@
public class ITG3200 : I2CDevice, Gyroscope {
public int[] rate { get; set; }
+ /* ITG3200 14.375 LSBs per °/sec in radians */
+ private static double scale_factor = (1.0 / 14.375) * (180.0 / Math.PI);
+
public ITG3200(uint8 dev, uint8 addr = 0x68) throws I2CError {
setup(dev, addr);
}
@@ -50,10 +53,10 @@ public class ITG3200 : I2CDevice, Gyroscope {
return 350 + ((raw + 13200) / 28);
}
- public void get_data(out int16 x, out int16 y, out int16 z) throws I2CError {
- x = (int16) get_big_word(0x1d);
- y = (int16) get_big_word(0x1f);
- z = (int16) get_big_word(0x21);
+ public void get_data(out double x, out double y, out double z) throws I2CError {
+ x = ((int16) get_big_word(0x1d) * scale_factor);
+ y = ((int16) get_big_word(0x1f) * scale_factor);
+ z = ((int16) get_big_word(0x21) * scale_factor);
}
}