高中生
最后登录1970-1-1
在线时间 小时
注册时间2018-5-13
|
楼主 |
发表于 2020-5-2 17:59:06
|
显示全部楼层
本帖最后由 pidalu 于 2020-5-2 18:06 编辑
自己摸索了两天,终于找到相关资料了。等宽字体的偏移地址如下:
ASCII:
5x7:0x1DDF80
7x8:0x1DE280
6x12:0x1DBE00
8x16:0x1DD780
12x24:0x1DFF00
16x32:0x1E5A50
GB2312:宋体
12x12:0x00000
16x16:0x2C9D0
24x24:0x68190
32x32:0xEDF00
下面的例子代码经过调试验证,是可行的。
void GetDataFromIC(uint32_t nStartAddr,PSTR Buf,uint16_t nSize)
{
FOT_Select();
W_spi8(0x0B); //发送字库IC连续读取命令
W_spi24(nStartAddr);//发送起始地址(3字节)
W_spi8(0x00); //发送一个Dummy字节
R_spiX(Buf,nSize); //读取字模数据到缓冲区
FOT_UnSelect();
}
uint32_t GetAddrByAsc(char c)
{
uint32_t nAddr = 0;
c = max(0x20,c) & 0x7F;
nAddr = c - 0x20;
return nAddr;
}
uint32_t GetAddrByGb2312(uint16_t c)
{
uint32_t nAddr = 0;
uint8_t msb = (uint8_t)(c>>8); //区码
uint8_t lsb = (uint8_t)(c); //位码
if ((msb>=0xA1) && (msb<=0xA9)) {// 1~9,符号区域
nAddr = (msb-0xA1)*94 + (lsb-0xA1);
}else if ((msb>=0xB0)&&(msb<=0xF7)){// 16~87,汉字区域
nAddr = (msb-0xB0)*94 + (lsb-0xA1) + 846;
}
return nAddr;
}
void GetAsc_5x7(char c,PSTR Buf)
{
const uint16_t nSize = 8;
const uint32_t nBaseAddr = 0x1DDF80;
uint32_t nAddr = GetAddrByAsc(c);
nAddr *= nSize;
nAddr += nBaseAddr;
GetDataFromIC(nAddr,Buf,nSize);
}
void GetAsc_7x8(char c,PSTR Buf)
{
const uint16_t nSize = 8;
const uint32_t nBaseAddr = 0x1DE280;
uint32_t nAddr = GetAddrByAsc(c);
nAddr *= nSize;
nAddr += nBaseAddr;
GetDataFromIC(nAddr,Buf,nSize);
}
void GetAsc_6x12(char c,PSTR Buf)
{
const uint16_t nSize = 12;
const uint32_t nBaseAddr = 0x1DBE00;
uint32_t nAddr = GetAddrByAsc(c);
nAddr *= nSize;
nAddr += nBaseAddr;
GetDataFromIC(nAddr,Buf,nSize);
}
void GetAsc_8x16(char c,PSTR Buf)
{
const uint16_t nSize = 16;
const uint32_t nBaseAddr = 0x1DD780;
uint32_t nAddr = GetAddrByAsc(c);
nAddr *= nSize;
nAddr += nBaseAddr;
GetDataFromIC(nAddr,Buf,nSize);
}
void GetAsc_12x24(char c,PSTR Buf)
{
const uint16_t nSize = 48;
const uint32_t nBaseAddr = 0x1DFF00;
uint32_t nAddr = GetAddrByAsc(c);
nAddr *= nSize;
nAddr += nBaseAddr;
GetDataFromIC(nAddr,Buf,nSize);
}
void GetAsc_16x32(char c,PSTR Buf)
{
const uint16_t nSize = 64;
const uint32_t nBaseAddr = 0x1E5A50;
uint32_t nAddr = GetAddrByAsc(c);
nAddr *= nSize;
nAddr += nBaseAddr;
GetDataFromIC(nAddr,Buf,nSize);
}
void GetGB2312_12x12(uint16_t c, PSTR Buf)
{
const uint16_t nSize = 12*2;
const uint32_t nBaseAddr = 0x00;
uint32_t nAddr = GetAddrByGb2312(c);
nAddr *= nSize;
nAddr += nBaseAddr;
GetDataFromIC(nAddr,Buf,nSize);
}
void GetGB2312_16x16(uint16_t c, PSTR Buf)
{
const uint16_t nSize = 16*2;
const uint32_t nBaseAddr = 0x2C9D0;
uint32_t nAddr = GetAddrByGb2312(c);
nAddr *= nSize;
nAddr += nBaseAddr;
GetDataFromIC(nAddr,Buf,nSize);
}
void GetGB2312_24x24(uint16_t c, PSTR Buf)
{
const uint16_t nSize = 24*3;
const uint32_t nBaseAddr = 0x68190;
uint32_t nAddr = GetAddrByGb2312(c);
nAddr *= nSize;
nAddr += nBaseAddr;
GetDataFromIC(nAddr,Buf,nSize);
}
void GetGB2312_32x32(uint16_t c, PSTR Buf)
{
const uint16_t nSize = 32*4;
const uint32_t nBaseAddr = 0xEDF00;
uint32_t nAddr = GetAddrByGb2312(c);
nAddr *= nSize;
nAddr += nBaseAddr;
GetDataFromIC(nAddr,Buf,nSize);
}
|
|