11#ifndef MAGIC_WAND_IMU_PROVIDER_H
22#define MAGIC_WAND_IMU_PROVIDER_H
33
4+ #ifdef NANO33_BLE_REV2
5+ #include < Arduino_BMI270_BMM150.h>
6+ #else
47#include < Arduino_LSM9DS1.h>
8+ #endif
9+
510#include < ArduinoBLE.h>
611
712namespace {
@@ -60,15 +65,14 @@ namespace {
6065 *new_accelerometer_samples = 0 ;
6166 *new_gyroscope_samples = 0 ;
6267 // Loop through new samples and add to buffer
63- while (IMU.accelerationAvailable ()) {
68+ if (IMU.accelerationAvailable ()) {
6469 const int gyroscope_index = (gyroscope_data_index % gyroscope_data_length);
6570 gyroscope_data_index += 3 ;
6671 float * current_gyroscope_data = &gyroscope_data[gyroscope_index];
6772 // Read each sample, removing it from the device's FIFO buffer
6873 if (!IMU.readGyroscope (
6974 current_gyroscope_data[0 ], current_gyroscope_data[1 ], current_gyroscope_data[2 ])) {
7075 Serial.println (" Failed to read gyroscope data" );
71- break ;
7276 }
7377 *new_gyroscope_samples += 1 ;
7478
@@ -79,7 +83,6 @@ namespace {
7983 if (!IMU.readAcceleration (
8084 current_acceleration_data[0 ], current_acceleration_data[1 ], current_acceleration_data[2 ])) {
8185 Serial.println (" Failed to read acceleration data" );
82- break ;
8386 }
8487 *new_accelerometer_samples += 1 ;
8588 }
@@ -89,7 +92,7 @@ namespace {
8992 // Keep track of whether we stored any new data
9093 int new_samples = 0 ;
9194 // Loop through new samples and add to buffer
92- while (IMU.gyroscopeAvailable ()) {
95+ if (IMU.gyroscopeAvailable ()) {
9396 const int index = (gyroscope_data_index % gyroscope_data_length);
9497 gyroscope_data_index += 3 ;
9598 float * data = &gyroscope_data[index];
0 commit comments