fsdf
Dependencies: BNO055_fusion MODSERIAL mbed
Fork of Shared-1BNO055 by
Diff: main.cpp
- Revision:
- 8:41d1f9ab3be0
- Parent:
- 7:d4b5e83c7947
- Child:
- 9:7be40e42e578
--- a/main.cpp Mon Feb 01 00:20:46 2016 +0000 +++ b/main.cpp Wed Feb 03 14:52:21 2016 +0000 @@ -27,10 +27,12 @@ // Object ---------------------------------------------------------------------------------------- MODSERIAL pc(USBTX,USBRX); -volatile bool Capture = true; -volatile bool SaveFile = false; +volatile bool RAW = true; +volatile bool FUS = false; bool printed = false; +//string sdata = ""; + DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); @@ -62,9 +64,17 @@ void rxCallback(MODSERIAL_IRQ_INFO *q) { MODSERIAL *serial = q->serial; - if ( serial->rxGetLastChar() == 'S') { - Capture = false; - SaveFile = true; + if ( serial->rxGetLastChar() == 'f') { + imu.write_reg0(0x3d, 0x0c); + RAW = false; + FUS = true; + pc.printf("\r\nSWITCHING TO FUSION DATA!\r\n"); + } + if ( serial->rxGetLastChar() == 'r') { + imu.write_reg0(0x3d, 0x07); + RAW = true; + FUS = false; + pc.printf("\r\nSWITCHING TO RAW DATA!\r\n"); } } @@ -75,9 +85,7 @@ // Please refer BNO055 Data sheet 3.10 Calibration & 3.6.4 Sensor calibration data void bno055_calbration(void) { - uint8_t d; - pc.printf("------ Enter BNO055 Manual Calibration Mode ------\r\n"); //---------- Gyroscope Caliblation ------------------------------------------------------------ // (a) Place the device in a single stable position for a period of few seconds to allow the @@ -142,10 +150,18 @@ t.stop(); } -//-------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +// Main Program +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- int main() { - pc.baud(9600); + pc.baud(115200); pc.attach(&rxCallback, MODSERIAL::RxIrq); pc.printf("BNO055 Hello World\r\n\r\n"); imu.set_mounting_position(MT_P6); @@ -176,40 +192,39 @@ if (c == 'y') { bno055_calbration(); } - pc.printf("[E]:Euler Angles[deg],[Q]:Quaternion[],[L]:Linear accel[m/s*s],"); - pc.printf("[G]:Gravity vector[m/s*s],[T]:Chip temperature,Acc,Gyr[degC],[S]:Status,[M]:time[mS]\r\n"); t.start(); - - while(Capture == true) { - imu.get_Euler_Angles(&euler_angles); - pc.printf("X,%+6.1f,Y,%+6.1f,Z,%+6.1f,", - euler_angles.h, euler_angles.r, euler_angles.p); - imu.get_linear_accel(&linear_acc); - pc.printf("Acc:,X,%+6.1f,Y,%+6.1f,Z,%+6.1f,", - linear_acc.x, linear_acc.y, linear_acc.z); - - imu.get_gravity(&gravity); - pc.printf("Gravity,X,%+6.1f,Y,%+6.1f,Z,%+6.1f,", - gravity.x, gravity.y, gravity.z); + imu.write_reg0(0x3d, 0x07); // Default FUS - pc.printf("Time:,%d,\r\n",t.read_ms()); - }; - while(SaveFile == true) { - if (printed == false) { - pc.printf("Save File Location\r\n"); - //pc.printf("Enter Filename: \r\n"); - printed = true; - }; - FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing - fprintf(fp, "MBED SAVE FILESZZZ"); - fclose(fp); - pc.printf("File closed\r\n"); - }; - - + while (1) { + while (RAW == true) { + pc.printf("RAW,xLSB:,%d,xMSB:,%d,yLSB:%d,yMSB:,%d,zLSB:,%d,zMSB:,%d," + ,imu.read_reg0(0x08),imu.read_reg0(0x09) + ,imu.read_reg0(0x0A),imu.read_reg0(0x0B) + ,imu.read_reg0(0x0C),imu.read_reg0(0x0D)); + pc.printf("Time:,%d,/",t.read_ms()); + } + while (RAW == false) { + imu.get_linear_accel(&linear_acc); + pc.printf("FUS,x:,%+6.1f,y:,%+6.1f,z:,%+6.1f," + ,linear_acc.x ,linear_acc.y ,linear_acc.z + ,t.read_ms()); + pc.printf("Time:,%d,/",t.read_ms()); + } + } } - +// imu.get_Euler_Angles(&euler_angles); +// pc.printf("X,%+6.1f,Y,%+6.1f,Z,%+6.1f,", +// euler_angles.h, euler_angles.r, euler_angles.p); +// imu.get_linear_accel(&linear_acc); +// pc.printf("Acc:,X,%+6.1f,Y,%+6.1f,Z,%+6.1f,", +// linear_acc.x, linear_acc.y, linear_acc.z); +// +// imu.get_gravity(&gravity); +// pc.printf("Gravity,X,%+6.1f,Y,%+6.1f,Z,%+6.1f,", +// gravity.x, gravity.y, gravity.z); +// +// pc.printf("Time:,%d,\r\n",t.read_ms()); // imu.get_Euler_Angles(&euler_angles); // pc.printf("[E],Y,%+6.1f,R,%+6.1f,P,%+6.1f,",