diff --git a/README.md b/README.md index 48bf8c9..a3cd353 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ SparkFun VR IMU BNO08X Arduino Library =========================================================== +Added shaker detection function to the main .cpp and .h file [![SparkFun VR IMU Breakout - BNO086 (Qwiic)](https://cdn.sparkfun.com/r/600-600/assets/parts/2/3/0/2/7/22857-SEN_SparkFun_VR_IMU_Breakout-BNO086_Qwiic-_01.jpg)](https://www.sparkfun.com/products/22857) diff --git a/src/SparkFun_BNO08x_Arduino_Library.cpp b/src/RosA_BNO08x_Arduino_Library.cpp similarity index 98% rename from src/SparkFun_BNO08x_Arduino_Library.cpp rename to src/RosA_BNO08x_Arduino_Library.cpp index 3a5c6ad..df7030a 100644 --- a/src/SparkFun_BNO08x_Arduino_Library.cpp +++ b/src/RosA_BNO08x_Arduino_Library.cpp @@ -40,7 +40,7 @@ Thank you Adafruit and your developers for all your hard work put into your Library! */ -#include "SparkFun_BNO08x_Arduino_Library.h" +#include "RosA_BNO08x_Arduino_Library.h" int8_t _int_pin = -1, _reset_pin = -1; static TwoWire *_i2cPort = NULL; //The generic connection to user's chosen I2C hardware @@ -616,11 +616,18 @@ float BNO08x::getGyroIntegratedRVangVelZ() //Return the tap detector uint8_t BNO08x::getTapDetector() { - uint8_t previousTapDetector = tapDetector; - tapDetector = 0; //Reset so user code sees exactly one tap - return (previousTapDetector); +// uint8_t previousTapDetector = tapDetector; +// tapDetector = 0; //Reset so user code sees exactly one tap +// return (previousTapDetector); + return _sensor_value->un.tapDetector.flags; +} +//Return shake detector +uint16_t BNO08x::getShakeDetector() +{ + return _sensor_value->un.shakeDetector.shake; } + //Return the step count uint16_t BNO08x::getStepCount() { @@ -904,6 +911,13 @@ bool BNO08x::enableTapDetector(uint16_t timeBetweenReports) return enableReport(SENSOR_REPORTID_TAP_DETECTOR, timeBetweenReports); } +//Sends the packet to enable the shake detector +bool BNO08x::enableShakeDetector(uint16_t timeBetweenReports) +{ + timeBetweenReports = timeBetweenReports * 1000; // ms to us + return enableReport(SENSOR_REPORTID_SHAKE_DETECTOR, timeBetweenReports); +} + //Sends the packet to enable the step counter bool BNO08x::enableStepCounter(uint16_t timeBetweenReports) { diff --git a/src/SparkFun_BNO08x_Arduino_Library.h b/src/RosA_BNO08x_Arduino_Library.h similarity index 98% rename from src/SparkFun_BNO08x_Arduino_Library.h rename to src/RosA_BNO08x_Arduino_Library.h index 3018819..6b35907 100644 --- a/src/SparkFun_BNO08x_Arduino_Library.h +++ b/src/RosA_BNO08x_Arduino_Library.h @@ -105,6 +105,7 @@ #define SENSOR_REPORTID_RAW_ACCELEROMETER 0x14 #define SENSOR_REPORTID_RAW_GYROSCOPE 0x15 #define SENSOR_REPORTID_RAW_MAGNETOMETER 0x16 +#define SENSOR_REPORTID_SHAKE_DETECTOR 0x19 #define SENSOR_REPORTID_PERSONAL_ACTIVITY_CLASSIFIER SH2_PERSONAL_ACTIVITY_CLASSIFIER #define SENSOR_REPORTID_AR_VR_STABILIZED_ROTATION_VECTOR 0x28 #define SENSOR_REPORTID_AR_VR_STABILIZED_GAME_ROTATION_VECTOR 0x29 @@ -181,6 +182,7 @@ class BNO08x bool enableGyro(uint16_t timeBetweenReports = 10); bool enableUncalibratedGyro(uint16_t timeBetweenReports = 10); bool enableMagnetometer(uint16_t timeBetweenReports = 10); + bool enableShakeDetector(uint16_t timeBetweenReports = 10); bool enableTapDetector(uint16_t timeBetweenReports); bool enableStepCounter(uint16_t timeBetweenReports = 10); bool enableStabilityClassifier(uint16_t timeBetweenReports = 10); @@ -258,6 +260,7 @@ class BNO08x bool clearTare(); uint8_t getTapDetector(); + uint16_t getShakeDetector(); uint64_t getTimeStamp(); uint16_t getStepCount(); uint8_t getStabilityClassifier();