diff --git a/README.md b/README.md index 3e79064..2ff638a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,69 @@ # driver-BMI088 - Driver for the BMI088 inertial measurement unit and gyroscope. +As a note: The BMI088 is pretty much two separate chips forced onto one bus. They both have unique chip selects and completely separate registers. Take this into consideration when using this driver. Pretty much everything needs to be done twice. +## Usage +Initialize the accelerometer by using ```init()```. -This driver is untested and is currently missing a readme explanation. \ No newline at end of file +This also wakes up the gyroscope and accelerometer. By default this driver initializes the gyroscope with a +-1000 degrees per second precision and a bandwidth of 64Hz at ODR 1000Hz. The accelerometer is initialized with a +-24G precision and "normal bandwidth" at ODR 100Hz. + +### Setting precision +#### Range +To set the precision of the accelerometer or gyroscope you may use ```setAccelerometerRange(...)```/```setGyroscopeRange(...)```. This only works if the accelerometer or gyroscope are in standby. Use ```setAccelerometerMode(...)``` / ```setGyroscopeMode(...)``` to switch between the different modes (```AccelMode::OFF```,```AccelMode::ON```,```GyroMode::NORMAL_AWAKE```,```GyroMode::SUSPEND```,```GyroMode::DEEP_SUSPEND```). + +Options for +-range include ```AccelRange::_3G```, ```AccelRange::_6G```, ```AccelRange::_12G```, ```AccelRange::_24G``` and ```GyroRange::_2000```,```GyroRange::_1000```,```GyroRange::_500```,```GyroRange::_250```,```GyroRange::_125``` . + + + +#### Bandwidth +Users also have the option to apply a filter, using ```setAccelerometerBandwidth(...)```/```setGyroscopeBandwidth(...)```. For the options, please consult the datasheet. Accelerometer bandwidth uses ```AccelBandwidth::OSRX```or```AccelBandwidth::NORMAL_BANDWIDTH```. Gyroscope bandwidth uses ```_odr_filterbandwidth``` format. + + + +Full example: + +```cpp + +//... (SPI initialization) + + + +//init + +sensor = new sta::BMI088(gyro_device, accel_device); + +if(sensor->init()) STA_DEBUG_PRINTLN("BMI088 init success"); +else STA_DEBUG_PRINTLN("BMI088 init failure"); + + + +//setting precision, bandwidth, odr (chip needs to be OFF!) +sensor->setAccelerometerMode(sta::BMI088::AccelMode::OFF); + +sensor->setAccelerometerRange(sta::BMI088::AccelRange::_24G); +sensor->setAccelerometerBandwidth(sta::BMI088::AccelBandwidth::OSR4, sta::BMI088::AccelODR::_1600); + +sensor->setAccelerometerMode(sta::BMI088::AccelMode::ON); + + + +sensor->setGyroscopeMode(sta::BMI088::GyroMode::DEEP_SUSPEND); + +sensor->setGyroscopeRange(sta::BMI088::GyroRange::_2000); +sensor->setGyroscopeBandwidth(sta::BMI088::GyroBandwidth::_2000_532); + +sensor->setGyroscopeMode(sta::BMI088::GyroMode::NORMAL_AWAKE); + + + +//... + + + +//getting data +float ax, ay, az, rx, ry, rz; +sensor->getRotation(&rx, &ry, &rz); +sensor->getAcceleration(&ax, &ay, &az); + +//... + +``` \ No newline at end of file