Skip to content

Added shaker function #25

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -258,6 +260,7 @@ class BNO08x
bool clearTare();

uint8_t getTapDetector();
uint16_t getShakeDetector();
uint64_t getTimeStamp();
uint16_t getStepCount();
uint8_t getStabilityClassifier();
Expand Down