[菜农助学交流] 板配4.3寸TFT彩屏显示汉字子程序

[复制链接]
 楼主| ichuangj 发表于 2011-5-30 11:19 | 显示全部楼层 |阅读模式
void LCD_ShowChn(uint8_t x,uint16_t y,uint8_t num)
{      
   #define MAX_CHAR_hPOSX 224
   #define MAX_CHAR_hPOSY 304
   
   uint16_t temp;
   uint8_t pos,t;
         
   if(x>MAX_CHAR_hPOSX||y>MAX_CHAR_hPOSY)
             return;

      
    LCD_WR_COM_DATA(0x0020,x);//设置X坐标位置
    LCD_WR_COM_DATA(0x0021,y);//设置Y坐标位置

          LCD_WR_COM_DATA(0x0050, x); // Horizontal GRAM Start Address
          LCD_WR_COM_DATA(0x0052, y); // Vertical GRAM Start Address  
          LCD_WR_COM_DATA(0x0051, x+15); // Horizontal GRAM End Address      
          LCD_WR_COM_DATA(0x0053, y+15); // Vertical GRAM end Address

    LCD_WR_COM(0x0022);                                //指向RAM寄存器,准备写数据到RAM
       
          for(pos=0;pos<16;pos++)
          {
              temp = (CodeChn[num][pos*2]<<8) + CodeChn[num][pos*2 +1];
                  if(temp/16<=9)
                  LCD_ShowChar(x+pos*24,y,temp/16+48);
                  else                  
                  LCD_ShowChar(x+pos*24,y,temp/16+55);
                  if(temp%16<=9)                  
                  LCD_ShowChar(x+pos*24+6,y,temp%16+48);
                  else
                  LCD_ShowChar(x+pos*24+6,y,temp%16+55);
                  temp = CodeChn[pos*2+1+32*num];
                  if(temp/16<=9)
                  LCD_ShowChar(x+pos*24+12,y,temp/16+48);
                  else
                  LCD_ShowChar(x+pos*24+12,y,temp/16+55);
                  if(temp%16<=9)                  
                  LCD_ShowChar(x+pos*24+18,y,temp%16+48);
                  else
                  LCD_ShowChar(x+pos*24+18,y,temp%16+55);*/
             for(t=0;t<16;t++)
             {                 
                        if(temp&0x8000)
                         LCD_WR_DATA(POINT_COLOR);
                else
                         LCD_WR_DATA(0xffff);//白色   
                temp<<=1;
             }
          }
          
    LCD_WR_COM_DATA(0x0050, 0x0000); // Horizontal GRAM Start Address
    LCD_WR_COM_DATA(0x0051, 0x00EF); // Horizontal GRAM End Address
    LCD_WR_COM_DATA(0x0052, 0x0000); // Vertical GRAM Start Address
    LCD_WR_COM_DATA(0x0053, 0x013F); // Vertical GRAM end Address

}
 楼主| ichuangj 发表于 2011-5-30 11:20 | 显示全部楼层
//16x16汉字库
const uint8_t CodeChn[][32] =
{ /* 横向取模、字节不倒序 */
/*--  文字:  闯  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x10,0x00,0x09,0xFC,0x08,0x04,0x20,0x04,0x27,0xC4,0x24,0x44,0x24,0x44,0x27,0xF4,
0x20,0x14,0x2F,0xD4,0x20,0x14,0x20,0x54,0x20,0x24,0x20,0x04,0x20,0x14,0x20,0x08,
};
 楼主| ichuangj 发表于 2011-5-30 11:20 | 显示全部楼层
可直接使用 :D
hotpower 发表于 2011-5-30 11:35 | 显示全部楼层
搞个裸照看看。
 楼主| ichuangj 发表于 2011-6-1 08:56 | 显示全部楼层
上了裸照,大叔可给条裤子?:lol
==我借到相机就拍了发上来
aihe 发表于 2011-6-4 07:40 | 显示全部楼层
4.3",这么大液晶啊
linbei1988 发表于 2011-6-23 14:59 | 显示全部楼层
;P裸照呢
 楼主| ichuangj 发表于 2011-9-29 10:30 | 显示全部楼层
void LCD_ShowChn(uint8_t x,uint16_t y,uint8_t num)
{      
   #define MAX_CHAR_hPOSX 224
   #define MAX_CHAR_hPOSY 304
   
   uint16_t temp;
   uint8_t pos,t;
         
   if(x>MAX_CHAR_hPOSX||y>MAX_CHAR_hPOSY)
             return;

      
    LCD_WR_COM_DATA(0x0020,x);//设置X坐标位置
    LCD_WR_COM_DATA(0x0021,y);//设置Y坐标位置

          LCD_WR_COM_DATA(0x0050, x); // Horizontal GRAM Start Address
          LCD_WR_COM_DATA(0x0052, y); // Vertical GRAM Start Address  
          LCD_WR_COM_DATA(0x0051, x+15); // Horizontal GRAM End Address      
          LCD_WR_COM_DATA(0x0053, y+15); // Vertical GRAM end Address

    LCD_WR_COM(0x0022);                                //指向RAM寄存器,准备写数据到RAM
        
          for(pos=0;pos<16;pos++)
          {
              temp = (CodeChn[num][pos*2]<<8) + CodeChn[num][pos*2 +1];
               for(t=0;t<16;t++)
             {                 
                        if(temp&0x8000)
                         LCD_WR_DATA(POINT_COLOR);
                else
                         LCD_WR_DATA(0xffff);//白色   
                temp<<=1;
             }
          }
         
    LCD_WR_COM_DATA(0x0050, 0x0000); // Horizontal GRAM Start Address
    LCD_WR_COM_DATA(0x0051, 0x00EF); // Horizontal GRAM End Address
    LCD_WR_COM_DATA(0x0052, 0x0000); // Vertical GRAM Start Address
    LCD_WR_COM_DATA(0x0053, 0x013F); // Vertical GRAM end Address

}
 楼主| ichuangj 发表于 2011-9-29 10:31 | 显示全部楼层
[quote][/quote]:
 楼主| ichuangj 发表于 2011-9-29 10:35 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
 楼主| ichuangj 发表于 2011-9-29 10:35 | 显示全部楼层
这是彩屏上显示照片、字母、数字,汉字的图片
Swallow_0322 发表于 2011-9-29 11:13 | 显示全部楼层
图片文件挺大,但是清晰度有点差,O(∩_∩)O~ 还是顶一个!

选择添加附件-->>然后插入到文档中...

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
tao560532 发表于 2011-9-29 12:17 | 显示全部楼层
 楼主| ichuangj 发表于 2011-9-29 16:59 | 显示全部楼层
呵呵 用手机拍的 :)
nixianmin 发表于 2011-9-29 18:52 | 显示全部楼层
什么时候可以写个在SD卡里放个汉字的库,通过SPI读SD卡内容
可以直接用LCD_Whanzi(x,y,"中国")调用函数并在彩屏上显示汉字
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

124

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部

0

主题

124

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部