|
本帖最后由 cheney03 于 2020-6-16 08:35 编辑
//TFT液晶屏,RA8875芯片驱动,下面是显示汉字程序,实验结果未显示汉字。不知道是哪里有问题,是不是红色字体寄存器设置有问题?麻烦各位大佬帮忙看下
// 初次用到取模方式,有个疑问:取模后的数组存放在单片机中,LCD是怎么样读取字模的,字模属于片外CGROM?
#include <stdio.h>
#include <reg52.h>
#include "ra8875.h
#define White 0xFFFF
#define Black 0x0000
void Cmd_Write(unsigned char a,unsigned char b)
{
LCD_CmdWrite(a);//写指令
LCD_DataWrite(b); //写数据
/********文字写入位置
void FontWrite_Position(unsigned int X,unsigned int Y)
{
unsigned char temp;
temp=X;
LCD_CmdWrite(0x2A);
LCD_DataWrite(temp);
temp=X>>8;
LCD_CmdWrite(0x2B);
LCD_DataWrite(temp);
temp=Y;
LCD_CmdWrite(0x2C);
LCD_DataWrite(temp);
temp=Y>>8;
LCD_CmdWrite(0x2D);
LCD_DataWrite(temp);
}
#include "GB1616.h" //16*16汉字字模
void PutGB1616(unsigned int x, unsigned int y, unsigned char c[2], unsigned int fColor,unsigned int bColor)
{
unsigned int i,j,k;
Cmd_Write(0x40,0x80); //寄存器配置选择文字模式
Cmd_Write(0x21,0x00); //Font Control
Cmd_Write(0x22,0x05); //transparency 0x45
Cmd_Write(0x2E,0x00); //文字大小,间距设置
Cmd_Write(0x2f,0x81); // Font ROM Setting GT23L32s4w_GB2312
FontWrite_Position(x,y);
for (k=0;k<64;k++)
{
if ((codeGB_16[k].Index[0]==c[0])&&(codeGB_16[k].Index[1]==c[1]))
{
for(i=0;i<32;i++) {
unsigned short m=codeGB_16[k].Msk;
for(j=0;j<8;j++) {
if((m&0x80)==0x80) {
Text_Foreground_Color1(fColor);
}
else {
Text_Background_Color1(bColor);
}
m<<=1;
}
}
}
}
}
// ------------------ 汉字字模的数据结构定义 ------------------------ //
struct typFNT_GB16 // 汉字字模数据结构
{
unsigned char Index[3]; // 汉字内码索引
unsigned char Msk[32]; // 点阵码数据
};
/////////////////////////////////////////////////////////////////////////
// 汉字字模表 //
// 汉字库: 宋体16.dot,横向取模左高位,数据排列:从左到右从上到下 //
/////////////////////////////////////////////////////////////////////////
code struct typFNT_GB16 codeGB_16[] = // 数据表
{
/*-- 文字: 电 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
"电",0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,
0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x02,0x01,0x02,0x00,0xFE,0x00,0x00,
}
PutGB1616(20,200,"电",black,White);
下面是两个寄存器[21h]、[2Fh]的配置
|
-
1.png
(98.15 KB, 下载次数: 59)
-
2.png
(87.27 KB, 下载次数: 60)
|