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

📄 lcd_drv.c

📁 天然气报警器 采用51控制 可以控制2路开关
💻 C
字号:
/*========================================================================================
project    : PCF8576CT驱动4背极段码液晶显示器
Developer  : Laputa
Date	   : 07.4.12

===========================================================================================*/

#include "STC89C51RC_RD_PLUS.H" 
#include "VI2C_C51.h" 
#include "LCD_DRV.h "


//===================================================================================
//               定义真值表
uint8 code asc[] ={0x7B,0x60,0X5E,0X7C,0X65,0X3D,0X3F,0X70,0X7F,0X7D};
/*======================================================================================
/////////////////////////	延时  /////////////////////////////////////////////////////
======================================================================================*/
void Delay(unsigned int Delx)                       
 {                                                     
   unsigned int i=0;                                            
   while(i<Delx)                                          
     i++;                                                 
 } 

/*======================================================================================
//////////////////////	设定模式  /////////////////////////////////////////////////////
======================================================================================*/
void SetMode(uint8 device,uint8 work_mode)
{
   device=(device&DEVICE_LIMIT)|DEVICE_SELECT|COMMAND;
   ISendByte(PCF8576,device);	             //选择器件

   work_mode=work_mode|MODE;
   ISendByte(PCF8576,work_mode);	               //设定模式
}
/*======================================================================================
//////////////////////	闪烁设定 /////////////////////////////////////////////////////
======================================================================================*/

void SetBlink(uint8 device,uint8  blink_mode)
{
   device=(device&DEVICE_LIMIT)|DEVICE_SELECT|COMMAND;
   ISendByte(PCF8576,device);	             //选择器件
   blink_mode=blink_mode|BLINK;
   ISendByte(PCF8576,blink_mode);	         //设定模式
}

/*======================================================================================
//////////////////////	 显示数据 /////////////////////////////////////////////////////
======================================================================================*/
void Display(uint8 device,uint8 address,uint8 Data)
{
  device=(device&DEVICE_LIMIT)|DEVICE_SELECT|DATA;
  ISendByte(PCF8576,device);
  ISendStr(PCF8576,address,&Data,1); 
} 
/*======================================================================================
//////////////////////	 清屏 /////////////////////////////////////////////////////
======================================================================================*/
void ClearLCD(void)
{
 uint8 i;
 for (i=0;i<29;i+=2)
  Display(0x00,i,0x00);
}
/*======================================================================================
/////////////////////PCF8576 初始化/////////////////////////////////////////////////////
======================================================================================*/
void PCF8576Init(void)
{
 Delay(800);                                 //1/3 偏压,4 背极,禁止闪烁
 SetMode(0X00, 0X08);
 SetBlink(0X00,0X00);
 ClearLCD();
}

/*======================================================================================
//////////////////////	 显示0~9 /////////////////////////////////////////////////////
======================================================================================*/
void PutChar(uint8 ascii_code,uint8 address,uint8 col)
{
  if(col==0)Display(0x00,address,asc[(ascii_code-0x30)]);
  else	Display(0x00,address,asc[(ascii_code-0x30)]|COLON);
 }
/*====================================================================================================

 ---- |----------| ----							 真值表
 |  | |    3     | |  |
 |7 | |----------| | 1|
 |  |              |  |
 |  |              |  |
 |  |              |  |
 |--| |----------| |--|
	  |    5     |
	  |----------|
 |--|              |--|
 |  |              |  |
 |  |              |  |
 |6 |              | 2|
 |  |              |  |
 |--| |----------| |--|
      |    4     |
	  |----------|         .== 0

----------------------------------------------------------------------------------------------------
  1       2       3       4       5       6       7       8       9		  0

  0x03   0x5e    0x7c     0x65    0x3d    0x3f    0x70    0x7f    0x7d	 0x7b
----------------------------------------------------------------------------------------------------


------------------------------------------------------------
      _     _     _         上上月反总尖峰平谷		       |
	 |_|   |_|   |_|			5						   |
	 |_|   |_| 	 |_|									   |
	  1     2     3										   |			显示顺序
														   |
	  _	    _     _     _     _     _     _     _	       |
     |_|   |_|	 |_|   |_|   |_|   |_|   |_|   |_|		   |
	 |_|   |_|   |_|   |_|   |_|   |_|   |_|   |_|     	   |
							 			  				   |
	  0		13	  12	11	  9	    8	  7		6	       |
														   |
														   |
	  123 @ ==                                  KWH		   |
		10										 4		   |
------------------------------------------------------------


-------------------------------------------------------------------------------------------------------*/



⌨️ 快捷键说明

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