?? lm3033_keyboard.c
字號:
//send 4 "0"
for(i = 0;i < 4;i ++) {
LCD_SID_CLR;
LCD_SCLK_SET;
LCD_SCLK_CLR;
}
//send data low 4 bits
for(i = 3;i >= 0;i --) {
if(data&(1<<i)) //current bit is "1"
LCD_SID_SET;
else //current bit is "0"
LCD_SID_CLR;
LCD_SCLK_SET;
LCD_SCLK_CLR;
}
//send 4 "0"
for(i = 0;i < 4;i ++) {
LCD_SID_CLR;
LCD_SCLK_SET;
LCD_SCLK_CLR;
}
}
/************************************************************************************************
Function: LCD_Coordinate
Description:set the display address
Calls: - LCD_WriteChar
Input: - U8 x(line select 0~3),U8 y(column select 0~7);
Output: - None
Return: - None
**************************************************************************************************/
void LCD_Coordinate(U8 x, U8 y)
{
U8 addr;
//find address
switch(x)
{
case 0:
addr = 0x80 + y; //line 0;column y
break;
case 1:
addr = 0x90 + y; //line 1;column y
break;
case 2:
addr = 0x88 + y; //line 2;column y
break;
case 3:
addr = 0x98 + y; //line 3;column y
break;
}
//setting command
LCD_WriteChar(0,addr);
}
/************************************************************************************************
Function: LCD_write_string
Description:write a byte to the lcd , command or data
Calls: - LCD_WriteChar/LCD_Coordinate
Input: - U8 x(line select 0~3),U8 y(column select 0~7); U8 *str string
Output: - None
Return: - None
**************************************************************************************************/
void LCD_write_string(U8 x,U8 y,U8 *str)
{
//set adress
LCD_Coordinate(x,y);
delay_Nms(1);
while (*str!='\0')
{
LCD_WriteChar(1,*str);
delay_N100us(1);////////// delay_Nms(1);
str++;
}
}
/************************************************************************************************
Function: Number_Output
Description:output a 16 bits number to the lcd ,address decided by the coordinate user setted
Calls: - LCD_WriteChar/LCD_Coordinate
Input: - U8 x(line select 0~3),U8 y(column select 0~7); U16 number number to be display
Output: - None
Return: - None
**************************************************************************************************/
void Number_Output(U16 number,U8 x,U8 y) {
U16 bit_current,temp,temp_count,count;
U16 bit_less;
temp = number;
count = 1;
do{
bit_current = temp%10; //get current lowest bit
bit_less = temp/10; //get bit less
//output current bit number
LCD_Coordinate(x,y);
for(temp_count= count;temp_count>0;temp_count--)
LCD_WriteChar(1,0x20);
LCD_WriteChar(1,bit_current+0x30);
y--;
count++;
//LCD_Coordinate(x,y);
//LCD_WriteChar(1,0x20);
temp=bit_less;
}while(bit_less); //while bit less is not equaled to 0,then recycle
}
/************************************************************************************************
Function: ScreenClean
Description: write 0x00 to the whole RAM for blank display
Calls: - LCD_WriteChar
Input: - None
Output: - None
Return: - None
**************************************************************************************************/
void ScreenClean(void)
{
U8 TempData = 0x00;
U8 i, j;
for(i=0;i<0x20;i++)
{
LCD_WriteChar(0,0x34);// 8bit I/F, extend command
LCD_WriteChar(0,0x80|i);// Y address
LCD_WriteChar(0,0x80); // X address
LCD_WriteChar(0,0x36); // 8bit I/F, basic command, graphic on
for(j=0;j<0x10;j++)
{
LCD_WriteChar(1,TempData);
LCD_WriteChar(1,TempData);
}
}
}
/************************************************************************************************
Function: WriteGraphicScreen
Description: write a graphic to screen
Calls: - LCD_WriteChar
Input: - U8 lines(graphic data matrix lines),
U8 column_bytes(graphic bytes each line),
U8 line_addr(display starting address line(0~64)),
U8 column_addr(0~7),
U8 *GDData(64*16*8 dots,64*16 = 1024bytes)
Output: - graphic diplay
Return: - None
**************************************************************************************************/
void WriteGraphicScreen(U8 lines,U8 column_bytes,U8 line_addr,U8 column_addr,U8 *GDData)
{
U8 TempData;
U8 i, j;
U8 addr_x,addr_y;
for(i=line_addr;i<lines+line_addr;i++) //
{
//set address
if(i<32){
addr_y = 0x80+i;
addr_x = 0x80+column_addr;
}
else {
addr_y = 0x80+(i - 32);
addr_x = 0x80+column_addr+0x08;
}
LCD_WriteChar(0,0x34);// 8bit I/F, extend command
LCD_WriteChar(0,addr_y);// Y address
LCD_WriteChar(0,addr_x); // X address
LCD_WriteChar(0,0x30); // 8bit I/F, basic command,// graphic on
for(j=0;j<column_bytes/2;j++) //10
{
TempData=(*(GDData+((i-line_addr)*column_bytes)+(j*2)+0)); // send high-byte
LCD_WriteChar(1,TempData);
// delay_Nms(1); ////////////////////////////a must
TempData=(*(GDData+((i-line_addr)*column_bytes)+(j*2)+1)); // send low-byte
LCD_WriteChar(1,TempData);
// delay_Nms(1); ////////////////////////////a must
}
}
LCD_WriteChar(0,0x36); // 8bit I/F, basic command graphic on
}
/************************************************************************************************
Function: TeamInfor
Description: TeamInfor
Calls: - LCD_WriteChar,LCD_write_string ,delay_Nms ,WriteGraphicScreen ,ShowMenu
Input: - None
Output: - None
Return: - None
**************************************************************************************************/
void TeamInfor(void){
//
LCD_Init();
delay_Nms(10);
ScreenClean();
delay_Nms(10); ////////////////////////////a must
WriteGraphicScreen(64,8,0,0,glogo_szu);
//
LCD_WriteChar(0,0x30); // 8bit I/F, basic command, graphic off
LCD_WriteChar(0,0x0c); // display on
LCD_write_string(0,4,"深圳大學(xué)");
LCD_write_string(1,4,"信息工程");
LCD_write_string(2,4,"荔園晨風(fēng)");
//
WaitForKey();
//
LCD_WriteChar(0,0x30); // 8bit I/F, basic command, graphic off
LCD_WriteChar(0,0x0c); // display on
LCD_WriteChar(0,0x01); // clr text screen
LCD_write_string(0,0,"指導(dǎo)老師: 錢恭斌");
LCD_write_string(1,0,"參賽隊員: 周東泳");
LCD_write_string(2,0," 張戰(zhàn)斌");
LCD_write_string(3,0," 李真棠");
WaitForKey();
LCD_WriteChar(0,0x01); // clr text screen
ShowMenu();
}
/************************************************************************************************
Function: LCD_Init
Description: LCD initial
Calls: - LCD_WriteChar, clrReg8Bits ,delay_Nms
Input: - None
Output: - None
Return: - None
**************************************************************************************************/
void LCD_Init(void)
{
//initial port regesiter
LCD_DATA = 0x00;
LCD_DATA_OUT; //port data regesiter out put
clrReg8Bits(PEAR, 140);
clrReg8Bits(PORTE,140); //io data set 0
setReg8Bits(PUCR, 145); //regester pull up
setReg8Bits(DDRE, 140); //command out
//initial signals
LCD_SCLK_CLR;
LCD_SID_CLR;
LCD_CS_CLR;
delay_Nms(1);
//commands
//ScreenClean();
//
LCD_WriteChar(0,0x30); // 8bit I/F, basic command, graphic off
delay_Nms(1); ////////////////////////////a must
LCD_WriteChar(0,0x0c); // display on
delay_Nms(1); ////////////////////////////a must
LCD_WriteChar(0,0x06); // cursor right shift
delay_Nms(1); ////////////////////////////a must
LCD_WriteChar(0,0x01); // clr text screen
delay_Nms(1); ////////////////////////////a must
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -