diff --git a/examples/LSM6DSOX_FIFO_Interrupt/LSM6DSOX_FIFO_Interrupt.ino b/examples/LSM6DSOX_FIFO_Interrupt/LSM6DSOX_FIFO_Interrupt.ino index 70362a8..e909a32 100644 --- a/examples/LSM6DSOX_FIFO_Interrupt/LSM6DSOX_FIFO_Interrupt.ino +++ b/examples/LSM6DSOX_FIFO_Interrupt/LSM6DSOX_FIFO_Interrupt.ino @@ -45,8 +45,8 @@ #include "LSM6DSOXSensor.h" -#define SR 417.0f // Sample rate. Options are: 12.5, 26, 52, 104, 208, 417, 833, 1667, 3333 and 6667 Hz -#define WTM_LV 102 // Watermark threshold level. Max samples in this FIFO configuration is 512 (accel and gyro only). +#define SR 104.0f // Sample rate. Options are: 12.5, 26, 52, 104, 208, 417, 833, 1667, 3333 and 6667 Hz +#define WTM_LV 199 // Watermark threshold level. Max samples in this FIFO configuration is 512 (accel and gyro only). // Define interrupt pins according to MCU board and sensor wiring. #define INT1_pin A0 // MCU input pin connected to sensor INT1 output pin @@ -150,6 +150,7 @@ void loop() { lsm6dsoxSensor.Get_FIFO_Num_Samples(&numSamples); Serial.print("Samples in FIFO: "); Serial.println(numSamples); + Serial.flush(); // Check if FIFO threshold level was reached. if (fullFlag != 0) { @@ -159,11 +160,13 @@ void loop() { if(fullStatus) { Serial.println("-- FIFO Watermark level reached!, fetching data."); + Serial.flush(); lsm6dsoxSensor.Get_FIFO_Num_Samples(&numSamples); Serial.print("numSamples="); Serial.println(numSamples); + Serial.flush(); // fetch data from FIFO for (uint16_t i = 0; i < numSamples; i++) { @@ -179,6 +182,7 @@ void loop() { Serial.print(", "); Serial.print(rotation[1]); Serial.print(", "); Serial.print(rotation[2]); Serial.println(); + Serial.flush(); #endif } @@ -191,6 +195,7 @@ void loop() { Serial.print(", "); Serial.print(acceleration[1]); Serial.print(", "); Serial.print(acceleration[2]); Serial.println(); + Serial.flush(); #endif } @@ -206,6 +211,7 @@ void loop() { Serial.println(count_gyro_samples); Serial.print("Dummy Samples: "); Serial.println(count_dummy_samples); + Serial.flush(); } } -} \ No newline at end of file +} diff --git a/examples/LSM6DSOX_FIFO_Polling/LSM6DSOX_FIFO_Polling.ino b/examples/LSM6DSOX_FIFO_Polling/LSM6DSOX_FIFO_Polling.ino index e1832bb..cebc063 100644 --- a/examples/LSM6DSOX_FIFO_Polling/LSM6DSOX_FIFO_Polling.ino +++ b/examples/LSM6DSOX_FIFO_Polling/LSM6DSOX_FIFO_Polling.ino @@ -44,8 +44,8 @@ #include "LSM6DSOXSensor.h" -#define SR 417 // Sample rate. Options are: 12.5, 26, 52, 104, 208, 417, 833, 1667, 3333 and 6667 Hz. -#define WTM_LV 500 // Watermark threshold level. Max samples in this FIFO configuration is 512 (accel and gyro only). +#define SR 104 // Sample rate. Options are: 12.5, 26, 52, 104, 208, 417, 833, 1667, 3333 and 6667 Hz. +#define WTM_LV 199 // Watermark threshold level. Max samples in this FIFO configuration is 512 (accel and gyro only). /** LSM6DSOX i2c address: * LSM6DSOX_I2C_ADD_L: 0x6A (default) @@ -55,7 +55,7 @@ LSM6DSOXSensor lsm6dsoxSensor = LSM6DSOXSensor(&Wire, LSM6DSOX_I2C_ADD_L); void setup() { - Serial.begin(115200); + Serial.begin(921600); // Comment this line to skip waiting for serial: while(!Serial) delay(10); @@ -127,12 +127,14 @@ void loop() { // Get number of samples in buffer lsm6dsoxSensor.Get_FIFO_Num_Samples(&numSamples); Serial.print("Samples in FIFO: "); Serial.println(numSamples); + Serial.flush(); // Check if FIFO threshold level was reached. lsm6dsoxSensor.Get_FIFO_Watermark_Status(&wtmStatus); if (wtmStatus != 0) { Serial.println("-- FIFO Watermark level reached!, fetching data."); + Serial.flush(); // fetch data from FIFO for (uint16_t i = 0; i < WTM_LV; i++) { @@ -142,22 +144,24 @@ void loop() { // Get gyroscope data if (Tag == 1) { lsm6dsoxSensor.Get_FIFO_G_Axes(rotation); - #if 0 // set to 1 for printing values + #if 1 // set to 1 for printing values Serial.print("mdps: "); Serial.print(rotation[0]); Serial.print(", "); Serial.print(rotation[1]); Serial.print(", "); Serial.print(rotation[2]); Serial.println(); + Serial.flush(); #endif } // Get accelerometer data else if (Tag == 2) { lsm6dsoxSensor.Get_FIFO_X_Axes(acceleration); - #if 0 // set to 1 for printing values + #if 1 // set to 1 for printing values Serial.print("mG: "); Serial.print(acceleration[0]); Serial.print(", "); Serial.print(acceleration[1]); Serial.print(", "); Serial.print(acceleration[2]); Serial.println(); + Serial.flush(); #endif } } @@ -168,6 +172,7 @@ void loop() { if (fullStatus != 0) { Serial.println("-- FIFO is full!, consider reducing Watermark Level or Buffer Data Rate.\nFlushing data from FIFO."); + Serial.flush(); lsm6dsoxSensor.Set_FIFO_Mode(LSM6DSOX_BYPASS_MODE); // flush FIFO data lsm6dsoxSensor.Set_FIFO_Mode(LSM6DSOX_STREAM_MODE); // continue batching } diff --git a/library.properties b/library.properties index 60acbfc..6146808 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=STM32duino LSM6DSOX -version=2.3.1 +version=2.3.2 author=SRA maintainer=stm32duino sentence=Ultra Low Power inertial measurement unit.