|
#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; //EN 低跳變?
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原型在哪 里?
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);//邏輯順序?qū)幔?/font>
else
writecommand(0x80|column-1+0x40);//邏輯順序?qū)幔?/font>
}
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!=0;++i)
writedata(string);
}
void main()
{
LCD_Init();
writes_string(1,1,"fuck you");
while(1)
{
}
}
|
|