首页 > 技术支持 > 应用与案例 > 正文
自建字库调用方法及范例(RA8876,RA8877) 作者:   发表日期:2020-09-21   来源:   浏览:
RA8876和RA8877芯片自建字库的调用方法如下:

首先需要使用提取字模软件生成所需文字字库的头文件并将其添加到工程,
包含头文件

#include
#include "stm32f10x.h"
#include "stdlib.h"
#include
#include "delay.h"
#include "UserDef.h"
 
#include "RA8876.h"
#include "RA8876_MCU_IF.h"
#include "RA8876_API.h"
#include "UserFontROM.h"

添加调用下列函数 
此函数列举了8x16,16x16,16x24,24x24,16x32,32x32字体尺寸的调用
在下面的应用例程中也都一 一展示了显示效果
void RA8876_Create_UserDefineFont(unsigned long UDF_Address,const unsigned char UserDefineData[],unsigned short num)

     /*

UDF_Address: User define font Address. 
UserDefineData[] / num: the data for user to create the fonts.
*/
unsigned short temp1,temp2,temp3;
unsigned short i;
 
/******************************/
//(0) Backup memory type //撷取执行前的状态
temp1 = LCD_RegisterRead(0x02);
temp2 = LCD_RegisterRead(0x03);
temp3 = LCD_RegisterRead(0x5E);
/******************************/
 
//(1) Set the setting for Create User Define Font 
Memory_Select_SDRAM();
Memory_Linear_Mode();
Graphic_Mode();
 
//(1.1) Data format have to set to 8bpp. 
#if defined (MCU_8bit_ColorDepth_8bpp) || defined (MCU_8bit_ColorDepth_16bpp) || defined (MCU_8bit_ColorDepth_24bpp)
Data_Format_8b_8bpp();
#endif
 
#if defined (MCU_16bit_ColorDepth_16bpp) || defined (MCU_16bit_ColorDepth_24bpp_Mode_1) || defined (MCU_16bit_ColorDepth_24bpp_Mode_2)
Data_Format_16b_8bpp();
#endif
 
//(1.2) Data format have to set to 8bpp. 
Memory_8bpp_Mode();
 
 
//(2) Set the start address for Create_UserDefine_Font, and write data.
Goto_Linear_Addr(UDF_Address);
//
LCD_CmdWrite(0x04);
for(i=0;i
{
Check_Mem_WR_FIFO_not_Full();
LCD_DataWrite(UserDefineData[i]);
}
Check_2D_Busy();
 
/******************************/
//(End) Restore the previous state //复原进子程序之前的状态
LCD_RegisterWrite(0x02,temp1);
LCD_RegisterWrite(0x03,temp2);
LCD_RegisterWrite(0x5E,temp3);    
/******************************/
 

}


 

void RA8876_Call_UserDefineFont(unsigned short UDF_case,unsigned long UDF_Address,unsigned short UDF_X,unsigned short UDF_Y,unsigned short char_code)
{
/*
UDF_case: please key 8*16, 16*16, 12*24, 24*24, 16*32 or 32*32.
UDF_Address: User define font Address. 
UDF_X / UDF_Y: X and Y coordinates 0n the memory area.
char_code: Character codes of user define fonts. 
*/
 
//(1) set Font Function // 设定文本属性
 
//(*)
Text_Mode();
 
//(*)
Font_Select_UserDefine_Mode();
 
//(*)
if( UDF_case == 128 ) //8x16
{
Font_Select_8x16_16x16();
CGRAM_Start_address(UDF_Address);
}
if( UDF_case == 256 ) //16x16
{
Font_Select_8x16_16x16();
CGRAM_Start_address(UDF_Address);
}
if( UDF_case == 288 ) //12x24
{
Font_Select_12x24_24x24();
CGRAM_Start_address(UDF_Address);
}
if( UDF_case == 576 ) //24x24
{
Font_Select_12x24_24x24();
CGRAM_Start_address(UDF_Address);
}
if( UDF_case == 512 ) //16x32
{
Font_Select_16x32_32x32();
CGRAM_Start_address(UDF_Address);
}
if( UDF_case == 1024 ) //32x32
{
Font_Select_16x32_32x32();
CGRAM_Start_address(UDF_Address);
}
 
//(*)
Goto_Text_XY(UDF_X,UDF_Y);
 
//(*) 
//Half width character code is 0000h~7FFFh,
if(UDF_case==128 || UDF_case==288 || UDF_case==512)
{
LCD_CmdWrite(0x04);
// character 0x0000
Check_Mem_WR_FIFO_not_Full();
LCD_DataWrite(char_code>>8);
Check_Mem_WR_FIFO_not_Full();
LCD_DataWrite(char_code);
 
Check_2D_Busy();
}  
 
//Full width character code is 8000h~FFFFh.
if(UDF_case==256 || UDF_case==576 || UDF_case==1024)
{
LCD_CmdWrite(0x04);
// character 0x8000
Check_Mem_WR_FIFO_not_Full();
LCD_DataWrite(char_code>>8);
Check_Mem_WR_FIFO_not_Full();
LCD_DataWrite(char_code);
 
Check_2D_Busy();
}
 
Graphic_Mode();
 

}


 
实例DEMO调用6个字模数组,并将其按4种比例大小显示,

