📄 lcd.c
字号:
/*
###############################################################################
File Name : LCD.C
Version : 1.0
Programmer(s) : Unknown
Created : Unknown
Description : LCD Basic Function Implement File
This source file is open, so it's easy to look for through Internet.
Do not need to controll LCD.
Modified History
Modified : 2002/03/13
Description :
###############################################################################
*/
/*
###############################################################################
Include Part
###############################################################################
*/
#include <lcd.h>
/*
###############################################################################
Define Part
###############################################################################
*/
#define BUSY 0x80
/*
###############################################################################
Grobal Variable Definition Part
###############################################################################
*/
/*
###############################################################################
Local Variable Definition Part
###############################################################################
*/
/*
###############################################################################
Function Implementation Part
###############################################################################
*/
/*
Description : Check to be ready LCD.
Argument :
Return Value : If it's ready ,then '1',else then '-1'.
Note : If LCD Device is not insert actually,then return '-1'.
*/
char LcdReady(void)
{
unsigned char flag;
while( (flag=LcdCommandR) & BUSY)
{
if(flag == 0xFF) return -1;
}
return 1;
}
/*
Description : Clear LCD.
Argument :
Return Value :
Note :
*/
void ClrScr(void)
{
LcdReady();
LcdCommandW = 0x01;
}
/*
Description : Initialize LCD.
Argument :
Return Value : If initialization is O.K, then return '1', else then return '-1'.
Note
*/
char InitLcd(void)
{
if(-1 ==LcdReady()) return -1;
LcdCommandW = 0x38;
LcdReady();
LcdCommandW = 0x0C;
ClrScr();
GotoXY(0,0);
}
/*
Description : Move Cursor to X Column, Y Row.
Argument : x - Column to move(INPUT),
y - Row to move(INPUT),
Return Value :
Note : LCD to be offered by WIZnet is '2*16' Dimension, so Row(Argument y) is not above 1.
*/
void GotoXY(unsigned char x, unsigned char y)
{
LcdReady();
switch(y){
case 0 : LcdCommandW = 0x80 + x; break;
case 1 : LcdCommandW = 0xC0 + x; break;
case 2 : LcdCommandW = 0x94 + x; break;
case 3 : LcdCommandW = 0xD4 + x; break;
}
}
/*
Description : Output character string in current Cursor.
Argument : str - Character to be output in LCD. (INPUT)
Return Value : Character string's Pointer to be output
Note :
*/
char *Puts(char* str)
{
unsigned char i;
for (i=0; str[i] != '\0'; i++){
LcdReady();
LcdDataW = str[i];
}
return str;
}
/*
Description : Output 1 character in current Cursor.
Argument : str - Character to be output in LCD. (INPUT)
Return Value :
Note :
*/
void Putch(char ch)
{
LcdReady();
LcdDataW = ch;
}
/*
###############################################################################
Unused Function Implementation Part
###############################################################################
*/
#ifndef __LCD_UNUSED
/*
Description : Decide Cursor type.
Argument : type - Cursor type(INPUT)
Return Value :
Note :
*/
void SetCursorType(unsigned char type)
{
LcdReady();
switch(type)
{
//No Cursor
case 0 : LcdCommandW = 0x0C; break;
// Normal Cursor
case 1 : LcdCommandW = 0x0E; break;
// No Cursor | Blink
case 2 : LcdCommandW = 0x0D; break;
// Normal Cursor | Blink
case 3 : LcdCommandW = 0x0F; break;
}
/*
Description : Shift to Left and Right current Cursor.
Argument : dir - Decide direction to be Shift.(INPUT) dir !=0 -> Right Shift, dir == 0 -> Left Shift
Return Value :
Note :
*/
void ShiftCursor(unsigned char dir)
{
LcdReady();
LcdCommandW = (dir ? 0x14: 0x10);
}
/*
Description : Move Cursor first Column.
Argument :
Return Value :
Note :
*/
void HomeCursor(void)
{
LcdReady();
LcdCommandW = 2;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -