本帖最后由 peng1554 于 2018-11-19 21:45 编辑
http://www.openedv.com/forum.php?mod=viewthread&tid=283109&extra=论坛有客户问到这个,所以整合了下,在原有显示图片的基础上增加了从片内FLASH读取汉字点阵数据的功能
不过帖子链接中的程序没有标准库,本帖子用了标准库,基于该帖子下的程序移植而来
http://www.openedv.com/forum.php?mod=viewthread&tid=283220
利用PCtoLCD2002生成“开” “发” “板”三个点阵库并存放在片内FLASH,这三个汉字的点阵库数据存放在text.c中
[mw_shl_code=c,true]//24*24的OLED汉字点阵,包括三个汉字:开、发、板。这三个汉字的点阵库,是利用PCtoLCD2002生产的,
//软件设置的取模方式同OLED实验ASCII的取模方式一样,字体采用24*24大小,一个汉字点阵占用72字节。
const u8 LCD_HZK_TBL[3][72]=
{
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x08,0x08,0x02,0x08,0x08,0x04,0x08,0x08,0x08,0x08,0x08,0x10,0x08,0x08,0xE0,
0x0F,0xFF,0x80,0x08,0x08,0x00,0x08,0x08,0x00,0x08,0x08,0x00,0x08,0x08,0x00,0x08,0x08,0x00,0x08,0x08,0x00,0x0F,0xFF,0xFE,
0x0F,0xFF,0xFE,0x08,0x08,0x00,0x08,0x08,0x00,0x10,0x08,0x00,0x10,0x10,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"开",0*/
{0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x04,0x01,0x80,0x08,0x0F,0x00,0x10,0x1C,0x80,0x60,0x00,0x81,0xC2,0x00,0x87,0x02,
0x00,0xFC,0x02,0x1F,0xF0,0x04,0x3C,0x9C,0x08,0x20,0x92,0x08,0x00,0x91,0x90,0x00,0x90,0x70,0x00,0x90,0x60,0x20,0x91,0x90,
0x10,0x93,0x18,0x1C,0x9C,0x08,0x0C,0x98,0x0C,0x00,0x80,0x04,0x01,0x00,0x06,0x01,0x00,0x04,0x00,0x00,0x04,0x00,0x00,0x00},/*"发",1*/
{0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0x01,0x00,0x01,0x0E,0x00,0x01,0xF8,0x00,0x3F,0xFF,0xFE,0x21,0x20,0x00,0x01,0x10,0x02,
0x02,0x0C,0x0E,0x00,0x00,0x12,0x00,0x07,0xE4,0x0F,0xFE,0x04,0x08,0x40,0x08,0x08,0x78,0x10,0x08,0x47,0x30,0x08,0x41,0xE0,
0x10,0x41,0xE0,0x10,0x47,0x30,0x30,0x7C,0x18,0x30,0xE0,0x0C,0x10,0x00,0x0C,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00},/*"板",2*/
}; [/mw_shl_code]
整个程序最重要的是LCD_Show_Font()这个函数就是用来支持从片内FLASH读取汉字点阵库并显示在液晶上,在main.c中来调用该函数
[mw_shl_code=c,true]//在指定位置,显示一个24*24大小的汉字
//x,y :汉字的坐标
//index:汉字编号(在字库数组里面的编号)
void LCD_Show_Font(u16 x,u16 y,u8 index)
{
u8 temp,t,t1;
u16 y0=y;
u8 *dzk;
u8 csize=72; //一个24*24的汉字72字节
dzk=(u8*)LCD_HZK_TBL[index]; //得到汉字编号对应的点阵库
for(t=0;t<csize;t++)
{
temp=dzk[t]; //得到点阵数据
for(t1=0;t1<8;t1++) //按照从高位到低位的顺序画点
{
if(temp&0x80)LCD_Fast_DrawPoint(x,y,POINT_COLOR);
else LCD_Fast_DrawPoint(x,y,BACK_COLOR);
temp<<=1;
y++;
if((y-y0)==24) //对y坐标的处理,当y坐标距起始坐标差24个像素点,x坐标加1
{
y=y0;
x++;
break;
}
}
}
}[/mw_shl_code]
main函数如下
[mw_shl_code=c,true] int main(void)
{
u8 i=0;
POINT_COLOR=RED;
delay_init(); //延时初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// 设置中断优先级分组2
LED_Init(); //初始化与LED连接的硬件接口
uart_init(115200);
LCD_Init();
POINT_COLOR=RED;
LCD_Show_Font(50,10,0);
LCD_Show_Font(74,10,1);
LCD_Show_Font(98,10,2);
while(1)
{
if(i==0)
{
image_display(20,40,(u8*)gImage_image1);//在指定地址显示图片
}
i++;
if(i>10)i=0;
LED0=!LED0;
delay_ms(200);
}
}[/mw_shl_code]
|