首页 > 技术支持 > 应用与案例 > 正文
将字库烧写到flash中并调用 作者:david   发表日期:2020-09-23   来源:   浏览:
本篇文章适用于RA8889M,RA8877,RA8876,RA8873M,RA8871M。

首先将需要使用的文字经过软件生成 .dot后缀文件(需要可与我们联系) ,将文件烧入到flash中

调用的函数如下:
(一)

首先定义出需要用到的宏定义,根据使用的实际数据进行修改
#define LCD_W 800 //LCD Resolution (Width)
#define LCD_H 480 //LCD Resolution (Height)
 
#define Layer_W 800 // Layer Width/Canvas Width (=LCD_W)
 
#define Layer_0_addr 0 // Display Layer Start Address
#define Layer_1_addr Layer_W*LCD_H*2 // Non Display Layer Start Adress (16bpp)
//#define Flash_CS0 //SPI Flash use CS0
#define Flash_CS1 //SPI Flash use CS1     //这里是选择对应的flash,读取CS0或是CS1

(二)
写入函数
/*
//用户字体ROM演示
//LCD:1280x800
//Canvas & Main Width:1280
//字号Font Size:16x16
//颜色深度Color Depth:16bpp
//=================================
//x&y:显示窗口x/y坐标
//透明:1=>透明,0=>不透明
transparent: 1=>transparent, 0=> not transparent
//前景色:Foreground Color
//背景色:Background Color
*/
void User_Font_ROM_Display(unsigned short font_num, unsigned short x, unsigned short y, 
unsigned char transparent, unsigned short fore_color, unsigned back_color)
{
  unsigned char i=0;
 
Memory_16bpp_Mode();  
Memory_Linear_Mode();
 
SFI_DMA_Source_Start_Address(32*font_num);
 
Start_SFI_DMA();
Check_Busy_SFI_DMA();
 
  Memory_16bpp_Mode();
  Memory_XY_Mode();
 
  for(i=0; i<16; i++)
  {
    BTE_S0_Color_16bpp();
    BTE_S0_Memory_Start_Address(Layer_1_addr);
    BTE_S0_Image_Width(Layer_W);
    BTE_S0_Window_Start_XY(i,0);
 
 
    BTE_Destination_Color_16bpp();  
    BTE_Destination_Memory_Start_Address(Layer_1_addr);
    BTE_Destination_Image_Width(Layer_W);
 
    BTE_Destination_Window_Start_XY(0,16+i);
 
    BTE_ROP_Code(15);
    BTE_Operation_Code(0xE);
 BTE_Window_Size(16,1);
 
    Foreground_color_65k(fore_color);
    Background_color_65k(back_color);
 
    BTE_Enable();
 
    Check_BTE_Busy();
  }
BTE_S0_Color_16bpp();
BTE_S0_Memory_Start_Address(Layer_1_addr);
BTE_S0_Image_Width(Layer_W);
BTE_S0_Window_Start_XY(0,16);
 
BTE_Destination_Color_16bpp();  
BTE_Destination_Memory_Start_Address(Layer_0_addr);
BTE_Destination_Image_Width(Layer_W);
BTE_Destination_Window_Start_XY(x+8,y);
 
BTE_ROP_Code(12);
 
if(transparent==0)
 BTE_Operation_Code(0x2);
else
BTE_Operation_Code(0x5);
BTE_Window_Size(8,16);
 
BTE_Enable();
Check_BTE_Busy();
 
BTE_S0_Color_16bpp();
BTE_S0_Memory_Start_Address(Layer_1_addr); //S0 Address 1280*480*3
BTE_S0_Image_Width(Layer_W);
BTE_S0_Window_Start_XY(8,16);
 
BTE_Destination_Color_16bpp();  
BTE_Destination_Memory_Start_Address(Layer_0_addr);
BTE_Destination_Image_Width(Layer_W);
BTE_Destination_Window_Start_XY(x,y);
BTE_ROP_Code(12);
if(transparent==0)
 BTE_Operation_Code(0x2);
else
BTE_Operation_Code(0x5);
BTE_Window_Size(8,16);
  BTE_Enable();
  Check_BTE_Busy();
}

