Skip to content

Commit

Permalink
Added API to control continuous FIFO mode
Browse files Browse the repository at this point in the history
  • Loading branch information
petewarden committed Feb 11, 2020
1 parent fe00b8a commit 9ff53a8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Arduino_LSM9DS1 ?.?.? - ????.??.??
Arduino_LSM9DS1 1.0.0 - 2019.07.31

* Initial release

Arduino_LSM9DS1 1.1.0 - 2020.02.11

* Added support for FIFO continuous reading of values
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Arduino_LSM9DS1
version=1.0.1
version=1.1.0
author=Arduino
maintainer=Arduino <[email protected]>
sentence=Allows you to read the accelerometer, magnetometer and gyroscope values from the LSM9DS1 IMU on your Arduino Nano 33 BLE Sense.
Expand Down
11 changes: 10 additions & 1 deletion src/LSM9DS1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,21 @@ int LSM9DS1Class::begin()
writeRegister(LSM9DS1_ADDRESS_M, LSM9DS1_CTRL_REG2_M, 0x00); // 4 Gauss
writeRegister(LSM9DS1_ADDRESS_M, LSM9DS1_CTRL_REG3_M, 0x00); // Continuous conversion mode

return 1;
}

void LSM9DS1Class::setContinuousMode() {
// Enable FIFO (see docs https://www.st.com/resource/en/datasheet/DM00103319.pdf)
writeRegister(LSM9DS1_ADDRESS, 0x23, 0x02);
// Set continuous mode
writeRegister(LSM9DS1_ADDRESS, 0x2E, 0xC0);
}

return 1;
void LSM9DS1Class::setOneShotMode() {
// Disable FIFO (see docs https://www.st.com/resource/en/datasheet/DM00103319.pdf)
writeRegister(LSM9DS1_ADDRESS, 0x23, 0x00);
// Disable continuous mode
writeRegister(LSM9DS1_ADDRESS, 0x2E, 0x00);
}

void LSM9DS1Class::end()
Expand Down
5 changes: 5 additions & 0 deletions src/LSM9DS1.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class LSM9DS1Class {
int begin();
void end();

// Controls whether a FIFO is continuously filled, or a single reading is stored.
// Defaults to one-shot.
void setContinuousMode();
void setOneShotMode();

// Accelerometer
virtual int readAcceleration(float& x, float& y, float& z); // Results are in G (earth gravity).
virtual int accelerationAvailable(); // Number of samples in the FIFO.
Expand Down

0 comments on commit 9ff53a8

Please sign in to comment.