本帖最后由 peng1554 于 2018-11-19 18:42 编辑
有用户问战舰V3板子想利用片内FLASH显示汉字,所以基于战舰V3板子的TFTLCD液晶显示实验移植了这个程序,相比源程序,多了个TEXT文件夹,该文件夹下存放了与片内FLASH显示汉字相关函数的text.c和text.h
程序适合战舰V3&MINI,支持2.8寸、3.5寸、4.3寸和7寸V2MCU屏
利用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读取汉字点阵库并显示在液晶上
[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.c中程序如下
[mw_shl_code=c,true] int main(void)
{
delay_init(); //延时初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// 设置中断优先级分组2
LED_Init(); //初始化与LED连接的硬件接口
uart_init(115200);
LCD_Init();
POINT_COLOR=RED;
LCD_Show_Font(100,40,0);
LCD_Show_Font(100,80,1);
LCD_Show_Font(100,120,2);
LCD_ShowString(75,180,150,24,24,"ALIENTEK");
LCD_ShowString(75,210,150,24,24,"WarshipSTM32");
while(1)
{
delay_ms(500);
LED0=!LED0;
}
}[/mw_shl_code]
|