現象,在TFT屏顯示結果是亂碼。各位大俠是哪里的問題
MAIN.C
#include "delay.h"
#include "sys.h"
#include "lcd.h"
#include "touch.h"
#include "gui.h"
#include "test.h"
#include "DS1302.h"
#include "usart.h"
int main(void)
{
char buf[] = {"Usart_SendData function!"};
uart_init(9600);
SystemInit();
delay_init(72);
LCD_Init();
DS1302_Init();
//Ñ-»·2aêÔ
while(1)
{
DS1302_GetTime();
printf("%d\r\n",TimeData .day );
Show_Str(20,30,BLUE,YELLOW,(u8 *)&TimeData .day ,16,1);
delay_ms(800);
}
}
GUI.C中的show_str函數
void Show_Str(u16 x, u16 y, u16 fc, u16 bc, u8 *str,u8 size,u8 mode)
{
u16 x0=x;
u8 bHz=0; //×Ö·û»òÕßÖDÎÄ
while(*str!=0)//êy¾YÎ′½áêø
{
if(!bHz)
{
if(x>(lcddev.width-size/2)||y>(lcddev.height-size))
return;
if(*str>0x80)bHz=1;
else
{
if(*str==0x0D)
{
y+=size;
x=x0;
str++;
}
else
{
if(size>16)
{
LCD_ShowChar(x,y,fc,bc,*str,16,mode);
x+=8;
}
else
{
LCD_ShowChar(x,y,fc,bc,*str,size,mode);
x+=size/2;
}
}
str++;
}
}else//ÖDÎÄ
{
if(x>(lcddev.width-size)||y>(lcddev.height-size))
return;
bHz=0;
if(size==32)
GUI_DrawFont32(x,y,fc,bc,str,mode);
else if(size==24)
GUI_DrawFont24(x,y,fc,bc,str,mode);
else
GUI_DrawFont16(x,y,fc,bc,str,mode);
str+=2;
x+=size;
}
}
}
DS1302.C中的DS1302_GETTIME函數
void DS1302_GetTime()
{
DS1302_ReadTime();
TimeData.year=(time_buf[0]>>4)*1000+(time_buf[0]&0x0F)*100+(time_buf[1]>>4)*10+(time_buf[1]&0x0F); //¼ÆËãÄê·Y
TimeData.month=(time_buf[2]>>4)*10+(time_buf[2]&0x0F); //¼ÆËãÔ·Y
TimeData.day=(time_buf[3]>>4)*10+(time_buf[3]&0x0F); //¼ÆËãèÕÆú
TimeData.hour=(time_buf[4]>>4)*10+(time_buf[4]&0x0F); //¼ÆËãD¡ê±
TimeData.minute=(time_buf[5]>>4)*10+(time_buf[5]&0x0F); //¼ÆËã·ÖÖó
TimeData.second=(time_buf[6]>>4)*10+(time_buf[6]&0x0F); //¼ÆËãÃëÖó
TimeData.week=(time_buf[7]&0x0F); //¼ÆËãDÇÆú
//printf("ê±¼ä:%d-%d-%d %d:%d:%d %d \n",TimeData.year,TimeData.month,TimeData.day,TimeData.hour,TimeData.minute,TimeData.second,TimeData.week);
}
DS1302.H中的TIMEDATA結構體
struct TIMEData
{
u16 year;
u8 month;
u8 day;
u8 hour;
u8 minute;
u8 second;
u8 week;
};
extern struct TIMEData TimeData;
|