diff --git a/keywords.txt b/keywords.txt index 40771b2..c0ccb51 100644 --- a/keywords.txt +++ b/keywords.txt @@ -37,6 +37,7 @@ enableARVRStabilizedGameRotationVector KEYWORD2 enableAccelerometer KEYWORD2 enableGyro KEYWORD2 enableMagnetometer KEYWORD2 +enableTapDetector KEYWORD2 enableStepCounter KEYWORD2 enableStabilityClassifier KEYWORD2 enableActivityClassifier KEYWORD2 @@ -98,6 +99,7 @@ saveCalibration KEYWORD2 requestCalibrationStatus KEYWORD2 calibrationComplete KEYWORD2 +getTapDetector KEYWORD2 getTimeStamp KEYWORD2 getStepCount KEYWORD2 getStabilityClassifier KEYWORD2 diff --git a/src/SparkFun_BNO080_Arduino_Library.cpp b/src/SparkFun_BNO080_Arduino_Library.cpp index 16ce758..4d3a903 100644 --- a/src/SparkFun_BNO080_Arduino_Library.cpp +++ b/src/SparkFun_BNO080_Arduino_Library.cpp @@ -345,6 +345,10 @@ uint16_t BNO080::parseInputReport(void) // not game rot vector and not ar/vr stabilized rotation vector rawQuatRadianAccuracy = data5; } + else if (shtpData[5] == SENSOR_REPORTID_TAP_DETECTOR) + { + tapDetector = shtpData[5 + 4]; //Byte 4 only + } else if (shtpData[5] == SENSOR_REPORTID_STEP_COUNTER) { stepCount = data3; //Bytes 8/9 @@ -717,6 +721,14 @@ float BNO080::getFastGyroZ() return (gyro); } +//Return the tap detector +uint8_t BNO080::getTapDetector() +{ + uint8_t previousTapDetector = tapDetector; + tapDetector = 0; //Reset so user code sees exactly one tap + return (previousTapDetector); +} + //Return the step count uint16_t BNO080::getStepCount() { @@ -1036,6 +1048,12 @@ void BNO080::enableGyroIntegratedRotationVector(uint16_t timeBetweenReports) setFeatureCommand(SENSOR_REPORTID_GYRO_INTEGRATED_ROTATION_VECTOR, timeBetweenReports); } +//Sends the packet to enable the tap detector +void BNO080::enableTapDetector(uint16_t timeBetweenReports) +{ + setFeatureCommand(SENSOR_REPORTID_TAP_DETECTOR, timeBetweenReports); +} + //Sends the packet to enable the step counter void BNO080::enableStepCounter(uint16_t timeBetweenReports) { diff --git a/src/SparkFun_BNO080_Arduino_Library.h b/src/SparkFun_BNO080_Arduino_Library.h index 201d896..ebcbdd7 100644 --- a/src/SparkFun_BNO080_Arduino_Library.h +++ b/src/SparkFun_BNO080_Arduino_Library.h @@ -151,6 +151,7 @@ class BNO080 void enableLinearAccelerometer(uint16_t timeBetweenReports); void enableGyro(uint16_t timeBetweenReports); void enableMagnetometer(uint16_t timeBetweenReports); + void enableTapDetector(uint16_t timeBetweenReports); void enableStepCounter(uint16_t timeBetweenReports); void enableStabilityClassifier(uint16_t timeBetweenReports); void enableActivityClassifier(uint16_t timeBetweenReports, uint32_t activitiesToEnable, uint8_t (&activityConfidences)[9]); @@ -211,6 +212,7 @@ class BNO080 void requestCalibrationStatus(); //Sends command to get status boolean calibrationComplete(); //Checks ME Cal response for byte 5, R0 - Status + uint8_t getTapDetector(); uint32_t getTimeStamp(); uint16_t getStepCount(); uint8_t getStabilityClassifier(); @@ -276,6 +278,7 @@ class BNO080 uint16_t rawMagX, rawMagY, rawMagZ, magAccuracy; uint16_t rawQuatI, rawQuatJ, rawQuatK, rawQuatReal, rawQuatRadianAccuracy, quatAccuracy; uint16_t rawFastGyroX, rawFastGyroY, rawFastGyroZ; + uint8_t tapDetector; uint16_t stepCount; uint32_t timeStamp; uint8_t stabilityClassifier;