Skip to content
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

Add function to enable 16G readings from accelerometer #107

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
29 changes: 29 additions & 0 deletions Adafruit_BNO055.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,35 @@ void Adafruit_BNO055::setExtCrystalUse(boolean usextal) {
delay(20);
}



/*!
* @brief Set the Accelerometer to report up to 16G
*/
void Adafruit_BNO055::setAccelConfig16G()
{
adafruit_bno055_opmode_t modeback = _mode;

setMode(OPERATION_MODE_CONFIG);
delay(250);

write8(BNO055_PAGE_ID_ADDR, 1);
delay(500);

uint8_t acc_config_16G = (uint8_t)((BNO055_ACC_PWRMODE_NORMAL << 5)
| (BNO055_ACC_BW_125_HZ << 2)
| BNO055_ACC_CONFIG_16G);
// Configure the accelerometer to report up to 16G of acceleration
write8(ACC_CONFIG, acc_config_16G);
delay(500);

write8(BNO055_PAGE_ID_ADDR, 0);

setMode(modeback);
delay(20);
}


/*!
* @brief Gets the latest system status info
* @param system_status
Expand Down
16 changes: 14 additions & 2 deletions Adafruit_BNO055.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
/** Offsets registers **/
#define NUM_BNO055_OFFSET_REGISTERS (22)

/** Accelerometer config values **/
#define BNO055_ACC_PWRMODE_NORMAL (0)
#define BNO055_ACC_BW_125_HZ (4)
#define BNO055_ACC_CONFIG_16G (3)

/** A structure to represent offsets **/
typedef struct {
int16_t accel_offset_x; /**< x acceleration offset */
Expand Down Expand Up @@ -198,7 +203,7 @@ class Adafruit_BNO055 : public Adafruit_Sensor {
MAG_OFFSET_Z_LSB_ADDR = 0X5F,
MAG_OFFSET_Z_MSB_ADDR = 0X60,

/* Gyroscope Offset register s*/
/* Gyroscope Offset registers */
GYRO_OFFSET_X_LSB_ADDR = 0X61,
GYRO_OFFSET_X_MSB_ADDR = 0X62,
GYRO_OFFSET_Y_LSB_ADDR = 0X63,
Expand All @@ -210,7 +215,11 @@ class Adafruit_BNO055 : public Adafruit_Sensor {
ACCEL_RADIUS_LSB_ADDR = 0X67,
ACCEL_RADIUS_MSB_ADDR = 0X68,
MAG_RADIUS_LSB_ADDR = 0X69,
MAG_RADIUS_MSB_ADDR = 0X6A
MAG_RADIUS_MSB_ADDR = 0X6A,

/* Accelerometer config register */
ACC_CONFIG = 0x08

} adafruit_bno055_reg_t;

/** BNO055 power settings */
Expand Down Expand Up @@ -313,6 +322,9 @@ class Adafruit_BNO055 : public Adafruit_Sensor {
/* Power managments functions */
void enterSuspendMode();
void enterNormalMode();

/* Accelerometer config functions */
void setAccelConfig16G();

private:
byte read8(adafruit_bno055_reg_t);
Expand Down