?? 19264lcdtest.c
字號:
/*------------------------------------------------------------------------------------------
[文件名] 19264lcdtest.c
[功能] 192X64驅動程序
[版本] 1.0
===========================================================================================*/
#include "absacc.h"
#include "intrins.h"
//自定義庫 在"C:\comp51\UserLib\"文件夾中
#include ".\inc\ASCII816.h" //標準ASCII庫
#include ".\inc\HZTable.h" //漢字點陣庫(自做)
#include ".\inc\Menu.h" //菜單庫(自做)
// LCD128*64 數據線
#define LCD19264DataPort P0
// LCD192*64 I/O 信號管腳
sbit p_csa=P3^3;
sbit p_csb=P3^4;
sbit p_lt=p3^5;
#define set_p_lt() (p_lt=1) //背光開
#define LCD_DAT_W_ADDR 0xA000H // 寫數據地址
#define LCD_DAT_R_ADDR 0xB000H //讀數據地址
#define LCD_CMD_W_ADDR 0x8000H //寫指令地址
#define LCD_STA_R_ADDR 0x9000H //讀狀態地址
/*----------------------------------------------------------------------------------------------------*/
/* ****函數列表****
//開關顯示
void SetOnOff(unsigned char onoff)
//選擇屏幕
//screen: 0-全屏,1-左屏,2-中,3-右
void SelectScreen(unsigned char screen)
//清屏
//screen: 0-全屏,1-左屏,2-中,3-右
void ClearScreen(unsigned char screen)
//全黑
//screen: 0-全屏,1-左屏,2-中,3-右
void BlackScreen(unsigned char screen)
//顯示8*8點陣
//旋轉90度:字模被豎著切分
//lin:行(0-7), column: 列(0-23)
//address : 字模區首地址
void Show88(unsigned char lin,unsigned char column,unsigned int address)
//顯示8*16字符
//旋轉90度:字模被豎著切分
//lin:行(0-3), column: 列(0-23)
//character:字符代碼(標準ASCII碼)
void ShowChar(unsigned char lin,unsigned char column,unsigned char character)
//顯示一個漢字
//旋轉90度:字模被豎著切分
//lin:行(0-3), column: 列(0-11)
//hzcode: 漢字代碼(自定義的)
void ShowHZ(unsigned char lin,unsigned char column,unsigned int hzcode)
//顯示一屏漢字
//pageheadaddr:此屏漢字代碼地址區首地址
void ShowPage(unsigned int pageheadaddr)
//反顯一個8*8字塊
//lin:行(0-3), column: 列(0-7)
void ReverseShow88(unsigned char lin,unsigned char column)
//反顯一個字符
//lin:行(0-4), column: 列(0-15)
void ReverseShowChar(unsigned char lin,unsigned char column)
//反顯一個漢字
//lin:行(0-3), column: 列(0-7)
ReverseShowHZ(unsigned char lin,unsigned char column)
//反顯一行漢字
//lin:行
ReverseShow(unsigned char lin)
//初始化LCD
void InitLCD()
****函數列表結束**** */
/*----------------------------------------------------------------------------------------------------*/
/*--基本函數源程序------------------------------------------------------------------------------------*/
//延時
void Lcd19264delay(Byte count)
{
Timer40ms=count;
while(Timer40ms!=0);
}
void TimerlISR_40ms(void)
{
TL1=CLOCK_40MS&0xff;
TH1=CLOCK_40MS>>8;
TF1=0;
if(Timer40ms!=0)
Timer40ms--;
}
/*----------------------------------------------------------------------------------------------------*/
//狀態檢查
void CheckState()
{
unsigned char dat;
P2=HIBYTE(LCD_STA_R_ADDR);
do{
dat=LCD19264DataPort;
dat=0x90 & dat; //僅當第4,7位為0時才可操作
}while(!(dat==0x00));
}
/*----------------------------------------------------------------------------------------------------*/
//寫顯示數據
//dat:顯示數據
void WriteByte(unsigned char dat)
{
CheckState();
P2=HIBYTE(LCD_DAT_W_ADDR);
LCD19264DataPort=dat;
}
/*-----------------------------------------------------------------------------------------------------*/
//向LCD發送命令
//command :命令
SendCommandToLCD(unsigned char command)
{
CheckState();
P2=HIBYTE(LCD_CMD_W_ADDR);
LCD19264DataPort=command;
}
/*----------------------------------------------------------------------------------------------------*/
//設定行地址(頁)--X 0-7
void SetLine(unsigned char line)
{
line=line & 0x07; // 0<=line<=7 后三位
line=line|0xb8; //1011 1xxx
SendCommandToLCD(line);
}
//設定列地址--Y 0-63
void SetColumn(unsigned char column)
{
column=column &0x3f; // 0=<column<=63
column=column | 0x40; //01xx xxxx
SendCommandToLCD(column);
}
//設定顯示開始行--XX
void SetStartLine(unsigned char startline) //0--63
{
startline=startline & 0x07;
startline=startline|0xc0; //1100 0000
SendCommandToLCD(startline);
}
//開關顯示
void SetOnOff(unsigned char onoff)
{
onoff=0x3e | onoff; //0011 111x
SendCommandToLCD(onoff);
}
/*---------------------------------------------------------------------------------------------------*/
//選擇屏幕
//screen: 0-全屏,1-左屏,2-中屏,3-右屏
void SelectScreen(unsigned char screen)
{
switch(screen)
{ case 0: //全屏
//?
break;
case 1: //左屏
p_csa=0;p_csb=0;
break;
case 2://中屏
p_csa=0;p_csb=1;
break;
case 3://右屏
p_csa=1;p_csb=0;
}
}
/*---------------------------------------------------------------------------------------------------*/
//清屏
//screen: 0-全屏,1-左屏,2-中,3-右
void ClearScreen(unsigned char screen)
{ unsigned char i,j;
SelectScreen(screen);
for(i=0;i<8;i++)
{ SetLine(i);
for(j=0;j<64;j++)
{
WriteByte(0x00);
}
}
}
/*---------------------------------------------------------------------------------------------------*/
//全黑
//screen: 0-全屏,1-左屏,2-中,3-右
void BlackScreen(unsigned char screen)
{ unsigned char i,j;
SelectScreen(screen);
for(i=0;i<8;i++)
{ SetLine(i);
for(j=0;j<64;j++)
{
WriteByte(0xff);
}
}
}
/*---------------------------------------------------------------------------------------------------*/
//黑白色塊測試
void BlockLcd(unsigned char ccreen)
{unsigned char i,j,n;
SelectScreen(screen);
for(i=0,i<8;i++)
{unsigned char a;
if(i%2)
{for(a=0,a=3,a++)
{
for(j=2*a*8,j=2*a*8+7;j++)
WriteByte(0x00);
for(j=(2*a+1)*8,j=(2*a+1)*8+1;j++)
WriteByte(0xff);
}
}
else
{for(a=0,a=3,a++)
{
for(j=2*a*8,j=2*a*8+7;j++)
WriteByte(0xff);
for(j=(2*a+1)*8,j=(2*a+1)*8+1;j++)
WriteByte(0x00);
}
}
}
}
/*--------------------------------------------------------------------------------------------------*/
//顯示8*8點陣
//旋轉90度:字模被豎著切分
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -