历史上的今天
今天是:2024年10月13日(星期日)
2020年10月13日 | 在emwin中显示字库芯片GT23L24M0140的字模
2020-10-13 来源:eefocus
环境:
主机:WIN8
开发环境:MDK5.13
mcu: stm32f407VGIGH6
emwin: STemWin5.22
字库芯片:GT23L24M0140
说明:
项目中需要显示生僻字,所以不能使用GB2312,选择字库芯片GT23L24M0140,支持GB18030标准。
难点在于在emwin中嵌入此字库芯片的字符,emwin本身有一套接口,所以必须满足这套接口才能显示。
解决的方法是先移植在emwin中显示sd卡/flash中字库的函数,然后将具体读取函数替换成直接读取字库芯片的函数。
字库芯片的驱动程序见此文:驱动字库芯片GT23L24M0140
显示效果:

源代码:
GUI_UC_EncodeNone.c
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* 礐/GUI is protected by international copyright laws. Knowledge of the
* source code may not be used to write a similar product. This file may
* only be used in accordance with a license and should not be redistributed
* in any way. We appreciate your understanding and fairness.
*
----------------------------------------------------------------------
File : GUI_UC_EncodeNone.c
Purpose : Encoding routines for non unicode systems (default)
---------------------------END-OF-HEADER------------------------------
*/
//#include "GUI_Protected.h"
#include "GUI_Private.h"
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _GetCharCode
*
* Purpose:
* Return the UNICODE character code of the current character.
*/
static U16 _GetCharCode(const char GUI_UNI_PTR * s) {
if((*s) > 0xA0)
{
return *(const U16 GUI_UNI_PTR *)s;
}
return *(const U8 GUI_UNI_PTR *)s;
}
/*********************************************************************
*
* _GetCharSize
*
* Purpose:
* Return the number of bytes of the current character.
*/
static int _GetCharSize(const char GUI_UNI_PTR * s) {
GUI_USE_PARA(s);
if((*s) > 0xA0)
{
return 2;
}
return 1;
}
/*********************************************************************
*
* _CalcSizeOfChar
*
* Purpose:
* Return the number of bytes needed for the given character.
*/
static int _CalcSizeOfChar(U16 Char) {
GUI_USE_PARA(Char);
if(Char > 0xA0A0)
{
return 2;
}
return 1;
}
/*********************************************************************
*
* _Encode
*
* Purpose:
* Encode character into 1/2/3 bytes.
*/
static int _Encode(char *s, U16 Char) {
if(Char > 0xA0A0)
{
*((U16 *)s) = (U16)(Char);
return 2;
}
*s = (U8)(Char);
return 1;
}
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
/*********************************************************************
*
* _API_Table
*/
const GUI_UC_ENC_APILIST GUI__API_TableNone = {
_GetCharCode, /* return character code as U16 */
_GetCharSize, /* return size of character: 1 */
_CalcSizeOfChar, /* return size of character: 1 */
_Encode /* Encode character */
};
/*********************************************************************
*
* Exported code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_UC_SetEncodeNone
*/
void GUI_UC_SetEncodeNone_User(void) {
GUI_LOCK();
//GUI_Context.pUC_API = &GUI__API_TableNone;
GUI_pUC_API = &GUI__API_TableNone;
GUI_UNLOCK();
}
/*************************** End of file ****************************/
GUI_CharPEx.c
#include #include "GUI_Private.h" //#include "ff.h" #include "string.h" #include "inf_font.h" #include "font_type.h" //字模数据的暂存数组,以单个字模的最大字节数为设定值 #define BYTES_PER_FONT 1024 static U8 GUI_FontDataBuf[BYTES_PER_FONT]; ///*---------------------------------------------------------------------------*/ ///*字库外部函数部分-----------------------------------------------------------*/ //void GUI_X_GetFontData(char* font, U32 oft, U8 *ptr, U8 bytes) //{ FIL fsrc; // 定义文件操作类 FRESULT res; // 定义操作结果变量 UINT br; // 定义读写数量变量 res = f_open(&fsrc, font, FA_OPEN_EXISTING | FA_READ); //打开字库文件 if(res != FR_OK) { } res = f_lseek(&fsrc,oft); //找到首地址 res = f_read(&fsrc, ptr, bytes, &br); //读取32个字库点阵数据 res = f_close(&fsrc); //关闭字体 // //memcpy(ptr,acFontHZ12_b9da1,24); // //memcpy(ptr,read_buf,24); // // // bytes = inf_font_read(ASCII_7X8,'j',ptr); //} static void GUI_GetDataFromMemory(const GUI_FONT_PROP GUI_UNI_PTR *pProp, U16P c) { U16 BytesPerFont; U32 oft; char *font = (char *)pProp->paCharInfo->pData; //汉字正序 uint8_t c1 = c >> 8; uint8_t c2 = c; uint16_t c3 = (c2 << 8) + c1; BytesPerFont = GUI_pContext->pAFont->YSize * pProp->paCharInfo->BytesPerLine; //每个字模的数据字节数 if (BytesPerFont > BYTES_PER_FONT) {BytesPerFont = BYTES_PER_FONT;} if (c < 0x80) //英文字符地址偏移算法 { oft = (c-0x20) * BytesPerFont; BytesPerFont = inf_font_read(Font_Now,c,GUI_FontDataBuf); } else { oft = ((((c >> 8)-0xA1)) + ((c & 0xFF)-0xb0) * 94)* BytesPerFont; //中文字符地址偏移算法包括符号 BytesPerFont = inf_font_read(Font_Now,c3,GUI_FontDataBuf); // if (strncmp(FontEx_HZ,font,sizeof(FontEx_HZ)) == 0) // { // // } } //GUI_X_GetFontData(font, oft, GUI_FontDataBuf, BytesPerFont); // BytesPerFont = inf_font_read(Font_Now,c,GUI_FontDataBuf); } void GUIPROP_X_DispChar(U16P c) { int BytesPerLine; GUI_DRAWMODE DrawMode = GUI_pContext->TextMode; const GUI_FONT_PROP GUI_UNI_PTR *pProp = GUI_pContext->pAFont->p.pProp; //搜索定位字库数据信息 for (; pProp; pProp = pProp->pNext) { if ((c >= pProp->First) && (c <= pProp->Last))break; } if (pProp) { GUI_DRAWMODE OldDrawMode; const GUI_CHARINFO GUI_UNI_PTR * pCharInfo = pProp->paCharInfo; GUI_GetDataFromMemory(pProp, c);//取出字模数据 BytesPerLine = pCharInfo->BytesPerLine; OldDrawMode = LCD_SetDrawMode(DrawMode); LCD_DrawBitmap(GUI_pContext->DispPosX, GUI_pContext->DispPosY, pCharInfo->XSize, GUI_pContext->pAFont->YSize, GUI_pContext->pAFont->XMag, GUI_pContext->pAFont->YMag, 1, /* Bits per Pixel */
史海拾趣
|
在QUARTUS里设置全局信号,是不是只要在ASSIGNMENT EDITOR把某一信号设置成全局信号就成,我这么设置,为什么编译的时候说没有声明?… 查看全部问答> |
|
---〓×〓×〓×〓×〓---Addr/DATA 请问上述地址与数据复用时序图中,为什么会有上下两根信号线? 一般的不都是一根的信号线吗,如:s0 s1 s2____/---\\_______ 不知道哪有芯片时序图的详细介绍书籍没?麻烦知道的给指点下,谢谢… 查看全部问答> |
|
4442卡的初始密码为ffffff,这个密码是16进制的,还是ASCII吗?明华读卡器的密码校验函数为:int csc_4442(int icdev, int len, unsigned char* p_string)我把\"ffffff\"作为参数放入,但校验错误。用hex_asc(\"ffffff\", s3, 3) 转换后把s3作为参数 ...… 查看全部问答> |
|
工作模式 bxCAN有3个主要的工作模式:初始化、正常和睡眠模式。 初始化模式 *软件通过对CAN_MCR寄存器的INRQ位置1,来请求bxCAN进入初始化模式,然后等待硬件对CAN_MSR寄存器的INAK位置1来进行确认。 *软件通过对CAN_MCR寄存器的 ...… 查看全部问答> |
|
这个是STM32的PWM输出模式,STM32的TIM1模块是增强型的定时器模块,天生就是为电机控制而生,可以产生3组6路PWM,同时每组2路PWM为互补,并可以带有死区,可以用来驱动H桥。 下面的代码,是利用TIM1模块的1、2通道产生一共4路PWM的代码例子, ...… 查看全部问答> |
|
贪便宜,在淘宝上买了个山寨的ST-LINK。 现在出现了奇怪的问题。 我用的是STM8S207S6,单片机工作电压是5V. ST-LINK的SWIM口,其供电电压时3.3V。 当我的板子不供电的时候,我直接连ST-LINK,由它来供电,我可以把软件down到单片机,并且在 ...… 查看全部问答> |
|
memcpy(&secureRamFuncs_runstart, &secureRamFuncs_loadstart, (Uint32)&secureRamFuncs_loadsize); 如题,请问这个函数的三个参数是在什么地方给它付的值?… 查看全部问答> |




