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

📄 lcd.h

📁 Program for ADC0808 with 4 bit LCD routine. It also includes Protus Debug file.
💻 H
字号:
#define LCDPORT P1
sbit _RS=LCDPORT^0;
//sbit _RW=LCDPORT^1;
sbit _E =LCDPORT^2;
sbit _D4 =LCDPORT^4;
sbit _D5 =LCDPORT^5;
sbit _D6 =LCDPORT^6;
sbit _D7 =LCDPORT^7;


bit  ___status=0;
#define lcd_delay 400

#define LINE_1 0x80
#define LINE_2 0xC0
#define LINE_3 0x94
#define LINE_4 0xD4

#define CLEAR_DISPLAY   0x01
#define CURSOR_HOME     0x02
#define DISPLAY_OFF		0x08
#define CURSOR_OFF      0x0C
#define CURSOR_ON       0x0D
#define CURSOR_BLINK_2  0x0E
#define CURSOR_BLINK_1  0x0F
//#define SHIFT_LEFT      0x18		 //Scroll display one character left (all lines)
//#define SHIFT_RIGHT     0x1C		//0X1E	//Scroll display one character right (all lines)
//#define CURSOR_LEFT     0x10		// Move cursor one character left
//#define CURSOR_RIGHT    0x14		// Move cursor one character right
//#define SHIFT_LEFT      0x18		//
//#define SHIFT_LEFT      0x18		//

//static unsigned char char_add,data_byte; 
//code unsigned char init_bytes[5] = {0x28,0x08,0x01,0x06,0x0c};


void delay(unsigned int j)
{
unsigned int i=0;
for(;i<j;i++);
}
void _lcd_init_write(unsigned char a)
{
_RS=0;
//_RW=0;
LCDPORT=a;
_E=1;
delay(lcd_delay);
_E=0;
}
void lcd_com(unsigned char a)
{
unsigned char temp;
if(___status){
	___status=0;
	goto ___next123321;
	}
_RS=0;
___next123321:
//_RW=0;
temp=a;
temp&=0xf0;
LCDPORT&=0x0f;
LCDPORT|=temp;
_E=1;
delay(lcd_delay);
_E=0;
temp=a<<4;
temp&=0xf0;
LCDPORT&=0x0f;
LCDPORT|=temp;
_E=1;
delay(lcd_delay);
_E=0;
}
void lcd_data(unsigned char a)
{
___status=1;
_RS=1;
lcd_com(a);
}
void lcd_init(void)
{
delay(lcd_delay);
_lcd_init_write(0x30);
delay(lcd_delay);
_lcd_init_write(0x30);
delay(lcd_delay);
_lcd_init_write(0x30);
delay(lcd_delay);
_lcd_init_write(0x20);
delay(lcd_delay);
lcd_com(0x28);
delay(lcd_delay);
lcd_com(4);
delay(lcd_delay);
lcd_com(0x85);
delay(lcd_delay);
lcd_com(6);
delay(lcd_delay);
lcd_com(1);
delay(lcd_delay);
}
void lcd_puts(char start_add,char *aaa)
{
unsigned int i=0;
lcd_com(start_add);
for(;aaa[i]!=0;i++)
	lcd_data(aaa[i]);
}
void Wrte_Variable(char abc)
{
lcd_data(abc+0x30);
}

⌨️ 快捷键说明

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