用OLED显示MPU6050的数据
时间:10-02
整理:3721RD
点击:
我根据正点原子的改了下程序但不行,如果用OLED显示请问这部分程序该怎么改:
while(1)
{
key=KEY_Scan(0);
if(key==KEY0_PRES)
{
report=!report;
if(report)LCD_ShowString(30,170,200,16,16,"UPLOAD ON ");
else LCD_ShowString(30,170,200,16,16,"UPLOAD OFF");
}
if(mpu_dmp_get_data(&pitch,&roll,&yaw)==0)
{
temp=MPU_Get_Temperature(); //μ?μ????è?μ
MPU_Get_Accelerometer(&aacx,&aacy,&aacz); //μ?μ??ó?ù?è′??D?÷êy?Y
MPU_Get_Gyroscope(&gyrox,&gyroy,&gyroz); //μ?μ?íó?Yò?êy?Y
if(report)mpu6050_send_data(aacx,aacy,aacz,gyrox,gyroy,gyroz);//ó?×??¨ò???·¢?í?ó?ù?èoííó?Yò??-ê?êy?Y
if(report)usart1_report_imu(aacx,aacy,aacz,gyrox,gyroy,gyroz,(int)(roll*100),(int)(pitch*100),(int)(yaw*10));
if((t%10)==0)
{
if(temp<0)
{
LCD_ShowChar(30+48,200,'-',16,0); //??ê??oo?
temp=-temp; //×a?a?yêy
}else LCD_ShowChar(30+48,200,' ',16,0); //è¥μ??oo?
LCD_ShowNum(30+48+8,200,temp/100,3,16); //??ê???êy2?·?
LCD_ShowNum(30+48+40,200,temp%10,1,16); //??ê?D?êy2?·?
OLED_ShowNum(0,0,temp/100,5,16);
OLED_ShowNum(0,0,temp%100,6,16);
temp=pitch*10;
if(temp<0)
{
LCD_ShowChar(30+48,220,'-',16,0); //??ê??oo?
temp=-temp; //×a?a?yêy
}else LCD_ShowChar(30+48,220,' ',16,0); //è¥μ??oo?
LCD_ShowNum(30+48+8,220,temp/10,3,16); //??ê???êy2?·?
LCD_ShowNum(30+48+40,220,temp%10,1,16); //??ê?D?êy2?·?
temp=roll*10;
if(temp<0)
{
LCD_ShowChar(30+48,240,'-',16,0); //??ê??oo?
temp=-temp; //×a?a?yêy
}else LCD_ShowChar(30+48,240,' ',16,0); //è¥μ??oo?
LCD_ShowNum(30+48+8,240,temp/10,3,16); //??ê???êy2?·?
LCD_ShowNum(30+48+40,240,temp%10,1,16); //??ê?D?êy2?·?
temp=yaw*10;
if(temp<0)
{
LCD_ShowChar(30+48,260,'-',16,0); //??ê??oo?
temp=-temp; //×a?a?yêy
}else LCD_ShowChar(30+48,260,' ',16,0); //è¥μ??oo?
LCD_ShowNum(30+48+8,260,temp/10,3,16); //??ê???êy2?·?
LCD_ShowNum(30+48+40,260,temp%10,1,16); //??ê?D?êy2?·?
t=0;
LED0=!LED0;//LEDéá??
}
}
t++;
while(1)
{
key=KEY_Scan(0);
if(key==KEY0_PRES)
{
report=!report;
if(report)LCD_ShowString(30,170,200,16,16,"UPLOAD ON ");
else LCD_ShowString(30,170,200,16,16,"UPLOAD OFF");
}
if(mpu_dmp_get_data(&pitch,&roll,&yaw)==0)
{
temp=MPU_Get_Temperature(); //μ?μ????è?μ
MPU_Get_Accelerometer(&aacx,&aacy,&aacz); //μ?μ??ó?ù?è′??D?÷êy?Y
MPU_Get_Gyroscope(&gyrox,&gyroy,&gyroz); //μ?μ?íó?Yò?êy?Y
if(report)mpu6050_send_data(aacx,aacy,aacz,gyrox,gyroy,gyroz);//ó?×??¨ò???·¢?í?ó?ù?èoííó?Yò??-ê?êy?Y
if(report)usart1_report_imu(aacx,aacy,aacz,gyrox,gyroy,gyroz,(int)(roll*100),(int)(pitch*100),(int)(yaw*10));
if((t%10)==0)
{
if(temp<0)
{
LCD_ShowChar(30+48,200,'-',16,0); //??ê??oo?
temp=-temp; //×a?a?yêy
}else LCD_ShowChar(30+48,200,' ',16,0); //è¥μ??oo?
LCD_ShowNum(30+48+8,200,temp/100,3,16); //??ê???êy2?·?
LCD_ShowNum(30+48+40,200,temp%10,1,16); //??ê?D?êy2?·?
OLED_ShowNum(0,0,temp/100,5,16);
OLED_ShowNum(0,0,temp%100,6,16);
temp=pitch*10;
if(temp<0)
{
LCD_ShowChar(30+48,220,'-',16,0); //??ê??oo?
temp=-temp; //×a?a?yêy
}else LCD_ShowChar(30+48,220,' ',16,0); //è¥μ??oo?
LCD_ShowNum(30+48+8,220,temp/10,3,16); //??ê???êy2?·?
LCD_ShowNum(30+48+40,220,temp%10,1,16); //??ê?D?êy2?·?
temp=roll*10;
if(temp<0)
{
LCD_ShowChar(30+48,240,'-',16,0); //??ê??oo?
temp=-temp; //×a?a?yêy
}else LCD_ShowChar(30+48,240,' ',16,0); //è¥μ??oo?
LCD_ShowNum(30+48+8,240,temp/10,3,16); //??ê???êy2?·?
LCD_ShowNum(30+48+40,240,temp%10,1,16); //??ê?D?êy2?·?
temp=yaw*10;
if(temp<0)
{
LCD_ShowChar(30+48,260,'-',16,0); //??ê??oo?
temp=-temp; //×a?a?yêy
}else LCD_ShowChar(30+48,260,' ',16,0); //è¥μ??oo?
LCD_ShowNum(30+48+8,260,temp/10,3,16); //??ê???êy2?·?
LCD_ShowNum(30+48+40,260,temp%10,1,16); //??ê?D?êy2?·?
t=0;
LED0=!LED0;//LEDéá??
}
}
t++;