.

Dependencies:   BNO055 SDFileSystem mbed

main.cpp

Committer:
alejo5214416
Date:
2018-09-06
Revision:
2:54bb4cee7885
Parent:
1:74fb432755d0
Child:
3:a4a031655cda

File content as of revision 2:54bb4cee7885:

#include "mbed.h"
#include "BNO055.h"
#define TS 0.1
using namespace std;
 
DigitalOut led1(LED1);
DigitalOut green(p21);
DigitalOut blue(p22);
DigitalOut red(p23);

Serial pc(USBTX, USBRX); 
// BNO055
BNO055 bno055(p9, p10);
InterruptIn interrupt(p15, PullUp); 

 
 
void event();
int main() {
    bno055.reset();
    bno055.setmode(OPERATION_MODE_NDOF);
    bno055.write_calibration_data();
    bno055.get_calib();
    interrupt.rise(&event);
    while (bno055.calib == 0) {
        bno055.get_calib();
    }
        if (bno055.check()){
        bno055.initIntr();
        }
        
    while(1) {
        
        bno055.get_angles(); //query the i2c device
        pc.printf("yaw:%6.2f pitch:%6.2f roll:%6.2f\r\n",bno055.euler.yaw, bno055.euler.pitch, bno055.euler.roll);
        bno055.get_lia(); //query the i2c device
        pc.printf("X: %3.2f, Y: %3.2f, Z: %3.2f\r\n",bno055.lia.x,bno055.lia.y,bno055.lia.z);
        wait_ms(TS);
        
    }
}


void event(){
    led1 = !led1;
    //wait(10);
    /*
    float v_act=0;
    float x_act=0;
    float v_ant=0;
    float x_ant=0;
        bno055.get_angles(); //query the i2c device
        bno055.get_lia(); //query the i2c device
        v_act = v_ant + TS*float(bno055.lia.x);
        wait(TS);
        pc.printf("V_act = %f",v_act);
        */
    bno055.resetIntr();
    }