This is the one where I went back and un-did the cube.cpp file
Dependencies: BNO055_fusion_tom FastPWM mbed
Fork of NucleoCube1 by
Diff: main.cpp
- Revision:
- 6:f2c930a90873
- Parent:
- 5:9247f07a954a
- Child:
- 7:1be7e6735fe2
--- a/main.cpp Sun Apr 09 00:47:55 2017 +0000 +++ b/main.cpp Sun Apr 09 16:28:10 2017 +0000 @@ -11,45 +11,71 @@ Ticker pwmint; DigitalOut myled(LED1); +InterruptIn button(USER_BUTTON); + PwmOut P1(PE_9); PwmOut P2(PE_11); PwmOut P3(PE_13); -void pwmupdate() { - myled = !myled; - } - -int main() -{ - //int i = 1; - pc.printf("Hello World !\n"); I2C i2c(PB_9, PB_8); // SDA, SCL BNO055 imu(i2c, PA_8); // Reset BNO055_ID_INF_TypeDef bno055_id_inf; BNO055_EULER_TypeDef euler_angles; + +int i = 180; +int isPressed; + +void pwmupdate() { + + myled = !myled; + + + P1 = (euler_angles.h/360.0); + P2 = (euler_angles.r/360.0); + P3 = (euler_angles.p/360.0); + + } + + void eventFunction() { + if(!isPressed) { + pwmint.attach(&pwmupdate, .005); + isPressed=1; + } else { + pwmint.detach(); + isPressed=0; + } +} + +int main() +{ pc.printf("Bosch Sensortec BNO055 test program on " __DATE__ "/" __TIME__ "\r\n"); if (imu.chip_ready() == 0){ pc.printf("Bosch BNO055 is NOT available!!\r\n"); } + imu.read_id_inf(&bno055_id_inf); + pc.printf("CHIP:0x%02x, ACC:0x%02x, MAG:0x%02x, GYR:0x%02x, , SW:0x%04x, , BL:0x%02x\r\n", bno055_id_inf.chip_id, bno055_id_inf.acc_id, bno055_id_inf.mag_id, bno055_id_inf.gyr_id, bno055_id_inf.sw_rev_id, bno055_id_inf.bootldr_rev_id); - pwmint.attach(&pwmupdate,.03); + + + isPressed=0; + + button.rise(&eventFunction); + + while(1) { -// acc.getAccAllAxis(data); -// pc.printf("Data %d %d %d \n",data[0], data[1], data[2]); - imu.get_Euler_Angles(&euler_angles); + + pc.printf("Heading:%+6.4f [deg], Roll:%+6.4f [deg], Pitch:%+6.4f [deg]\r\n", euler_angles.h, euler_angles.r, euler_angles.p); - wait(0.2); + imu.get_Euler_Angles(&euler_angles); + - - P1 = (euler_angles.h/360.0); - P2 = (euler_angles.r/360.0); - P3 = (euler_angles.p/360.0); + wait(0.2); } }