![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
IMU LSM9DS1 Library
Fork of LSM9DS1_Library by
Diff: LSM9DS1.cpp
- Revision:
- 4:e1404cbaf2a9
- Parent:
- 3:585984c4a4b1
- Child:
- 5:58710c38076c
--- a/LSM9DS1.cpp Tue Jul 19 20:53:34 2016 +0000 +++ b/LSM9DS1.cpp Wed Jul 20 21:38:08 2016 +0000 @@ -63,7 +63,7 @@ // 1 = 14.9 4 = 238 // 2 = 59.5 5 = 476 // 3 = 119 6 = 952 - settings.gyro.sampleRate = 6; + settings.gyro.sampleRate = 1; // gyro cutoff frequency: value between 0-3 // Actual value of cutoff frequency depends // on sample rate. @@ -90,7 +90,7 @@ // 1 = 10 Hz 4 = 238 Hz // 2 = 50 Hz 5 = 476 Hz // 3 = 119 Hz 6 = 952 Hz - settings.accel.sampleRate = 6; + settings.accel.sampleRate = 1; // Accel cutoff freqeuncy can be any value between -1 - 3. // -1 = bandwidth determined by sample rate // 0 = 408 Hz 2 = 105 Hz @@ -111,7 +111,7 @@ // 1 = 1.25 Hz 5 = 20 Hz // 2 = 2.5 Hz 6 = 40 Hz // 3 = 5 Hz 7 = 80 Hz - settings.mag.sampleRate = 7; + settings.mag.sampleRate = 4; settings.mag.tempCompensationEnable = false; // magPerformance can be any value between 0-3 // 0 = Low power mode 2 = high performance @@ -1121,30 +1121,13 @@ uint8_t LSM9DS1::I2CreadByte(uint8_t address, uint8_t subAddress) { - /* - int timeout = LSM9DS1_COMMUNICATION_TIMEOUT; - uint8_t data; // `data` will store the register data - - Wire.beginTransmission(address); // Initialize the Tx buffer - Wire.write(subAddress); // Put slave register address in Tx buffer - Wire.endTransmission(true); // Send the Tx buffer, but send a restart to keep connection alive - Wire.requestFrom(address, (uint8_t) 1); // Read one byte from slave register address - while ((Wire.available() < 1) && (timeout-- > 0)) - delay(1); + char data; + char temp = subAddress; - if (timeout <= 0) - return 255; //! Bad! 255 will be misinterpreted as a good value. - - data = Wire.read(); // Fill Rx buffer with result - return data; // Return data read from slave register - */ - char data; - char temp[1] = {subAddress}; - - i2c.write(address, temp, 1); + //i2c.write(address, temp, 1); //i2c.write(address & 0xFE); - temp[1] = 0x00; - i2c.write(address, temp, 1); + //temp[1] = 0x00; + i2c.write(address, &temp, 1); //i2c.write( address | 0x01); int a = i2c.read(address, &data, 1); return data;