?? lcd.c
字號(hào):
//******************************************************************************
//ZhaoZhendong
//Lierda, Inc
//July 2004
//Built with IAR Embedded Workbench Version: 3.20A
//******************************************************************************
#include "LCD_DEFINE.H"
void lcd_init(void)
{
LCD_DATA_OUT = 0x00;
}
void write_command(unsigned char command)
{
LCD_CS1 =1 ;
LCD_CS2 =1 ;
LCD_RW = 0 ;
LCD_DI = 0 ;
LCD_DATA_OUT = command;
LCD_EN = 1 ;
LCD_EN = 0 ;
}
void write_data( unsigned char LCDdata, unsigned char CS1, unsigned char CS2 )
{
if(CS1)
LCD_CS1 =1 ;
else
LCD_CS1 =0;
if(CS2)
LCD_CS2 =1;
else
LCD_CS2 =0;
LCD_DI = 1;
LCD_RW = 0;
LCD_DATA_OUT = LCDdata;
LCD_EN = 1;
LCD_EN = 0;
}
void clear_lcd(void)
{
unsigned char i,j;
for(i=0;i<8;i++)
{
write_command(SET_X|i);
write_command(SET_Y);
for(j=0;j<128;j++)
{
if(j<=63) write_data(0,1,0);
else write_data(0,0,1);
// _NOP_();
}
}
}
//*chr 顯示數(shù)據(jù)的地址,nRow 在顯示屏上第幾行,nCol 在顯示屏上第幾列
//highth 字體的高度,wideth 字體的寬度
//128*64有8行,128列
void display( unsigned char *chr, unsigned char nRow, unsigned char nCol,
unsigned char highth,unsigned char wideth )
{
unsigned char i,tmpCol,tmpRow,h,m;
unsigned int j;
tmpRow = nRow;
m=0;
j=0; //注意此變量的用法
for(h=0;h<highth;h=h+8)
{
write_command(SET_X|tmpRow);
tmpCol=nCol;
for(i=0;i<wideth;i++)
{
if(tmpCol<64)
{
write_command(SET_Y|tmpCol);
write_data(chr[i+j],1,0);}
else
{
write_command(SET_Y|(tmpCol-64));
write_data(chr[i+j],0,1);
}
tmpCol++;
}
m++;
j=m*wideth;
tmpRow++;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -