diff --git a/examples/magic_wand/imu_provider.h b/examples/magic_wand/imu_provider.h index a2d0cd5..d7d6ad7 100644 --- a/examples/magic_wand/imu_provider.h +++ b/examples/magic_wand/imu_provider.h @@ -1,7 +1,12 @@ #ifndef MAGIC_WAND_IMU_PROVIDER_H #define MAGIC_WAND_IMU_PROVIDER_H +#ifdef NANO33_BLE_REV2 +#include +#else #include +#endif + #include namespace { @@ -60,7 +65,7 @@ namespace { *new_accelerometer_samples = 0; *new_gyroscope_samples = 0; // Loop through new samples and add to buffer - while (IMU.accelerationAvailable()) { + if (IMU.accelerationAvailable()) { const int gyroscope_index = (gyroscope_data_index % gyroscope_data_length); gyroscope_data_index += 3; float* current_gyroscope_data = &gyroscope_data[gyroscope_index]; @@ -68,7 +73,6 @@ namespace { if (!IMU.readGyroscope( current_gyroscope_data[0], current_gyroscope_data[1], current_gyroscope_data[2])) { Serial.println("Failed to read gyroscope data"); - break; } *new_gyroscope_samples += 1; @@ -79,7 +83,6 @@ namespace { if (!IMU.readAcceleration( current_acceleration_data[0], current_acceleration_data[1], current_acceleration_data[2])) { Serial.println("Failed to read acceleration data"); - break; } *new_accelerometer_samples += 1; } @@ -89,7 +92,7 @@ namespace { // Keep track of whether we stored any new data int new_samples = 0; // Loop through new samples and add to buffer - while (IMU.gyroscopeAvailable()) { + if (IMU.gyroscopeAvailable()) { const int index = (gyroscope_data_index % gyroscope_data_length); gyroscope_data_index += 3; float* data = &gyroscope_data[index]; diff --git a/examples/magic_wand/magic_wand.ino b/examples/magic_wand/magic_wand.ino index 5c4e0de..3729a65 100644 --- a/examples/magic_wand/magic_wand.ino +++ b/examples/magic_wand/magic_wand.ino @@ -12,6 +12,9 @@ limitations under the License. #include +// If you are using a Nano 33 BLE rev2, uncomment the next line: +// #define NANO33_BLE_REV2 + #include "tensorflow/lite/micro/micro_error_reporter.h" #include "tensorflow/lite/micro/micro_interpreter.h" #include "tensorflow/lite/micro/micro_mutable_op_resolver.h" @@ -63,6 +66,8 @@ namespace { void setup() { // Start serial Serial.begin(9600); + while (!Serial); + Serial.println("Started"); // Start IMU diff --git a/examples/test_IMU/test_IMU.ino b/examples/test_IMU/test_IMU.ino index 4b3d646..23df532 100644 --- a/examples/test_IMU/test_IMU.ino +++ b/examples/test_IMU/test_IMU.ino @@ -6,7 +6,14 @@ Requires the Arduino_LSM9DS1 library library */ +// If you are using a Nano 33 BLE rev2, uncomment the next line: +// #define NANO33_BLE_REV2 + +#ifdef NANO33_BLE_REV2 +#include +#else #include +#endif int imuIndex = 0; // 0 - accelerometer, 1 - gyroscope, 2 - magnetometer bool commandRecv = false; // flag used for indicating receipt of commands from serial port @@ -22,6 +29,8 @@ void setup() { while (1); } + IMU.setContinuousMode(); + Serial.println("Welcome to the IMU test for the built-in IMU on the Nano 33 BLE Sense\n"); Serial.println("Available commands:"); Serial.println("a - display accelerometer readings in g's in x, y, and z directions");