(三)
写入前设置写入模式位数以及坐标等,然后调用二的函数进行显示

void  display()
{

Main_Image_Start_Address(Layer_0_addr);
  Main_Image_Width(Layer_W);
  Main_Window_Start_XY(0,0);
Select_Main_Window_16bpp();
 
  Canvas_Image_Start_address(Layer_0_addr);
  Canvas_image_width(Layer_W);
Memory_16bpp_Mode();
  Memory_XY_Mode();
  
Host_Bus_16bit();
Data_Format_16b_16bpp();
Graphic_Mode();
Active_Window_XY(0,0);
  Active_Window_WH(Layer_W,LCD_H);
  Goto_Pixel_XY(0,0);
 
  Draw_Square_Fill(0xF0F0,0,0,Layer_W,LCD_H);
 
SPI_Clock_Period(0);
Select_RA8875_SPI_Mode0_and_Mode3();
Select_SFI_Single_Mode_Dummy_8T_0Bh();
Enable_SFlash_SPI();
Select_SFI_24bit_Address();
Select_SFI_1();
Select_SFI_DMA_Mode();
SFI_DMA_Transfer_Number(32);
SFI_DMA_Destination_Start_Address(Layer_1_addr);
 
 
  User_Font_ROM_Display(2000,100,200,0,0xf800,0x07e0);

}


DEMO应用范例
void UserFontROM16x16_Demo(void)
{
  unsigned short i;
unsigned short j=0,k=0,h=0;
 
Main_Image_Start_Address(Layer_0_addr);
  Main_Image_Width(Layer_W);
  Main_Window_Start_XY(0,0);
Select_Main_Window_16bpp();
 
  Canvas_Image_Start_address(Layer_0_addr);
  Canvas_image_width(Layer_W);
Memory_16bpp_Mode();
  Memory_XY_Mode();
  
Host_Bus_16bit();
Data_Format_16b_16bpp();
Graphic_Mode();
Active_Window_XY(0,0);
  Active_Window_WH(Layer_W,LCD_H);
  Goto_Pixel_XY(0,0);
 
//Clear Display
  Draw_Square_Fill(0x000000,0,0,Layer_W,LCD_H);
 
 
 
  //SPI Flash Parameter Setting
SPI_Clock_Period(0);
Select_RA8875_SPI_Mode0_and_Mode3();
Select_SFI_Single_Mode_Dummy_8T_0Bh();  
Enable_SFlash_SPI();
 
 
#ifdef Over_128Mb
 
  switch_24bits_to_32bits(1);
Select_SFI_32bit_Address();
 
#ifdef Flash_CS0
Select_SFI_0();
#endif
 
#ifdef Flash_CS1
Select_SFI_1();
#endif
 
#endif
 
 
#ifndef Over_128Mb
 
  Select_SFI_24bit_Address();
 
#ifdef Flash_CS0
Select_SFI_0();
#endif
 
#ifdef Flash_CS1
Select_SFI_1();
#endif
 
#endif
 
Select_SFI_DMA_Mode();
SFI_DMA_Transfer_Number(32);
SFI_DMA_Destination_Start_Address(Layer_1_addr);
 
 
  User_Font_ROM_Display(2000, 100, 200, 0, 0xf800,0x07e0);
 
  for(i=0; i<40; i++)
  {
    User_Font_ROM_Display(2000+i, 50+16*i, 100, 1, 0xffff,0x001f);
  }
 
}

显示效果


分享到:

相关热词搜索:

上一篇:自建字库调用方法及范例(RA8876,RA8877)
下一篇:单片机与RA8875接法及软件初始化之一(通过8080接口介绍)