?? main.c
字號:
}
Linexy( MAIN_METHOD*64,49,MAIN_METHOD*64+63,49,0,1);
Linexy( MAIN_METHOD*64,49,MAIN_METHOD*64,51+NO_FANGFA_COMMANDS*16,0,1);
Linexy( MAIN_METHOD*64+63,49,MAIN_METHOD*64+63,51+NO_FANGFA_COMMANDS*16,0,1);
Linexy( MAIN_METHOD*64,51+NO_FANGFA_COMMANDS*16,MAIN_METHOD*64+63,51+NO_FANGFA_COMMANDS*16,0,1);
}
if ( current_command->parent == (COMMAND*)&main_menu[MAIN_FUNCTION])
{
WriteCommand( 0x59 ); // 寫入指令DISP ON/OFF代碼,后續參數:
WriteData( 0x44 ); // 00 00 01 00顯示1區開顯示,其余層關閉
for(i=0;i<NO_GONGNENG_COMMANDS;i++)
{
if(current_command->ID==i)
{
fb=1;
}
else
{
fb=0;
}
dprintf
(MAIN_FUNCTION*8,51+16*i,0,fb,gongneng_menu[i].name);
}
Linexy( MAIN_FUNCTION*64,49,MAIN_FUNCTION*64+63,49,0,1);
Linexy( MAIN_FUNCTION*64,49,MAIN_FUNCTION*64,51+NO_GONGNENG_COMMANDS*16,0,1);
Linexy( MAIN_FUNCTION*64+63,49,MAIN_FUNCTION*64+63,51+NO_GONGNENG_COMMANDS*16,0,1);
Linexy( MAIN_FUNCTION*64,51+NO_GONGNENG_COMMANDS*16,MAIN_FUNCTION*64+63,51+NO_GONGNENG_COMMANDS*16,0,1);
}
if ( current_command->parent == (COMMAND*)&main_menu[MAIN_PPL])
{
WriteCommand( 0x59 ); // 寫入指令DISP ON/OFF代碼,后續參數:
WriteData( 0x44 ); // 00 00 01 00顯示1區開顯示,其余層關閉
for(i=0;i<NO_PLL_COMMANDS;i++)
{
if(current_command->ID==i)
{
fb=1;
}
else
{
fb=0;
}
dprintf(MAIN_PPL*8,51+16*i,0,fb,pll_menu[i].name);
}
Linexy( MAIN_PPL*64,49,MAIN_PPL*64+63,49,0,1);
Linexy( MAIN_PPL*64,49,MAIN_PPL*64,51+NO_PLL_COMMANDS*16,0,1);
Linexy( MAIN_PPL*64+63,49,MAIN_PPL*64+63,51+NO_PLL_COMMANDS*16,0,1);
Linexy( MAIN_PPL*64,51+NO_PLL_COMMANDS*16,MAIN_PPL*64+63,51+NO_PLL_COMMANDS*16,0,1);
}
if ( current_command->parent == (COMMAND*)&main_menu[MAIN_HELP])
{
WriteCommand( 0x59 ); // 寫入指令DISP ON/OFF代碼,后續參數:
WriteData( 0x44 ); // 00 00 01 00顯示1區開顯示,其余層關閉
for(i=0;i<NO_HELP_COMMANDS;i++)
{
if(current_command->ID==i)
{
fb=1;
}
else
{
fb=0;
}
dprintf(MAIN_HELP*8,51+16*i,0,fb,help_menu[i].name);
}
Linexy( MAIN_HELP*64,49,MAIN_HELP*64+63,49,0,1);
Linexy( MAIN_HELP*64,49,MAIN_HELP*64,51+NO_HELP_COMMANDS*16,0,1);
Linexy( MAIN_HELP*64+63,49,MAIN_HELP*64+63,51+NO_HELP_COMMANDS*16,0,1);
Linexy( MAIN_HELP*64,51+NO_HELP_COMMANDS*16,MAIN_HELP*64+63,51+NO_HELP_COMMANDS*16,0,1);
}
}
void set(void)
{
current_command=&set_menu[SET_DDJ]; // BlockClr(0,50,40,170);
return;
}
void method(void)
{
current_command=&fangfa_menu[FANGFA_FANGFA1]; // BlockClr(0,50,40,170);
return;
}
void function(void)
{
current_command=&gongneng_menu[GONGNENG_analyse];// BlockClr(0,50,40,170);
return;
}
void pll(void)
{
current_command=&pll_menu[PLL_PLL1]; // BlockClr(0,50,40,170);
return;
}
void help(void)
{
current_command=&help_menu[HELP_HELP1]; // BlockClr(0,50,40,170);
return;
}
void help2(void)
{
}
void help1(void)
{
}
void pll3(void)
{
}
void pll2(void)
{
}
void pll1(void)
{
}
//-------------------------------------------
// 函數: void analyse(void)
//-------------------------------------------
void analyse(void)
{
}
//--------------------------------------------
//函數: void gongneng2(void)
//-------------------------------------------
void gongneng2(void)
{
}
//---------------------------------------------
// 函數: void gongneng3(void)
//--------------------------------------------
void gongneng3(void)
{
}
//---------------------------------------------
// 函數: void gongneng4(void)
//---------------------------------------------
void gongneng4(void)
{
}
void gongneng5(void)
{
}
void fang1(void)
{
}
void fang2(void)
{
}
void fang3(void)
{
}
void fang4(void)
{
}
void fang5(void)
{
}
void shezi(void)
{
}
void mainfangfa(void)
{
}
void biaoyang(void)
{
}
void brj(void)
{
}
//------------------------------------------
// 函數: void ddj(void)
//------------------------------------------
void ddj(void)
{
}
void clockset(void)
{
}
void Linexy(Uint x0,Uchar y0,Uint xt,Uchar yt,Uchar att,Uchar att1)
{
Uint t;
int xerr=0,yerr=0,delta_x,delta_y,distance;
int incx,incy;
Uint row,col;
delta_x = xt-x0; //計算坐標增量
delta_y = yt-y0;
col = x0;
row = y0;
if(delta_x>0) incx=1; //設置單步方向
else
{
if( delta_x==0 ) incx=0; //垂
直線
else {incx=-1;delta_x=-delta_x;}
}
if(delta_y>0) incy=1;
else
{
if( delta_y==0 ) incy=0; //水平線
else {incy=-1;delta_y=-delta_y;}
}
if( delta_x > delta_y ) distance=delta_x; //選取基本增量坐標軸
else distance=delta_y;
for( t=0;t <= distance+1; t++ )
{
//畫線輸出
Point((Uint)col,row,att,att1);
//畫點
xerr += delta_x ;
yerr += delta_y ;
if( xerr > distance )
{
xerr-=distance;
col+=incx;
}
if( yerr > distance )
{
yerr-=distance;
row+=incy;
}
}
}
//-----------------------------------------
// 寫指令代碼子程序pr1
//-----------------------------------------
void WriteCommand( Uchar CommandByte ) {
LcmCmdPort = CommandByte;
}
//------------------------------------------
// 寫參數及顯示數據子程序
//------------------------------------------
void WriteData( Uchar dataW ) {
LcmWdataPort = dataW;
}
//-------------------------------------------
// 讀參數及顯示數據子程序
//-------------------------------------------
Uchar ReadDataLcm( void )
{
return LcmRdataPort;
}
//--------------------------------------------
// 初始化子程序
//--------------------------------------------
void LcmInition( void ) {
Uchar i;
WriteCommand( SystemSet ); // 系統參數設置
for (i=0;i<8;i++) {
WriteData( ParaSysTable8[i] ); //
}
WriteCommand( Scroll ); //設定顯示區域起始地址
for (i=0;i<10;i++) {
WriteData( ParaScrTableA[i] );
}
WriteCommand( HdotScr ); // 寫入點位移指令代碼
WriteData( 0 ); // 寫入P1參數
WriteCommand( Ovlay ); // 顯示合成方式設置
WriteData( 0x4 ); //
//0000 0100 顯示一區圖形,三區文本屬性,二重"或"合成
WriteCommand( DispOn ); // 寫入指令代碼
WriteData( 0x54 ); // 顯示 1~4 區開顯示,光標關顯示
}
//-------------------------------------------------
//漢字寫入子程序(圖形方式)。每次調用輸出一個漢字
//支持圖形方式使用,完成漢字點陣碼的輸出。
//攜入參數: Ox,Oy....寫入顯示的左上角坐標,Ox是以字節單位,Oy以行掃描線單位
//Ptr......漢字碼,庫內的排列編碼,大型程序時請改用unsigned int類型
//無返回數據。
//---------------------------------------------------
void PutCdotInGraph( Uint Ox, Uchar Oy, Uchar Cnumber, Uchar DotWidth ) {
Uint tempPtr,Optr;
Uchar tempCount1,tempCount2,nByte;
Optr = (Uint)Oy * paraP9 + Ox;
nByte = DotWidth/8;
WriteCommand( CsrDirD ); // 自動右移。
tempPtr = (Uint)Cnumber * DotWidth*nByte;
for (tempCount1=0;tempCount1<nByte;tempCount1++) {
WriteCommand( CsrW ); // 光標定位指令
WriteData( (Uchar)(Optr &0xff) ); // 設置光標地址CSR
WriteData( (Uchar)(Optr /256 ) );
WriteCommand( mWrite ); // ram寫指令
switch(DotWidth){
case 16: for
(tempCount2=0;tempCount2<DotWidth;tempCount2++) {
WriteData(
Cdotlib[Cnumber].Msk[tempCount2*2+tempCount1] ); // 寫入數據
}
break;
case 24: for
(tempCount2=0;tempCount2<DotWidth;tempCount2++) {
WriteData(
Cdot24lib[tempPtr] ); // 寫入數據
tempPtr +=
nByte;
}
break;
}
tempPtr = Cnumber * DotWidth*nByte + tempCount1 + 1;
Optr++;
}
}
//--------------------------------------------------
//函數名稱:void Point(Uint Px, Uchar Py, Uchar attr )
//入口參數:橫坐標x,縱坐標y,畫點或擦點
//出口參數:無
//其它調用:WriteCommand(),WriteData()
//函數說明:用于在屏幕上任意一點畫點
//---------------------------------------------------
void Point(Uint Px, Uchar Py, Uchar attr,Uchar attr1 )
{
Uint tempPtr;
Uchar tempD,tempP;
tempPtr = (Uint)Py * paraP9 + (Px & 0x7fff)/8; // 去除最高位(顯示屬性)
if(attr) tempPtr+=BasePart2*256;
WriteCommand( CsrDirD ); // CSRDIR 代碼(光標自動下移)
WriteCommand( CsrW ); // 設置光標地址
WriteData( (Uchar)(tempPtr & 0xff) );
WriteData( (Uchar)(tempPtr /256) );
WriteCommand( mRead ); // 讀顯示ram指令
tempD = ReadDataLcm(); // 讀取當前顯示數據
tempP = 1<<(Uchar)(7-Px & 0x0007); // 根據預定屬性決定寫點或擦除
if( attr1 )tempD |= tempP; // 畫點
else tempD &= ~tempP; // 消點
WriteCommand( CsrW ); // 重新設置光標地址
WriteData( (Uchar)(tempPtr & 0xff) );
WriteData( (Uchar)(tempPtr /256) );
WriteCommand( mWrite ); // 代碼0x42,數據寫入指令
WriteData( tempD ); // 寫入合成數據
}
//----------------------------------------------
//函數名稱:void LcmClear( void )
//其它調用:WriteCommand(),WriteData()
//函數說明:用于清顯示32K RAM區清屏字程序
//----------------------------------------------
void LcmClear( void ) {
uint i1=32768;
WriteCommand( CsrDirR ); // 光標移動方向定義:自動右移
WriteCommand( CsrW ); // 光標Locate,定位
WriteData( 0 ); // 寫入參數CSRL設置參數光標指針低8位
WriteData( 0 ); // 寫入參數CSRH設置參數光標指針高8位
WriteCommand( mWrite ); // 數據寫入指令,代碼0x42
while(i1--) {
WriteData( 0x0 ); // 寫入數據0
}
}
//-------------------------------------------------------
//函數名稱:void Locatexy(Uchar x,Uchar y, Uchar attribs)
//入口參數:橫坐標x,縱坐標y,所在的區attribs
//出口參數:無
//其它調用:WriteCommand(),WriteData()
//函數說明:用于光標位定位
//--------------------------------------------------------
void Locatexy(uchar x,uchar y, uchar attribs)
{
uint temp;
temp = (uint)y*paraP9+x;
if(attribs==1)
temp += BasePart2*256; // 如果需要就指向第二區,加上第二區首地址
if(attribs==2)
temp +=BasePart3*256;
WriteCommand( CsrW ); // 光標Locate,定位
WriteData( (uchar)(temp & 0xff) ); // 寫入參數CSRL設置參數光標指針低8位
WriteData( (uchar)(temp /256 ) ); // 寫入參數CSRH設置參數光標指針高8位
}
//-------------------------------------------------------
//函數名稱:Uchar dprintf(Uchar x, Uchar y, Uchar att,bit fb, char *fmt, ...)
//入口參數:橫坐標x,縱坐標y,所在的層att,是否反白fb,所要顯示在屏幕上的字符串
//出口參數:字符串長度
//其它調用:太多了,自己看吧。
//函數說明:用于漢字及英文字符的混合顯示,英文字符為8*16,漢字為16*16
//--------------------------------------------------------
Uchar dprintf(uchar x, uchar y, uchar att,bit fb, char *fmt, ...)
{
va_list arg_ptr;
char c1,c2,cData;
Uchar i= 0,j,uLen,uRow,uCol,temp;
Uint k;
uRow = x;
uCol = y;
uLen = 0;
WriteCommand( CsrDirD ); // 光標移動方向定義:自動下移
Locatexy(uRow,uCol,att); //起點定位
va_start(arg_ptr, fmt);
uLen = (Uchar)vsprintf(tmpBuf, fmt, arg_ptr);
va_end(arg_ptr);
while(i<uLen)
{
c1 = tmpBuf[i];
c2 = tmpBuf[i+1];
if(c1 >= 0)
{ // ASCII
if(c1 < 0x20)
{
switch(c1)
{
case CR:
case LF: // 回車或換行
i++;
if(uRow < 224)
Locatexy(uRow+16,uCol,att);
else
Locatexy(0,0,att);
continue;
case BS: // 退格
if(uCol > 0)
uCol--;
Locatexy(uRow,uCol,att);
cData = 0x00;
break;
default: // 其他
c1 = 0x1f;
}
}
for(j=0;j<16;j++)
{
WriteCommand( mWrite ); // 寫數據
if(c1 >= 0x1f)
{
if(fb)
{
WriteData(255-ASC_MSK[(c1-0x20)*16+j]);
}
else
{
WriteData(ASC_MSK[(c1-0x20)*16+j]);
}
}
else
WriteData(cData);
}
uRow++;
}
else // 中文
{
for(j=0;j<sizeof(Cdotlib)/sizeof(Cdotlib[0]);j++) // 查找定位
{
if((c1 == Cdotlib[j].Index[0]) && (c2 == Cdotlib[j].Index[1]))
break;
}
for(k=0;k<2;k++) // 分16行輸出
{
Locatexy(uRow+k,uCol,att);
WriteCommand( mWrite ); // 寫數據(命令)
for(temp=0;temp<16;temp++)
{
if(fb)
{
WriteData( 255-Cdotlib[j].Msk[temp*2 + k]);
}
else
{
WriteData( Cdotlib[j].Msk[temp*2 + k]);
}
}
}
uRow +=2; // 光標右移一大格
i++;
}
if(uRow >= 40) // 光標后移
{
uCol += 16; // Y坐標
uRow = 0; // X坐標
if( uCol >= 240 ) uCol = 0;
}
Locatexy(uRow,uCol,att);
i++;
}
return uLen; //返回字串長度,漢字按2字節計算
}
main()
{
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -