-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from TeamSunride/restructure
Restructure into library
- Loading branch information
Showing
24 changed files
with
231 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: PlatformIO CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build_example: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
examples: [ | ||
examples/accelmaggyro.cpp, | ||
examples/accgyro.cpp, | ||
examples/accmag.cpp, | ||
examples/acconly.cpp, | ||
examples/euler.cpp, | ||
examples/gyroonly.cpp, | ||
examples/maggyro.cpp, | ||
examples/magonly.cpp, | ||
examples/quaternion.cpp, | ||
examples/interrupts/accelAnyMotionInterrupt.cpp, | ||
examples/interrupts/accelHighGInterrupt.cpp, | ||
examples/interrupts/gyroAnyMotionInterrupt.cpp, | ||
examples/interrupts/gyroHighRateInterrupt.cpp, | ||
examples/interrupts/noMotionInterrupt.cpp, | ||
examples/interrupts/slowMotionInterrupt.cpp | ||
] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Cache pip | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Cache PlatformIO | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.platformio | ||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
|
||
- name: Install PlatformIO | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --upgrade platformio | ||
- name: Run PlatformIO | ||
run: pio ci --lib "." --board teensy41 | ||
env: | ||
PLATFORMIO_CI_SRC: ${{ matrix.examples }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
CMakeListsPrivate.txt | ||
cmake-build-*/ | ||
.idea | ||
pyteaplot.py | ||
pyteaplot.py | ||
/test/tmp_pio_test_transport.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# Arduino BNO055 Library | ||
|
||
![](resources/BNO055.jpg) | ||
|
||
*image credit: Adafruit* | ||
|
||
PlatformIO / Arduino library designed to make it easy to use | ||
advanced features of the Bosch BNO055 IMU. | ||
|
||
Developed by [Tom Danvers](https://github.com/TomD53) | ||
|
||
## Features | ||
|
||
- Power mode configuration | ||
- Operation mode configuration | ||
- Sensor reset | ||
- Sensor self test | ||
- Methods to read from all operation modes, converted to useful units | ||
- Burst read of all data | ||
- Sensor configuration (set G range, sample rate, power mode - | ||
this requires reading of the datasheet) | ||
- View sensor calibration | ||
- Implementation of all interrupts | ||
- `AccelHighGInterrupt` | ||
- `AccelSlowNoMotionInterrupt` | ||
- `AccelAnyMotionInterrupt` | ||
- `GyroHighRateInterrupt` | ||
- `GyroAnyMotionInterrupt` | ||
|
||
## TODO | ||
|
||
- Sensor configuration could be improved / made more intuitive. You need to work out what value to write to the | ||
config register by reading the datasheet. | ||
- Axis remap is not implemented (yet) | ||
- Calibration parameters cannot yet be saved and re-applied after a sensor restart | ||
|
||
## Examples | ||
|
||
Refer to the [examples directory](examples) | ||
|
||
To run an example (in PlatformIO), modify platformio.ini to support your board/framework, and then run the following: | ||
|
||
pio ci "examples/accgyro.cpp" --lib "." -c "platformio.ini" | ||
|
||
### Read from accelerometer | ||
|
||
```cpp | ||
#include <Arduino.h> | ||
#include "BNO055.h" | ||
|
||
const byte I2C_ADDRESS = 0x28; | ||
|
||
BNO055 sensor(I2C_ADDRESS, &Wire); | ||
|
||
void setup() { | ||
Wire.begin(); | ||
sensor.begin(); | ||
sensor.setOperationMode(ACCONLY); | ||
} | ||
|
||
void loop() { | ||
Vector<double> accelVector = sensor.getRawAcceleration(); | ||
Serial.println((String)accelVector.getX() + "," + (String)accelVector.getY() + "," | ||
+ (String)accelVector.getZ() + ","); | ||
} | ||
``` | ||
### Register Accelerometer High G interrupt | ||
```cpp | ||
#include <Arduino.h> | ||
#include "BNO055.h" | ||
const byte I2C_ADDRESS = 0x28; | ||
BNO055 sensor(I2C_ADDRESS, &Wire); | ||
// define our callback (known as an ISR, or interrupt service routine) to be called when the interrupt is | ||
// detected. Note that ISRs have various limitations. | ||
void myCallback() { | ||
digitalWrite(3, !digitalRead(3)); | ||
} | ||
void setup() { | ||
// begin I2C communication | ||
Wire.begin(); | ||
// reset the sensor to remove any existing configuration | ||
sensor.resetSystem(); | ||
// we need to be in configmode to set up the interrupt. | ||
// this is not necessary as we just called sensor#resetSystem however it is here for completeness | ||
sensor.setOperationMode(CONFIGMODE); | ||
// define the configuration of our interrupt | ||
BNO055::AccelHighGInterrupt interrupt( | ||
sensor, | ||
(new BNO055::Interrupt::EnabledAxes)->enableX().enableY().enableZ(), | ||
myCallback, | ||
2); | ||
// write the configuration to the BNO055 | ||
interrupt.setup(); | ||
// enable this interrupt | ||
interrupt.enable(); | ||
// route this interrupt to the INT pin on the sensor | ||
interrupt.mask(); | ||
// enter the ACCONLY operation mode (note that the above code must run in COMFIGMODE) | ||
sensor.setOperationMode(ACCONLY); | ||
pinMode(3, OUTPUT); | ||
} | ||
void loop() { | ||
// we constantly clear the interrupt on the sensor. Not an ideal solution and not efficient, but | ||
// works for this example | ||
sensor.clearInterrupt(); | ||
} | ||
``` | ||
|
||
## Documentation | ||
|
||
Most/all methods are documented well in [`BNO055.h`](src/BNO055.h). | ||
|
||
Refer to the [examples directory](examples) and also the [unit test](test/test_BNO055.cpp) for usage examples. | ||
|
||
The best way of understanding how things work is to [read the datasheet](datasheet.pdf) | ||
|
||
## Unit testing | ||
|
||
This project contains some automated unit tests that you can run to check that everything works. | ||
You need to do this with PlatformIO. | ||
|
||
If you aren't using a Teensy 4.1, modify the configuration in `platformio.ini` | ||
|
||
To run the unit tests, run ```pio test``` | ||
|
||
![](resources/test_result.png) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Run an example and upload / monitor it | ||
|
||
pio ci "examples/accgyro.cpp" --lib "." -c "platformio.ini" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "Arduino-BNO055", | ||
"version": "1.0.0", | ||
"description": "PlatformIO / Arduino library designed to make it easy to use advanced features of the Bosch BNO055 IMU.", | ||
"keywords": "arduino, sensor, BNO055, adafruit, interrupt, IMU", | ||
"repository": | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/TeamSunride/Arduino-BNO055" | ||
}, | ||
"authors": | ||
[ | ||
{ | ||
"name": "Tom Danvers", | ||
"url": "https://tdanvers.com/", | ||
"maintainer": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; https://docs.platformio.org/page/projectconf.html | ||
|
||
[env:teensy41] | ||
; the parameters below will be specific to your board/platform/environment | ||
platform = teensy | ||
board = teensy41 | ||
framework = arduino | ||
upload_protocol = teensy-cli | ||
extra_scripts = extra_script.py | ||
test_port = COM3 | ||
test_port = COM3 | ||
|
||
; the parameters below are required | ||
test_build_project_src = true | ||
targets=upload, monitor |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.