这是我的一个课程设计,题目其实不难,从串口接受数据然后再LCD上显示出来,要有游动效果
主函数:
- C/C++ code
int main(void){ // 初始化I/O uint16 chr,str[100],color; uint8 fs,i = 0; int coor; rGPHCON = (rGPHCON & (~(0x03<<20))) | (0x01<<20); // rGPHCON[21:20] = 01b,设置GPH10为GPIO输出模式 UART_Select(0); // 选择UART0 UART_Init(); // 初始化UART0 RTC_Init(0); // 初始化RTC GUI_Initialize();//初始化LCD RunBeep(); UART_SendStr("请选择滚动方式,0为横向滚动,1为纵向滚动\n"); chr = UART_GetKey(); if(chr == 0) { fs = 1; coor = WIDTH; } else { fs = 0; coor = HIGN; }//格式控制,fs为0时横向滚动,fs为1时纵向滚动 UART_SendStr("请选择文字颜色: \n0 黑色\n1 深蓝色\n2 深绿色\n3 深青色\n4 深红色:\n5 紫色\n6 橄榄绿\n7 灰白色\n8 深灰色\n9 蓝色\n10 绿色\n11 青色\n12 红色\n13 品红\n14 黄色\n15 白色"); chr = UART_GetKey(); color = COLORS_TAB[chr];//选择颜色 while(str[i-1] != 0x0D) { str[i] = UART_GetKey(); //获得串口数据 i++; } str[i] = ' '; str[i++] = '2'; str[i++] = '0'; str[i++] = g_year/10; str[i++] = g_year%10; str[i++] = '-'; str[i++] = g_month/10; str[i++] = g_month%10; str[i++] = '-'; str[i++] = g_day/10; str[i++] = g_day%10; str[i++] = ' '; str[i++] = g_hour/10; str[i++] = g_hour%10; str[i++] = ':'; str[i++] = g_min/10; str[i++] = g_min%10; str[i++] = ':'; str[i++] = g_sec/10; str[i++] = g_sec%10; str[i] = '\0';//加入rtc while(1) { ShowChar(str,fs,coor,color);//显示串口获得的数据,这里有问题!,可以正常执行但是就是显示不出东西 TFT_FillSCR(GUI_CCOLOR);//清屏 coor-=GUNDONG; if(coor == -(16 * i) && fs == 0) coor = WIDTH; if(coor == -(16 * i) && fs == 1) coor = HIGN;//滚动结束,重新开始 DelayNS(10); } return(0);}
ShowChar函数
- C/C++ code
void ShowChar(uint16 *p,uint8 fs,uint16 i,uint8 color){ if(fs == 0) { Lcd_DspAscII8x16(i,0,color,p); } else { Lcd_DspAscII8x16(0,i,color,p); }}
lcd_DspAscII8X16函数
- C/C++ code
void Lcd_DspAscII8x16(uint16 x0, uint16 y0, uint8 ForeColor, uint8 * s){ int16 i,j,k,x,y,xx; uint8 qm; uint32 ulOffset; int8 ywbuf[16],temp[2]; for( i = 0; i < strlen((const char*)s); i++ ) { if( (uint8)*(s+i) >= 161 ) { temp[0] = *(s + i); temp[1] = '\0'; return; } else { qm = *(s+i); ulOffset = (uint32)(qm) * 16; //Here to be changed tomorrow for( j = 0; j < 16; j ++ ) { ywbuf[j] = g_auc_Ascii8x16[ulOffset + j]; } for( y = 0; y < 16; y++ ) { for( x = 0; x < 8; x++ ) { k = x % 8; if( ywbuf[y] & (0x80 >> k) ) { xx = x0 + x + i*8; GUI_Point(xx, y + y0, (uint8)ForeColor); } } } } }}
经过调试,可以显示图片,但是就是显示不了文字,怎么回事?
------解决方案--------------------------------------------------------
看不懂,帮顶一下是可以的.
------解决方案--------------------------------------------------------
ShowChar(str,fs,coor,color);//显示串口获得的数据,这里有问题!,可以正常执行但是就是显示不出东西
TFT_FillSCR(GUI_CCOLOR);//清屏
清屏?什么意思,屏幕清掉了还能显示什么?