📄 tft_user.c
字号:
//====================================================================================
//File Name: TFT_User.c
//Description: TFT user-defined callback routines
//Update: 2007.01.17 V0.1 by wangtao <wangtao@sunnorth.com.cn>
//====================================================================================
#include "TFT_API.h"
#include "Resource.h"
extern short gAsciiFontType;
extern short gChineseFontType;
extern STR_FONT gAsciiFont;
extern STR_FONT gChineseFont;
const STR_FONT AsciiFontSet[] = { // ASCII font list
{8, 16, RES_ASC16},
};
const STR_FONT ChineseFontSet[] = { // Chinese font list
{16, 16, RES_HZK16},
};
//=============================================================
// Prototype: void TFT_CallBack_UpdateFont(void);
// Description: Update information of current font. It will be called by TFT_API.c.
// Arguments: None
// Return Value: None
//=============================================================
void TFT_CallBack_UpdateFont(void)
{
gAsciiFont.CharWidth = AsciiFontSet[gAsciiFontType].CharWidth;
gAsciiFont.CharHeight = AsciiFontSet[gAsciiFontType].CharHeight;
gAsciiFont.FontBuf = AsciiFontSet[gAsciiFontType].FontBuf;
gChineseFont.CharWidth = ChineseFontSet[gChineseFontType].CharWidth;
gChineseFont.CharHeight = ChineseFontSet[gChineseFontType].CharHeight;
gChineseFont.FontBuf = ChineseFontSet[gChineseFontType].FontBuf;
}
//=============================================================
// Prototype: void TFT_CallBack_GetCharBuf(unsigned short CharCode, STR_FONT *Font_Char);
// Description: Set TFT buffer format and address.
// Arguments:
// CharCode - Character code
// Font_Char - Address of dot matrix structure
// Return Value:
// None
//=============================================================
void TFT_CallBack_GetCharBuf(unsigned short CharCode, STR_FONT *Font_Char)
{
if(CharCode<=0x00FF) // ASCII character
{
Font_Char->CharWidth = gAsciiFont.CharWidth;
Font_Char->CharHeight = gAsciiFont.CharHeight;
Font_Char->FontBuf = gAsciiFont.FontBuf;
Font_Char->FontBuf += CharCode*gAsciiFont.CharHeight*((gAsciiFont.CharWidth+7)>>3);
}
else // Chinese character
{
Font_Char->CharWidth = gChineseFont.CharWidth;
Font_Char->CharHeight = gChineseFont.CharHeight;
Font_Char->FontBuf = gChineseFont.FontBuf;
Font_Char->FontBuf += (unsigned int)(94*((CharCode&0xFF)-0xA1)+((CharCode>>8)-0xA1))
* gChineseFont.CharHeight * ((gChineseFont.CharWidth+7)>>3);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -