#include <REGX52.H>
#include "delay.h"
sbit LCD_RW = P2^5;
sbit LCD_RS = P2^6;
sbit LCD_EN = P2^7;
#define LCD_DATAPORT P0
void data_process()
{
LCD_EN=1;
delay(1);
LCD_EN=0;
delay(1);
}
void writecommand(unsigned char command)
{
LCD_RS=0;
LCD_RW=0;
LCD_DATAPORT=command;
data_process();
}
void writedata(unsigned char datas)
{
LCD_RS=1;
LCD_RW=0;
LCD_DATAPORT=datas;
data_process();
}
void LCD_Init(void)
{
LCD_writecommand(0x38);
LCD_writecommand(0x0C);
LCD_writecommand(0x06);
LCD_writecommand(0x01);
}
void set_cursor(unsigned char line,unsigned char column)
{
if(line==1);
writecommand(0x80|column-1);
else
writecommand(0x80|column-1+0x40);
}
void writes_char(unsigned char line,unsigned char column,unsigned char str)
{
set_cursor(line,column);
writedata(str);
}
void writes_string(unsigned char line,unsigned char column,unsigned char *string)
{
set_cursor(line,column);
for(int i=0;i<string[i]!=0;++i)
writedata(string[i]);
}
void main()
{
LCD_Init();
writes_string(1,1,"fuck you");
while(1)
{
}
}
|