使用自制汉字库

联系方式:qq:809777626

1、展示效果


使用自制汉字库_第1张图片

2、 汉字库烧录到外部FLASH中
链接:https://pan.baidu.com/s/1pHi6S3gwZuYbyTLrY4U3CA 密码:61nq
3、示例代码

//UN2GBK_ADDR是您烧录在外部FLASH的地址
#define UN2GBK_ADDR                     (EX_UI_PARA_ADDR+EX_UI_PARA_ADDR_SIZE)
#define UN2GBK_ADDR_SIZE                (41804) 

#define HZ_16X16_ADDR                   (UN2GBK_ADDR + UN2GBK_ADDR_SIZE)
#define HZ_16X16_ADDR_SIZE              (282752)

#define HZ_24X24_ADDR                   (HZ_16X16_ADDR + HZ_16X16_ADDR_SIZE)
#define HZ_24X24_ADDR_SZIE              (636192)

#define HZ_16X16_SIZE (16*16/8)
#define HZ_24X24_SIZE (24*24/8)
    
u16 UNICODEtoGBK(u16 unicode)
{
    u32 offset,position;
    u16 bGbk;


    if(unicode<0x4e00) return unicode;//Swap16(unicode);
    if(unicode<=0X9FA5)offset=unicode-0X4E00;
    else if(unicode>0X9FA5)
    {
        if(unicode<0XFF01||unicode>0XFF61)return 0x0020;
        return Swap16(unicode-0x5b60);
    }
    //UNICODE_FILE_OFFSET
    position=UN2GBK_ADDR+offset*2;
    SPI_FLASH_ReadCont((u8*)&bGbk,position,2);
    return bGbk ; 

}
uint32_t addr=0;
uint8_t DZ_Data[300];
void display_hz(void)
{   
    ST7789_Clear(BLACK);
    //16X16
    addr = GB2312_FindAddr(0xa1a9,HZ_16X16_SIZE);
    SPI_FLASH_ReadCont(DZ_Data,addr+HZ_16X16_ADDR,HZ_16X16_SIZE);
    ST7789_ShowHZ_Point_form_flash(120,0,16,16,DZ_Data);
    
    addr = GB2312_FindAddr(0xb0a1,HZ_16X16_SIZE);//啊
    SPI_FLASH_ReadCont(DZ_Data,addr+HZ_16X16_ADDR,HZ_16X16_SIZE);
    ST7789_ShowHZ_Point_form_flash(140,0,16,16,DZ_Data);
    
    addr = UNICODEtoGBK(0x963F);//啊
    addr = GB2312_FindAddr(Swap16(addr),HZ_16X16_SIZE);
    SPI_FLASH_ReadCont(DZ_Data,addr+HZ_16X16_ADDR,HZ_16X16_SIZE);
    ST7789_ShowHZ_Point_form_flash(160,0,16,16,DZ_Data);
    //24X24  
    addr = GB2312_FindAddr(0xa1a9,HZ_24X24_SIZE);
    SPI_FLASH_ReadCont(DZ_Data,addr+HZ_24X24_ADDR,HZ_24X24_SIZE);
    ST7789_ShowHZ_Point_form_flash(120,16,24,24,DZ_Data);
    
    addr = GB2312_FindAddr(0xb0a1,HZ_24X24_SIZE);//啊
    SPI_FLASH_ReadCont(DZ_Data,addr+HZ_24X24_ADDR,HZ_24X24_SIZE);
    ST7789_ShowHZ_Point_form_flash(140,16,24,24,DZ_Data);
    
    addr = UNICODEtoGBK(0x963F);//啊
    addr = GB2312_FindAddr(Swap16(addr),HZ_24X24_SIZE);
    SPI_FLASH_ReadCont(DZ_Data,addr+HZ_24X24_ADDR,HZ_24X24_SIZE);
    ST7789_ShowHZ_Point_form_flash(160,16,24,24,DZ_Data);
}



你可能感兴趣的:(使用自制汉字库)