t6963c驅(qū)動(dòng)程序-驅(qū)動(dòng)代碼
{
OutPortCom3( (unsigned char)(StartAddr), (unsigned char)(StartAddr>>8), 0x24); //set address
for(j=0;jLineWidth;j++)
{
OutPortCom2( CBYTE[address + i*LineWidth+ j ], 0xc0);
}
StartAddr=StartAddr + LineChar;
}
}
///////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//圖形函數(shù),用于描點(diǎn)畫圖
//---------------------------------------------------------------------------
//在指定位置顯示一個(gè)點(diǎn)
//如果顯示屏超過了256*256,請修改這個(gè)函數(shù) PointX,PointY的類型
//Mode 1:顯示 0:清除該點(diǎn)
Pixel(unsigned char PointX,unsigned char PointY, bit Mode)
{
unsigned int StartAddr=0;
unsigned char dat;
StartAddr=PointX*LineChar + PointY/8;
dat=0xf0+7-PointY%8;
if(Mode) dat=dat 0x08;
OutPortCom3( (unsigned char)(StartAddr),(unsigned char)(StartAddr>>8),0x24 ); //設(shè)置該點(diǎn)所在單元地址
OutPortCom1(dat);
}
//-------------------------------------------------------------------------------
//劃線函數(shù)
void Line( unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, bit Mode)
{
unsigned char x,y;
double k,b;
if( abs(y1-y2) = abs(x1-x2) ) // k =1
{
k=(float)(y2-y1) / (float)(x2-x1) ;
b=y1-k*x1;
if( x1 = x2 )
{
for(x=x1;x=x2;x++)
{
y=k*x+b;
Pixel(x, y, Mode);
}
}
else
{
for(x=x2;x=x1;x++)
{ y=k*x+b;
Pixel(x, y, Mode);
}
}
}
else // abs(y1-y2) > abs(x1-x2) K >1
{
k=(float)(x2-x1) / (float)(y2-y1) ;
b=x1-k*y1;
if( y1 = y2 )
{
for(y=y1;y=y2;y++)
{ x=k*y+b;
Pixel( x , y,Mode );
}
}
else
{
for(y=y2;y=y1;y++)
{ x=k*y+b;
Pixel( x , y,Mode );
}
}
}
}
/*--------------------------------------------------------------------------------------*/
void ClearScreen()
{
unsigned int i;
///////// 清顯示 RAM 區(qū) 0000h--2000h (8k)
OutPortCom3(0x00,0x00,0x24); //設(shè)置指針地址0000H
OutPortCom1(0xb0); //設(shè)置自動(dòng)寫狀態(tài)
for(i=0x00;i0x2000;i++) OutPortData(0x00); // data=0;
OutPortCom1(0xb2); // 自動(dòng)寫結(jié)束
}
//初始化LCD
//需要手動(dòng)設(shè)置
void InitLCD()
{
OutPortCom3( 0x00,0x00,0x42 ); //設(shè)置圖形顯示區(qū)域首地址GraphAddr
OutPortCom3( 30,0x00,0x43 ); //設(shè)置圖形顯示區(qū)域?qū)挾?: LineChar
// OutPortCom3( 0x00,0x00,0x42 ); //設(shè)置圖形顯示區(qū)域首地址GraphAddr
// OutPortCom3( 0x10,0x00,0x43); //設(shè)置圖形顯示區(qū)域?qū)挾?10H
OutPortCom1(0xa7); //設(shè)置光標(biāo)形狀 cursor size 8x8
OutPortCom1(0x80); //設(shè)置顯示方式: CGROM方式 文本圖形 "或"
OutPortCom1(0x98); //設(shè)置顯示開關(guān): 1001 1100 圖形
ClearScreen();
}
T6963C 引腳說明
T6963C 的QFD 封裝共有67 個(gè)引腳,各引腳說明如下:
1、D0-D7:T6963C 與MPU 接口的數(shù)據(jù)總線,三態(tài)。
c語言相關(guān)文章:c語言教程
評論