区分显示LCD汉字字模库中的中文与英文

来源:互联网 发布:程序员要求 编辑:程序博客网 时间:2024/05/22 12:04
 #ifndef GUI_H #define GUI_H void LCD_Bytes(unsigned char* chs,int x_LCD,int y_LCD,int color){int i,j,x=x_LCD,y=y_LCD;int k=0;pCH pBytes = &CharLib[0];for(k=0; k<sizeof(CharLib)/sizeof(CharLib[0]); k++){if((chs[0] == pBytes->index[0]) && (chs[1] == pBytes->index[1])){break;}else{pBytes++;}}for (i=0;i<32;i++)//画列     {        if (i%2==0) {x=x_LCD;y++;}   //每行两字节,16X16点阵        for (j=7;j>=0;j--)//画行        {            if ((pBytes->data[i])&(1<<j))            {                draw_point(x,y,color);            }//由高到低,为1则输出'O',反之输出'-';            else                {;}            x++;        }    }}void LCD_Chars( char ASCII, int Xpos, int Ypos, int charColor){int i, j;    unsigned char* buffer, tmp_char;    GetASCIICode(&buffer,ASCII);  /* 取字模数据 */    for( i=15; i>=0; i--)    {        tmp_char = buffer[i];        for( j=7; j>=0; j-- )        {            if (buffer[i]&(1<<j))            {                draw_point((Xpos + 7 - j), (Ypos + i), charColor);            }            else            {                ;            }        }    }}void LCD_String(char* str,int x,int y){    int i = 0;    unsigned char* s= (unsigned char*)str;        for(i=0; s[i] != '\0';)    {    if(s[i] > 128)//是汉字     {    LCD_Bytes(&s[i],x,y,Red);//在屏幕上显示这个汉字    x=x+16;    i=i+2;    }    else{LCD_Chars(s[i],x,y,Red);x=x+8;i++;}            }}void Draw_line(int x1,int y1,int x2,int y2, int color){int i=0;int start=0, end=0;float k=0;if(x1 == x2){start = (y1<y2)?y1:y2;end   = (y1>y2)?y1:y2;for(i=start; i<=end; i++){draw_point(x1,i,color);}}else if(y1 == y2){start = (x1<x2)?x1:x2;end   = (x1>x2)?x1:x2;for(i=start; i<=end; i++){draw_point(i,y1,color);}}else{if(x1>x2){start = x2;x2 = x1; x1 = start;start = y2; y2 = y1; y1 = start;}k = ((float)y2-y1)/(x2-x1);//+-for(i=x1;i<=x2;i++){draw_point(i,y1+(int)(k*(i-x1)),color);}}}#endif