最后想用sprintf函数将GPS测得的数据显示出来,分别为经度纬度高度速度UTC时间,但是只显示最后一个时间了,如果将显示UTC时间注释掉,就只显示速度信息。。
新手小白求指教。
以下为代码:
void Gps_Msg_Show(void)
{
float tp;
POINT_COLOR=BLUE;
tp=gpsx.longitude;
sprintf((char *)dtbuf,"Longitude:%.5f %1c ",tp/=100000,gpsx.ewhemi); //得到经度字符串
LCD_ShowString(30,130,200,16,16,dtbuf);
tp=gpsx.latitude;
sprintf((char *)dtbuf,"Latitude:%.5f %1c ",tp/=100000,gpsx.nshemi); //得到纬度字符串
LCD_ShowString(30,150,200,16,16,dtbuf);
tp=gpsx.altitude;
sprintf((char *)dtbuf,"Altitude:%.1fm ",tp/=10); //得到高度字符串
LCD_ShowString(30,170,200,16,16,dtbuf);
tp=gpsx.speed;
sprintf((char *)dtbuf,"Speed:%.3fkm/h ",tp/=1000); //得到速度字符串
LCD_ShowString(30,190,200,16,16,dtbuf);
if(gpsx.fixmode<=3) //定位状态
{
sprintf((char *)dtbuf,"Fix Mode:%s",fixmode_tbl[gpsx.fixmode]);
LCD_ShowString(30,210,200,16,16,dtbuf);
}
sprintf((char *)dtbuf,"Valid satellite:%02d",gpsx.posslnum); //用于定位的卫星数
LCD_ShowString(30,230,200,16,16,dtbuf);
sprintf((char *)dtbuf,"Visible satellite:%02d",gpsx.svnum%100); //可见卫星数
LCD_ShowString(30,250,200,16,16,dtbuf);
sprintf((char *)dtbuf,"UTC Date:%04d/%02d/%02d ",gpsx.utc.year,gpsx.utc.month,gpsx.utc.date); //显示UTC日期
//printf("year2:%d\r\n",gpsx.utc.year);
LCD_ShowString(30,270,200,16,16,dtbuf);
sprintf((char *)dtbuf,"UTC Time:%02d:%02d:%02d ",gpsx.utc.hour,gpsx.utc.min,gpsx.utc.sec); //显示UTC时间
LCD_ShowString(30,290,200,16,16,dtbuf);
}
|