gyro
Dependencies: BSP_DISCO_F429ZI GYRO_DISCO_F429ZI LCD_DISCO_F429ZI mbed
Fork of DISCO-F429ZI_Gyro_demo by
Revision 3:68f55e42c85f, committed 2017-11-15
- Comitter:
- codebreaker7
- Date:
- Wed Nov 15 10:51:01 2017 +0000
- Parent:
- 2:b878d61bf57b
- Commit message:
- Cleaned up some code
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r b878d61bf57b -r 68f55e42c85f main.cpp --- a/main.cpp Thu Feb 16 11:43:51 2017 +0000 +++ b/main.cpp Wed Nov 15 10:51:01 2017 +0000 @@ -46,18 +46,13 @@ lcd.DisplayStringAt(20, 40, (uint8_t*)"760", CENTER_MODE); break; } - //BSP_LCD_Init(); - //BSP_LCD_De - //BSP_LCD_DisplayStringAt(10,10, (uint8_t*)"Gyroscope_started", CENTER_MODE); - + for (int i = 0; i < 50; i++) { gyro.GetXYZ(GyroBuffer); zero_level[0] += GyroBuffer[0] / 17.5f; zero_level[1] += GyroBuffer[1] / 17.5f; zero_level[2] += GyroBuffer[2] / 17.5f; - //zero_level[0] += GyroBuffer[0]; - //zero_level[1] += GyroBuffer[1]; - //zero_level[2] += GyroBuffer[2]; + wait_ms(10); } for (int i = 0; i < 3; i++) @@ -80,8 +75,7 @@ while(1) { // Read Gyroscope values wait(0.02); - //GYRO_IO_Read(&tmpreg, L3GD20_STATUS_REG_ADDR, 1); - //while((tmpreg >> 3) & 0x01 != 1) GYRO_IO_Read(&tmpreg, L3GD20_STATUS_REG_ADDR, 1); + gyro.GetXYZ(GyroBuffer); float value = GyroBuffer[0] / 17.5f - zero_level[0]; if (value >= noise_level || value <= -noise_level) { @@ -90,18 +84,6 @@ prev_value = value; sprintf((char*)buffer, "Angle = %.3f\n", angle); lcd.DisplayStringAt(20, 100, buffer, CENTER_MODE); - // Display values - //sprintf((char*)buffer, "X = %.2f\n", (GyroBuffer[0] - zero_level[0]) / 1000); - //sprintf((char*)buffer, "X = %.2f\n", GyroBuffer[0] / 17.5f - zero_level[0]); - //lcd.DisplayStringAt(20, 10, buffer, CENTER_MODE); - //sprintf((char*)buffer, "Y = %.2f\n", (GyroBuffer[1] - zero_level[1]) / 1000); - //sprintf((char*)buffer, "Y = %.2f\n", GyroBuffer[1] / 17.5f - zero_level[1]); - //lcd.DisplayStringAt(20, 40, buffer, CENTER_MODE); - //sprintf((char*)buffer, "Z = %.2f\n", (GyroBuffer[2] - zero_level[2]) / 1000); - //sprintf((char*)buffer, "Z = %.2f\n", GyroBuffer[2] / 17.5f - zero_level[2]); - //lcd.DisplayStringAt(20, 70, buffer, CENTER_MODE); - //led1 = !led1; - //wait(1); - //lcd.Clear(0xffffffff); + } }