?? lcd_init._h
字號:
/*
LCD12864液晶驅(qū)動模塊
*/
/*
PG0---RS---4
PG1---R/W--5
PG2---EN---6
PA0---DB0---7
PA1---DB1---8
PA2---DB2---9
PA3---DB3---10
PA4---DB4---11
PA5---DB5---12
PA6---DB6---13
PA7---DB7---14
*/
#include <iom128v.h>
#include <macros.h>
/*命令或是數(shù)據(jù)選擇*/
/*RS = 0命令,RS = 1數(shù)據(jù)*/
#define RS_CLR PORTG&=~(1<<0)
#define RS_SET PORTG|=(1<<0)
/*讀取或?qū)懭脒x擇*/
/*RW = 1讀,RW = 0寫*/
#define RW_CLR PORTG&=~(1<<1)
#define RW_SET PORTG|=(1<<1)
/*讀寫使能信號*/
/*下降沿有效*/
#define EN_CLR PORTG&=~(1<<2)
#define EN_SET PORTG|=(1<<2)
/*芯片復位腳*/
/*高電平復位
#define RST_CLR PORTD&=~(1<<PD7)
#define RST_SET PORTD|=(1<<PD7)*/
//延時函數(shù)
void delay (unsigned int n)
{
while(n--);
}
void chk_busy(void)
{
PORTA=0XFF;
RS_CLR;
RW_SET;
DDRA=0X00;
EN_SET;
while(PINA&0X80);
EN_CLR;
DDRA=0XFF;
}
//顯示屏命令寫入函數(shù)
void LCD_write_code(unsigned char code)
{
chk_busy();
RS_CLR;
RW_CLR;
PORTA=code;
EN_SET;
delay(100);
EN_CLR;
}
//顯示屏數(shù)據(jù)顯寫入函數(shù)
void LCD_write_data(unsigned char data)
{
chk_busy();
RS_SET;
RW_CLR;
PORTA=data;
EN_SET;
delay(100);
EN_CLR;
}
/*單個字符輸入函數(shù);position--顯示位置,data--顯示內(nèi)容*/
void disp_char(unsigned char position,unsigned char asii)
{
LCD_write_code(position);
LCD_write_data(asii);
}
/*一串字符輸入函數(shù)
void disp_char_str(unsigned char position,unsigned char *str)
{
LCD_write_code(position);
while(*str!=0) //含義???
{
LCD_write_data(*str);
str++;
}
}*/
/*漢字輸入*/
void disp_word(unsigned char position,unsigned char *word)
{
LCD_write_code(position);//要顯示的位置
while(*word!=0)
{
LCD_write_data(*word);
word++;
}
}
//------------------------------------------------------------------------------
//函數(shù)名稱:disp_number10()
//功能:數(shù)據(jù)的十進制顯示,7顯示07,12顯示12
//------------------------------------------------------------------------------
void disp_number10(unsigned char position,unsigned char num)
{
unsigned char num_h, num_l;
LCD_write_code(position);
if(num>=10)
{
num_h=(num/10);
num_l=(num%10);
LCD_write_data(num_h+0x30);
LCD_write_data(num_l+0x30);
}
else
{
LCD_write_data(0x30);
LCD_write_data(num+0x30);
}
}
//------------------------------------------------------------------------------
//函數(shù)名稱:disp_number16()
//功能:數(shù)據(jù)的16進制顯示,
//------------------------------------------------------------------------------
void disp_number16(unsigned char position,unsigned char num)
{
unsigned char num_h,num_l;
//LCD_write_code(position);
if(num>=10)
{
num_h=(num/16);
num_l=(num%16);
LCD_write_data(num_h+0x30);
LCD_write_data(num_l+0x30);
}
else
{
LCD_write_data(0x30);
LCD_write_data(num+0x30);
}
}
//顯示屏初始化
void disp_init(void)
{
DDRA=0XFF;
//DDRD=(1<<PD4)|(1<<PD5)|(1<<PD6)|(1<<PD7);
DDRG=0XFF;
LCD_write_code(0x30);//功能設定/*30---基本指令動作
LCD_write_code(0x01);//清屏,地址指針指向00H
LCD_write_code(0x06);//光標的移動方向
LCD_write_code(0x0c);//光標反白顯示--0x0f/*開顯示,關游標
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -