Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LSM9DS1_Library by
Diff: LSM9DS1.cpp
- Revision:
- 3:9ed8bc1d0da3
- Parent:
- 1:87d535bf8c53
diff -r e8c2301f7523 -r 9ed8bc1d0da3 LSM9DS1.cpp
--- a/LSM9DS1.cpp Wed Feb 03 18:24:29 2016 +0000
+++ b/LSM9DS1.cpp Tue Jun 13 03:51:56 2017 +0000
@@ -42,6 +42,10 @@
:i2c(sda, scl)
{
init(IMU_MODE_I2C, xgAddr, mAddr); // dont know about 0xD6 or 0x3B
+
+ // Unit transformation
+ deg2rad = PI/180.0;
+ rad2deg = 180.0/PI;
}
/*
LSM9DS1::LSM9DS1()
@@ -539,6 +543,26 @@
return value;
}
+// =========================================================================== //
+
+void LSM9DS1::readAccelFloatVector(vector<float> &v_out)
+{
+ readAccel();
+
+ v_out[X_AXIS] = calcAccel(ax)*G;
+ v_out[Y_AXIS] = calcAccel(ay)*G;
+ v_out[Z_AXIS] = calcAccel(az)*G;
+}
+
+float LSM9DS1::readAccelFloat(lsm9ds1_axis axis)
+{
+ return calcAccel(readAccel(axis))*G;
+}
+// =========================================================================== //
+
+
+
+
void LSM9DS1::readMag()
{
uint8_t temp[6]; // We'll read six bytes from the mag into temp
@@ -592,6 +616,38 @@
return value;
}
+// =========================================================================== //
+
+void LSM9DS1::readGyroFloatVectorRad(vector<float> &v_out)
+{
+ readGyro();
+
+ v_out[X_AXIS] = calcGyro(gx)*deg2rad;
+ v_out[Y_AXIS] = calcGyro(gy)*deg2rad;
+ v_out[Z_AXIS] = calcGyro(gz)*deg2rad;
+}
+
+void LSM9DS1::readGyroFloatVectorDeg(vector<float> &v_out)
+{
+ readGyro();
+
+ v_out[X_AXIS] = calcGyro(gx);
+ v_out[Y_AXIS] = calcGyro(gy);
+ v_out[Z_AXIS] = calcGyro(gz);
+}
+
+float LSM9DS1::readGyroFloatRad(lsm9ds1_axis axis)
+{
+ return calcGyro(readGyro(axis))*deg2rad;
+}
+
+float LSM9DS1::readGyroFloatDeg(lsm9ds1_axis axis)
+{
+ return calcGyro(readGyro(axis));
+}
+
+// =========================================================================== //
+
float LSM9DS1::calcGyro(int16_t gyro)
{
// Return the gyro raw reading times our pre-calculated DPS / (ADC tick):
