only test purpose not official
Revision 9:e0759c34eb93, committed 2020-02-07
- Comitter:
- kenjiArai
- Date:
- Fri Feb 07 00:53:14 2020 +0000
- Parent:
- 8:16e88babd42a
- Commit message:
- only test purpose not official
Changed in this revision
LSM9DS1.cpp | Show annotated file Show diff for this revision Revisions of this file |
LSM9DS1.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 16e88babd42a -r e0759c34eb93 LSM9DS1.cpp --- a/LSM9DS1.cpp Mon Jun 19 02:25:48 2017 +0000 +++ b/LSM9DS1.cpp Fri Feb 07 00:53:14 2020 +0000 @@ -7,7 +7,9 @@ mAddress = mAddr; } -bool LSM9DS1::begin(gyro_scale gScl, accel_scale aScl, mag_scale mScl, +/* bool LSM9DS1::begin(gyro_scale gScl, accel_scale aScl, mag_scale mScl, + gyro_odr gODR, accel_odr aODR, mag_odr mODR) */ +uint16_t LSM9DS1::begin(gyro_scale gScl, accel_scale aScl, mag_scale mScl, gyro_odr gODR, accel_odr aODR, mag_odr mODR) { // Store the given scales in class variables. These scale variables @@ -73,7 +75,8 @@ initIntr(); // Once everything is initialized, return the WHO_AM_I registers we read: - return ( ((xgTest << 8) | mTest) == (WHO_AM_I_AG_RSP << 8 | WHO_AM_I_M_RSP) ); + /* return ( ((xgTest << 8) | mTest) == (WHO_AM_I_AG_RSP << 8 | WHO_AM_I_M_RSP) ); */ + return (WHO_AM_I_AG_RSP << 8 | WHO_AM_I_M_RSP); } void LSM9DS1::initGyro() @@ -89,7 +92,8 @@ char cmd[4] = { CTRL_REG1_G, - gScale | G_ODR_119_BW_14, + /*gScale | G_ODR_119_BW_14,*/ + (char)(gScale | G_ODR_119_BW_14), 0x03, // Data pass througn HPF and LPF2, default int out 0x80 // Low-power mode, disable high-pass filter, default cut-off frequency }; @@ -103,7 +107,8 @@ char cmd[4] = { CTRL_REG5_XL, 0x38, // Enable all axis and don't decimate data in out Registers - (A_ODR_119 << 5) | (aScale << 3) | (A_BW_AUTO_SCALE), // 119 Hz ODR, set scale, and auto BW + /* (A_ODR_119 << 5) | (aScale << 3) | (A_BW_AUTO_SCALE), // 119 Hz ODR, set scale, and auto BW */ + (char)((A_ODR_119 << 5) | (aScale << 3) | (A_BW_AUTO_SCALE)), // 119 Hz ODR, set scale, and auto BW 0 // Default resolution mode and filtering settings }; @@ -116,7 +121,8 @@ char cmd[4] = { CTRL_REG1_M, 0x10, // Default data rate, xy axes mode, and temp comp - mScale << 5, // Set mag scale + /* mScale << 5, // Set mag scale */ + (char)(mScale << 5), // Set mag scale 0 // Enable I2C, write only SPI, not LP mode, Continuous conversion mode }; @@ -216,7 +222,8 @@ aBiasRawTemp[1] += ay_raw; aBiasRawTemp[2] += az_raw; */ - wait_ms(1); // 1 ms + /* wait_ms(1); // 1 ms */ + ThisThread::sleep_for(1); samples++; } @@ -249,7 +256,8 @@ } } // - wait_ms(1); // 1 ms + /* wait_ms(1); // 1 ms */ + ThisThread::sleep_for(1); } // @@ -347,8 +355,9 @@ // Temperature is a 12-bit signed integer temperature_raw = data[0] | (data[1] << 8); - temperature_c = (float)temperature_raw / 8.0 + 25; - temperature_f = temperature_c * 1.8 + 32; + // Feb. 5th, 2020 by JH1PJL / Arai + temperature_c = (float)temperature_raw / 16.0 + 25.0; + temperature_f = temperature_c * 1.8 + 32.0; } void LSM9DS1::readGyro()
diff -r 16e88babd42a -r e0759c34eb93 LSM9DS1.h --- a/LSM9DS1.h Mon Jun 19 02:25:48 2017 +0000 +++ b/LSM9DS1.h Fri Feb 07 00:53:14 2020 +0000 @@ -246,7 +246,8 @@ * gyro, 119 Hz for accelerometer, 80 Hz for magnetometer. * Use the return value of this function to verify communication. */ - bool begin(gyro_scale gScl = G_SCALE_2000DPS, + /* bool begin(gyro_scale gScl = G_SCALE_2000DPS, */ + uint16_t begin(gyro_scale gScl = G_SCALE_2000DPS, accel_scale aScl = A_SCALE_8G, mag_scale mScl = M_SCALE_4GS, gyro_odr gODR = G_ODR_119_BW_31, accel_odr aODR = A_ODR_119, mag_odr mODR = M_ODR_80);