Skip to content

Add tap detector #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enableARVRStabilizedGameRotationVector KEYWORD2
enableAccelerometer KEYWORD2
enableGyro KEYWORD2
enableMagnetometer KEYWORD2
enableTapDetector KEYWORD2
enableStepCounter KEYWORD2
enableStabilityClassifier KEYWORD2
enableActivityClassifier KEYWORD2
Expand Down Expand Up @@ -98,6 +99,7 @@ saveCalibration KEYWORD2
requestCalibrationStatus KEYWORD2
calibrationComplete KEYWORD2

getTapDetector KEYWORD2
getTimeStamp KEYWORD2
getStepCount KEYWORD2
getStabilityClassifier KEYWORD2
Expand Down
18 changes: 18 additions & 0 deletions src/SparkFun_BNO080_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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)
{
Expand Down
3 changes: 3 additions & 0 deletions src/SparkFun_BNO080_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down