⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcb8000.c

📁 拓普微TCB8000中文液晶的驱动程序,并在此基础上完成了显示汉字,游标,图片等功能.
💻 C
📖 第 1 页 / 共 2 页
字号:
	Buffer[1]=0x81; //写游标图案存储单元起始地址 示例为2b000H
	Buffer[2]=0x00;
	Buffer[3]=0xb0;
	Buffer[4]=0x02;
	WritePKG(Buffer);

	for(j=0;j<2;j++) //写入游标图案数据给2b000H 后单元
	{
		SdCmd(0x84); //写入显示RAM 指令码
		SdCmd(32); //写入数据量
		for(k=0;k<32;k++) //写入数据
		{
			SdCmd(gImage_1[k+j*32]);
		}
		CmdEnd();
	}
}
/*******************************************************************************************
** Function name: use_sprite
** Descriptions : 使用游标
** Input        : 无
** Output       : 无 
*******************************************************************************************/
void use_sprite(uint16 x, uint16 y)
{
	uint8 buf[5];

	//启用图标
	buf[0]=4;
	buf[1]=0x83;
	buf[2]=0x00;
	buf[3]=0xf1;
	buf[4]=0x01; //激活游标寄存器 D[1:0]=01 2bpp
	WritePKG(buf);	
	buf[0] = 4;
	buf[1] = 0x83;
	buf[2] = 0;
	buf[3] = 0xF1;
	buf[4] = 0xc1;
	WritePKG(buf);
	buf[0] = 4;
	buf[1] = 0x83;
	buf[2] = 0x0c;
	buf[3] = 0xF1;
	buf[4] = x;
	WritePKG(buf);
	buf[0] = 4;
	buf[1] = 0x83;
	buf[2] = 0x0d;
	buf[3] = 0xF1;
	buf[4] = x >> 8;
	WritePKG(buf);
	buf[0] = 4;
	buf[1] = 0x83;
	buf[2] = 0x0e;
	buf[3] = 0xF1;
	buf[4] = y;
	WritePKG(buf);
	buf[0] = 4;
	buf[1] = 0x83;
	buf[2] = 0x0F;
	buf[3] = 0xF1;
	buf[4] = y >> 8;
	WritePKG(buf);	
}
//----------------------------------- 
//初始化设置 
//----------------------------------- 
/*
uchar code Set_F500[]={4,0x83,0x00,0xf5,0x00};
uchar code Set_F504[]={4,0x83,0x04,0xf5,0x04};
uchar code Set_F505[]={4,0x83,0x05,0xf5,0x80};
uchar code Set_F6C4[]={4,0x83,0xc4,0xf6,0x10};
uchar code Set_F080[]={4,0x83,0x80,0xf0,0xfc};
uchar code Set_F08E[]={4,0x83,0x8e,0xf0,0x32};
uchar code Set_F090[]={4,0x83,0x90,0xf0,0x14};
uchar code Set_F091[]={4,0x83,0x91,0xf0,0x25};
uchar code Set_F092[]={4,0x83,0x92,0xf0,0x1e};
uchar code Set_F094[]={4,0x83,0x94,0xf0,0x05};
uchar code Set_F095[]={4,0x83,0x95,0xf0,0x0e};
uchar code Set_F096[]={4,0x83,0x96,0xf0,0x03};
uchar code Set_8F[]={7,0x8f,0x69,0x45,0x61,0x67,0x6c,0x65};*/
//----------------------------------- 
//初始化设置  
//----------------------------------- 
const uint8 SRAM01[]={4,0x83,0x00,0xf5,0x00}; // memory 脉冲宽度 
//const uint8 SRAM02[]={4,0x83,0x01,0xf5,0xe0};                                    // memory 16位数据线 
const uint8 ROM01[]={4,0x83,0x04,0xf5,0x04};// 外部字库 脉冲宽度 
//const uint8 ROM01[]={4,0x83,0x04,0xf5,0x04};  
const uint8 ROM02[]={4,0x83,0x05,0xf5,0x80};  
const uint8 ROM03[]={4,0x83,0xc4,0xf6,0x10}; // 外部字库 8位数据线 
const uint8 LCDConfig01[]={4,0x83,0x80,0xf0,0xfc};// panel选择 
const uint8 LCDConfig02[]={4,0x83,0x8e,0xf0,0x32};// Pixel Clock 6MHZ 

const uint8 LCDConfig03[]={4,0x83,0x90,0xf0,0x14};	// Horizontal Front Porch 
const uint8 LCDConfig04[]={4,0x83,0x91,0xf0,0x25};// Horizontal Back Porch 
const uint8 LCDConfig05[]={4,0x83,0x92,0xf0,0x1e};// Horizontal Sync 脉冲宽度 
const uint8 LCDConfig06[]={4,0x83,0x94,0xf0,0x05};// Vertical Front Porch 
const uint8 LCDConfig07[]={4,0x83,0x95,0xf0,0x0e};// Vertical Back Porch 
const uint8 LCDConfig08[]={4,0x83,0x96,0xf0,0x03};// Vertical Sync 脉冲宽度 
const uint8 Clock[]={7,0x8f,0x69,0x45,0x61,0x67,0x6c,0x65}; // 时钟使能 
const uint8 CharSet[]={2,0x10,0x04};  // 字库设置:中文字库 
//uint8 CharSet[]={2,0x10,0x00};  // 字库设置:ASCII码 
const uint8  LCDConfigWidth[] = {4,0x83,0x81,0xF0,0x28};
const uint8  LCDConfigLine0[] = {4,0x83,0x82,0xF0,0xef};
const uint8  LCDConfigLine1[] = {4,0x83,0x83,0xF0,0x00};