void RA8876_Demo_UserDefine_Font(void)
{
/*
Half width character code is 0000h~7FFFh,
Full width character code is 8000h~FFFFh.
*/
unsigned long UDF_8x16_Address,UDF_16x16_Address;
unsigned long UDF_12x24_Address,UDF_24x24_Address;
unsigned long UDF_16x32_Address,UDF_32x32_Address;
 
unsigned short x,y;
unsigned char i,j,BGC;
 
 
//(1) Create User Define Font. // 建立自建字型
//(1.a)    
/* (1) SDRAM=256Mb, address=0x01FF FFFF (byte).
(2) Assume that plan 1MB SDRAM memory for storing  8x16 or 16x16 Font data.
(3) Assume that plan 1MB SDRAM memory for storing 12x24 or 24x24 Font data.
(4) Assume that plan 1MB SDRAM memory for storing 16x32 or 32x32 Font data. 
*/
UDF_8x16_Address  = 0x02000000-1024*6; //(byte)
UDF_16x16_Address = 0x02000000-1024*5; //(byte)
UDF_12x24_Address = 0x02000000-1024*4; //(byte)
UDF_24x24_Address = 0x02000000-1024*3; //(byte)
UDF_16x32_Address = 0x02000000-1024*2; //(byte)
UDF_32x32_Address = 0x02000000-1024*1; //(byte)
 
//(1.b)
RA8876_Create_UserDefineFont( UDF_8x16_Address  , Demo_UDF_8x16  ,16);
RA8876_Create_UserDefineFont( UDF_16x16_Address , Demo_UDF_16x16 ,32);
RA8876_Create_UserDefineFont( UDF_12x24_Address , Demo_UDF_12x24 ,48);
RA8876_Create_UserDefineFont( UDF_24x24_Address , Demo_UDF_24x24 ,72);
RA8876_Create_UserDefineFont( UDF_16x32_Address , Demo_UDF_16x32 ,64);
RA8876_Create_UserDefineFont( UDF_32x32_Address , Demo_UDF_32x32 ,128);
 
//(2) 
Memory_Select_SDRAM();
Memory_XY_Mode();
Graphic_Mode();
 
Main_Window_Start_XY(0,0);
 
Active_Window_XY(0,0);
 
Active_Window_WH(800,480);
 
//(3) set Font Function // 设定文本属性
//(*)
Font_Select_UserDefine_Mode();
//(*)
Text_Mode();
 
//(*) font color
Foreground_RGB(0xFF,0x00,0x00);  //设定文字颜色
Background_RGB(0x00,0x00,0xFF);  //当显示底色是设定底色
 
//(*)
Set_Font_to_Font_Width(0);
Font_Line_Distance(0);
 
//(*)
for(BGC=0;BGC<2;BGC++)//
{
if(BGC==0)Font_Background_select_Original_Canvas();   //透明色显示,及没有底色
if(BGC==1)Font_Background_select_Color();             //有底色显示
//
for(i=1;i<=6;i++)//
{
for(j=1;j<=4;j++)//变更字型倍数 
{
switch(j)
{
case 1 : Font_Width_X1(); Font_Height_X1(); break;
case 2 : Font_Width_X2(); Font_Height_X2(); break;
case 3 : Font_Width_X3(); Font_Height_X3(); break;
case 4 : Font_Width_X4(); Font_Height_X4(); break;
}
 
//Text Write position
if(i==1 || i==2)
{
if(i==1) x = 0;
if(i==2) x = 8*4;
 
if(j==1) y= 0;
if(j==2) y= 0 + 16*1;
if(j==3) y= 0 + 16*1 + 16*2;
if(j==4) y= 0 + 16*1 + 16*2 + 16*3;
}
if(i==3 || i==4)
{
if(i==3) x = 8*4+16*4;
if(i==4) x = 8*4+16*4+12*4;
 
if(j==1) y= 0;
if(j==2) y= 0 + 24*1;
if(j==3) y= 0 + 24*1 + 24*2;
if(j==4) y= 0 + 24*1 + 24*2 + 24*3;
}
if(i==5 || i==6)
{
if(i==5) x = 8*4+16*4+12*4+24*4;
if(i==6) x = 8*4+16*4+12*4+24*4+16*4;
 
if(j==1) y= 0;
if(j==2) y= 0 + 32*1;
if(j==3) y= 0 + 32*1 + 32*2;
if(j==4) y= 0 + 32*1 + 32*2 + 32*3;
}
 
switch(i)
{
case 1 :/*UDF_8x16*/
RA8876_Call_UserDefineFont( 8*16 ,UDF_8x16_Address ,x+10*i ,y+10*j ,0x0000 );// 10*i or 10*j : shift 10 pixel 
break;
case 2 :/*UDF_16x16*/
RA8876_Call_UserDefineFont( 16*16 ,UDF_16x16_Address ,x+10*i ,y+10*j ,0x8000 );// 10*i or 10*j : shift 10 pixel 
break;
case 3 :/*UDF_12x24*/
RA8876_Call_UserDefineFont( 12*24 ,UDF_12x24_Address ,x+10*i ,y+10*j ,0x0000 );// 10*i or 10*j : shift 10 pixel 
break;
case 4 :/*UDF_24x24*/
RA8876_Call_UserDefineFont( 24*24 ,UDF_24x24_Address ,x+10*i ,y+10*j ,0x8000 );// 10*i or 10*j : shift 10 pixel
break;
case 5 :/*UDF_16x32*/
RA8876_Call_UserDefineFont( 16*32 ,UDF_16x32_Address ,x+10*i ,y+10*j ,0x0000 );// 10*i or 10*j : shift 10 pixel 
break;
case 6 :/*UDF_32x32*/
RA8876_Call_UserDefineFont( 32*32 ,UDF_32x32_Address ,x+10*i ,y+10*j ,0x8000 );// 10*i or 10*j : shift 10 pixel 
break;
}
delay_ms(500);
}
delay_ms(1000);
}
}
}


实例效果









 





分享到:

相关热词搜索:

上一篇:瑞佑RAIO图形控制芯片简介(选型参考)
下一篇:将字库烧写到flash中并调用