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

📄 lcddrive.h

📁 这是用proteus做的基于51核的一个菜单仿真的程序开发环境keil 没有使用os在裸机上跑
💻 H
字号:
 //#include <lcddrive.h>
#include <absacc.h>
#define  unchar  unsigned char 
#define GRAPHIC_HOME_ADRESS 2048
//-----------------------------------
//the lcd driver  based on t6963c
//write by liujianwei  2005-6-23
// e-mail:liujianwei@ruyi.com
// qq:361299856
//-----------------------------------
#define LCD_DATA_PORT  		 0x8000
#define LCD_CMD_PORT   		 0x8001
#define LCD_STATUS_PORT		 0x8001
//--------------------------------------
// data type declare 
//-----------------------------------------
//#define unchar  unsigned char 
//#include <ABSACC.H>
//----------------------------------
// write data to the lcd
//----------------------------------
void  WriteData(unchar Dat)
      {
        while ((XBYTE[LCD_STATUS_PORT]&3)!=3);
        XBYTE[LCD_DATA_PORT]=Dat; 
      }
//---------------------------------------
// write command to the lcd  
//---------------------------------------
void WriteCmd(unchar Cmd)
 	{
	  while((XBYTE[LCD_STATUS_PORT]&3)!=3);
	  XBYTE[LCD_CMD_PORT]=Cmd;
	}
//----------------------------------------
// cursor  point set
//-----------------------------------------
   CursorPointSet(unchar x,unchar y)
		{
		  WriteData(x);
		  WriteData(y);
		  WriteCmd(0x21);
		}
//----------------------------------------
//adress pointer set 
//-----------------------------------------
void AdressPointSet(unchar x,unchar y)
	{
	    WriteData(x);
	    WriteData(y);
	    WriteCmd(0x24);
	}
//------------------------------------------
// text area home adress set 
//------------------------------------------
void TxtHomeAdresSet(unchar x,unchar y)
	{
	  WriteData(x);
	    WriteData(y);
	    WriteCmd(0x40);
	}
//-------------------------------------------
//text area width  set  bytes number per line 
//-----------------------------------------------
void TxtWidthSet(unchar x)
	{
	   WriteData(x);
	    WriteData(0);
	    WriteCmd(0x41);
	}
//---------------------------------------------
//graphic area home adrress set 
//---------------------------------------------
void GraphicHomeAdressSet(unchar x,unchar y)
	{
	  WriteData(x);
	    WriteData(y);
	    WriteCmd(0x42);
	}
//-------------------------------------------
//graphic  area width  set  bytes number per line 
//-----------------------------------------------
void GraphicWidthSet(unchar x)
	{
	   WriteData(x);
	    WriteData(0);
	    WriteCmd(0x43);
	}

//---------------------------------------------------
// display model set 
// logic or,logic  xor,logic and 
// text  special set
// ------------------------------------------------
 void DisplayModelOr()    //or model and use the cgrom in the lcd
	{
	  WriteCmd(0x80);
	}  

//----------------------------------------------- 
void displayModelXor()    // xor model  
	{
	  WriteCmd(0x81);
	}  
//-----------------------------------------------
void displayModelAnd()    //and model
	{
	  WriteCmd(0x83);
	}  

//-----------------------------------------------
void TxtAttributeSet()     //
	{
	  WriteCmd(0x84);
	}



//-----------------------------------------------------
// display  turn on and turn off set 
//---------------------------------------------------------
void CursorFlashOn()
	{
	  WriteCmd(0x91);
	}

void CursorFlashOff()
	{
	  WriteCmd(0x90);
	}

void CursorOn()
	{
	  WriteCmd(0x92);
	}

void CursorOff()
	{
	  WriteCmd(0x90);
	}

void TxtDisplayOn()
	{
	  WriteCmd(0x94);
	}

void TxtDisplayOff()
	{
	  WriteCmd(0x90);
	}

//-----------------------------------------------------
//cursor shape set 
//----------------------------------------------------
  void CursorShapeSet(unchar shape) //the shape my be  0xA0----0xA7
	{
	  WriteCmd(shape);
	}

//----------------------------------------------------------
// data auto read  or write set 
//----------------------------------------------------------
 void  DataAutoWrite()
	{
	  WriteCmd(0xb0);
	}
//----------------------------------------------------------
 void DataAutoRead()

	{
	  WriteCmd(0xb1);
	}
//---------------------------------------------------------
 void OverAutoWrite()
	{
	 WriteCmd(0xb2);
	}

void OverAutoRead()
	{
	 WriteCmd(0xb3);

	}
//--------------------------------------------------------------
// display a string  at  current point
//--------------------------------------------------------------
  void DisplayString(unchar string[])
  	{
	  unchar i;
	  i=0; 
	  DataAutoWrite();
	  while (string[i]!=0)
	  {
	   WriteData(string[i]-0x20);

	   i++;
	  }
	  OverAutoWrite();
	}
//----------------------------------------------------------------
// set the attribe in the mix model 
//----------------------------------------------------------------
GraphicAttribAutoWrite(unchar Attrib,  unchar Number)

	{unchar i;
		 
	   DataAutoWrite();	
	   for (i=0;i<=Number;i++)
		{
		  WriteData(Attrib);
		}
           OverAutoWrite();

	}
//---------------------------------------------------------------------
//  clear the  screen  
//---------------------------------------------------------------------
ClrScreen()
	{
	  int i;
		 
	  AdressPointSet(0,0);
	  DataAutoWrite();
	  for (i=0;i<=1023;i++)
		{
		  WriteData(0);
		}
	  OverAutoWrite();
	  AdressPointSet(GRAPHIC_HOME_ADRESS%256,GRAPHIC_HOME_ADRESS/256);
	  DataAutoWrite();
	  for (i=0;i<=1023;i++)
		{
		  WriteData(0);
		}
	  OverAutoWrite();
	}









































⌨️ 快捷键说明

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