/*******************************************************************************************
** Function name: initLCDM
** Descriptions : 初始化LCD
** Input        : 无
** Output       : 无 
*******************************************************************************************/

void initLCDM(void) 
{ 
	WritePKG(SRAM01);   
	// 外置 64K×16SRAM 
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(ROM01);             
	// 外置中文字库ROM 
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(ROM02);
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(ROM03);	
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(LCDConfig01);      
	// 320*240 点阵 16bpp TFT 
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(LCDConfig02);      
	// TFT面板时序设置 
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(LCDConfig03); 
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(LCDConfig04); 
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(LCDConfig05); 
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(LCDConfig06); 
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(LCDConfig07); 
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(LCDConfig08);
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(LCDConfigWidth);
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(LCDConfigLine0);
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(LCDConfigLine1); 
//	OSTimeDly(OS_TICKS_PER_SEC); 
	WritePKG(CharSet);          
//	OSTimeDly(OS_TICKS_PER_SEC); // 16×16 GB2312 
	WritePKG(Clock);            

	SET_SPRITE();
//	OSTimeDly(OS_TICKS_PER_SEC); // 开时钟 

	ClearScreen(MAGENTA); // 清屏 
  /*  OSTimeDly(OS_TICKS_PER_SEC / 200);
	SetFgColor(0x14, RED);
	SetCharCoord(100, 100);
	Printstr((const uint8*)"我是李力");
    OSTimeDly(OS_TICKS_PER_SEC / 200);	
	SetFgColor(0x20, BLUE);
	SetCharCoord(200, 200);
	Printstr((const uint8*)"我不是李力");
	
    OSTimeDly(OS_TICKS_PER_SEC / 200);	
	SetBgColor(YELLOW);
    OSTimeDly(OS_TICKS_PER_SEC / 200);
	Draw_Rect(0x26, 10, 10, 100, 100);
	OSTimeDly(OS_TICKS_PER_SEC / 200);
	ClearScreen(MAGENTA); 

	use_sprite(100, 100);
	SetFgColor(0x20, BLUE);
	SetCharCoord(00, 00);
	Printstr((const uint8*)"我不是李力");
	use_sprite(100, 200);
	SetCharCoord(50, 50);
	Printstr((const uint8*)"我不是李力");*/
} 

/*******************************************************************************************
** Function name: short_delay
** Descriptions : 延时程序
** Input        : 无
** Output       : 无 
*******************************************************************************************/
void  crt_short_delay()
{
	uint16 i;
	for(i = 0; i < 300;i++);
}

/*******************************************************************************************
** Function name: DispBmp
** Descriptions : 写入指定的bmp文件
** Input        : x, y	写入文件坐标
				  width,height 写入图片的大小 
				  bmp_data	图片的内容
** Output       : 无 
*******************************************************************************************/

void DispBmp(uint16 x,uint16 y,uint16 width,uint16 height,const uint8* bmp_data)
{
	uint8 MemPtr[]={4,0x81,0x00,0x00,0x00}; 
	uint16 i,j; 
	uint16 k=0; 
	unsigned long addr; 
	uint16 ll;
	
	uint8 times_of_30,remains_of_30;

	addr=2*x+640*y;                                       // 图片起始位置为2*X+640*Y;其中 X=80,Y=60 
	crt_delay(20); 

	times_of_30 = width / 30;
	remains_of_30 = width % 30;
	for(j=0;j<height;j++) 
	{ 
          MemPtr[2]=addr; 
          MemPtr[3]=addr>>8; 
          MemPtr[4]=addr>>16; 
          WritePKG(MemPtr);                       // 设置起始内存地址指针 
          //每次写60个字节
         for( i = 0; i < times_of_30;i++)
          {
          	   SdCmd(0x84);                       // 送一个像素的数据到内存 
               SdCmd(60); 
 
               for(ll = 0; ll < 30 ; ll++)
               {
               		SdCmd(bmp_data[2*k]); 
               		SdCmd(bmp_data[2*k+1]); 
               		k++; 
               }
               CmdEnd();
               crt_short_delay();
          } 
          
          if(remains_of_30 > 0)
          {
          	   SdCmd(0x84);                       // 送一个像素的数据到内存 
               SdCmd(2*remains_of_30); 
 
               for(ll = 0; ll < remains_of_30 ; ll++)
               {
               		SdCmd(bmp_data[2*k]); 
               		SdCmd(bmp_data[2*k+1]); 
               		k++; 
               }
             

	          	CmdEnd();       
                crt_short_delay();                      
          }           
          addr+=640; 
	} 
	 LCD_COM_ADDR = 0x00;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -