?? test.c
?? 無線音頻電話(gprs)
?? C
?? 第 1 頁 / 共 2 頁
字號:
??
case DEF_KEY_6: sKeyTested[6]='1'; szBuf[6]='6'; break;
case DEF_KEY_7: sKeyTested[7]='1'; szBuf[7]='7'; break;
case DEF_KEY_8: sKeyTested[8]='1'; szBuf[8]='8'; break;
case DEF_KEY_9: sKeyTested[9]='1'; szBuf[9]='9'; break;
case DEF_KEY_DOT: sKeyTested[10]='1'; szBuf[10]='.'; break;
case DEF_KEY_ENTER: sKeyTested[11]='1'; szBuf[12]='E'; break;
case DEF_KEY_CLEAR: sKeyTested[12]='1'; szBuf[14]='C'; break;
case DEF_KEY_ESC:
sKeyTested[13]='1';
cESC++;
if (cESC == 3)
{
_Buzzer();
_Display(2, "鍵盤測試中止");
_Delay(DEF_DELAY_TIMES);
return 0;
}
memcpy(szBuf1 ,"ESC",3); break;
default: _Display(2, " 錯誤的鍵碼");
while(1) {_Buzzer();}
}
_Display(1,(uchar *)szBuf);
_Display(2,(uchar *)szBuf1);
}
}
uchar TestClock(void)
{
stClock ClockNow;
uchar szBuf[20];
// uint t1,t2,t3,t4,t5,t6,t7,
uint TimeF, TimeT;
uchar cc;
while (1)
{
TimeF = TimeT = 0;
while( ! _KeyBoardTest() )
{
_ClockRead((stClock*)(&ClockNow));
t1 = ClockNow.year + 1960;
t2 = ClockNow.month;
t3 = ClockNow.day;
t4 = ClockNow.hour;
t5 = ClockNow.minute;
t6 = ClockNow.second;
t7 = ClockNow.weekday;
if ( TimeF!=t6) {TimeF=t6;TimeT++;}
if ( TimeT==60)
{
_Buzzer();
_Display(2, "時鐘測試通過");
_Delay(DEF_DELAY_TIMES);
return 1;
}
sprintf(szBuf, " %d/%02d/%02d",t1,t2,t3);
_Display(1, szBuf);
sprintf(szBuf, " %02d:%02d:%02d %1d",t4,t5,t6,t7);
_Display(2, szBuf);
}
cc = _KeyBoardGet();
_Buzzer();
switch ( cc )
{
case DEF_KEY_ENTER:
_Display(2,"");
_Display(1,"YYYYMMDDHHMMSSW");
t1 = Input(2, szBuf, 15);
if( t1 != 15)
{
_Display(2,"輸入時間無效");
_Delay(DEF_DELAY_TIMES);
break;
}
memcpy(PubBuff, szBuf, 4);
PubBuff[4]=0;
ClockNow.year = atoi(PubBuff)-1960;
memcpy(PubBuff, szBuf+4, 2);
PubBuff[2]=0;
ClockNow.month = atoi(PubBuff);
memcpy(PubBuff, szBuf+6, 2);
ClockNow.day = atoi(PubBuff);
memcpy(PubBuff, szBuf+8, 2);
ClockNow.hour = atoi(PubBuff);
memcpy(PubBuff, szBuf+10, 2);
ClockNow.minute = atoi(PubBuff);
memcpy(PubBuff, szBuf+12, 2);
ClockNow.second = atoi(PubBuff);
memcpy(PubBuff,szBuf+14,1);
PubBuff[1] = 0;
ClockNow.weekday = atoi(PubBuff);
_ClockSet((stClock *)(&ClockNow));
break;
case DEF_KEY_ESC:
return 0;
}//switch
}//while
}
uchar TestSysRW(void)
{
uint i, j, count;
uchar offset, cc;
uchar TempSrc[512-60];
uchar TempObj[512-60];
count = 512-64;
offset = 0;
memset(TempSrc, 0, 512-60);
memset(TempObj, 0, 512-60);
for (i=0; i<28; i++)//512-64 == 28*16 == 448
{
memset(TempSrc+i*16, 0x20+i, 16);
// TempSrc[i] = (uchar)(0x20 + i);
}
cc = _SysDataWrite(offset, count, TempSrc);
if ( cc )
{
_Display(1, "寫系統數據錯:");
BCDtoChar(&cc, 1, TempObj);
_Display(2, TempObj);
_Delay(DEF_DELAY_TIMES);
return 0;
}
else
_Display(1, "寫系統數據正確!");
cc = _SysDataRead(offset, count, TempObj);
if ( cc )
{
sprintf(TempObj, "讀系統數據錯:[%02X]", cc);
_Display(1, TempObj);
_Delay(DEF_DELAY_TIMES);
return 0;
}
else
{//cmp Src & Obj
cc = 1;
for (i=0; i<count; i++)
{
if (TempSrc[i] != TempObj[i])
{
cc = 0;
break;
}
}
if (i != count)
{
// sprintf(PubBuff, "[%02X]!=[%02X]", TempSrc[i], TempObj[i]);
BCDtoChar(TempSrc+i, 1, PubBuff);
_Display(4, PubBuff);
BCDtoChar(TempObj+i, 1, PubBuff);
_Display(5, PubBuff);
sprintf(PubBuff, "讀寫比較錯在:[%d]", i);
}
else
strcpy(PubBuff, "讀系統數據正確!");
_Display(2, PubBuff);
_Delay(DEF_DELAY_TIMES);
return cc;
}
}
uchar Input(uchar line, uchar *InBuff, uchar InLen)
{
uchar len, uch, usefull, j;
uint i;
i = j = len = 0;
memset(InBuff, 0, InLen+2);
while(1)
{
while(!_KeyBoardTest())
{
i++;
_Display(line, InBuff);
if ( i == 30 )
{
j = (j+1) & 0x01;
if ( j == 0 ) i = 0;
else i = '_';
if (len == 0)
InBuff[0] = i;
else
InBuff[len] = i;
i = 0;
}
}
_Buzzer();
uch = _KeyBoardGet();
if ( (len >= InLen) &&
(uch != DEF_KEY_ENTER) &&
(uch != DEF_KEY_CANCEL) )
continue;
usefull = 1;
switch ( uch )
{
case DEF_KEY_0: uch='0'; break;
case DEF_KEY_1: uch='1'; break;
case DEF_KEY_2: uch='2'; break;
case DEF_KEY_3: uch='3'; break;
case DEF_KEY_4: uch='4'; break;
case DEF_KEY_5: uch='5'; break;
case DEF_KEY_6: uch='6'; break;
case DEF_KEY_7: uch='7'; break;
case DEF_KEY_8: uch='8'; break;
case DEF_KEY_9: uch='9'; break;
case DEF_KEY_ENTER:
return len;
case DEF_KEY_CANCEL:
if ( len == 0 ) return DEF_KEY_CANCEL;
len--;
InBuff[len] = 0;
_Display(line, InBuff);
continue;
default: usefull=0; break;
}
if ( usefull == 1 )
{
InBuff[len] = uch;
len++;
InBuff[len] = 0;
i = j = 0;
_Display(line, InBuff);
}
}
}
void SetBuff(uchar *SrcBuff, Val)
{
uchar i, j;
uint k;
for (i=0; i<16; i++)
{
for (j=0; j<16; j++)
{
if ( Val )
SrcBuff[i*16 + j] = Val+i + j;
else
SrcBuff[i*16 + j] = 0x00;
}
}
SrcBuff[256] = 0x00;
return;
}
void TestModem(void)
{
uchar k;
while ( 1 )
{
_ClearScreen();
_DispXY (1,2,0, "MODEM測試");
_Display(2, "1--AT指令測試");
_Display(3, "2--擴展串口測試");
_Display(4, "按取消鍵退出... ...");
while ( !_KeyBoardTest() ) ;
k = _KeyBoardGet();
_ClearScreen();
switch ( k )
{
case DEF_KEY_1: TestModemRS(); break;
case DEF_KEY_2: TestModemManualDial(); break;
case DEF_KEY_CANCEL: return;
}
}
}
uchar TestModemRS(void)
{
uchar cc;
_AsyncOpen(2400,0);
_EXP_Open(2400,0);
_ClearScreen();
_Display(4, "按取消鍵退出... ...");
while(1)
{
if ( _KeyBoardTest() )
{
cc = _KeyBoardGet();
if(cc== DEF_KEY_CANCEL) {_Dial_Tone(0);return;}
}
if (_AsyncGetTest())
{
cc = _AsyncGet();_Dial_Tone(1);
_EXP_Put(cc);
}
if (_EXP_GetTest())
{
cc = _EXP_Get();
_AsyncPut(cc);
}
}
}
void TestModemManualDial(void)
{
uchar cc,dd;
uint i;
_AsyncOpen(9600,0);
_ClearScreen();
_Display(4, "按取消鍵退出... ...");
while(1)
{
if ( _KeyBoardTest() )
{
cc = _KeyBoardGet();
if(cc== DEF_KEY_CANCEL) return;
}
if (_AsyncGetTest())
{
cc = _AsyncGet();
if(cc==0xff) continue;
dd=cc;
i = ((uint)cc&0x000f)+0x8000;
if((cc&0xf0)==0)
{
_AsyncPut(cc);
P1_5=0;
P1_6=1;
cc = XBYTE[i];
_AsyncPut(cc);
}
else
{
while(1)
{
if ( _KeyBoardTest() )
{
cc = _KeyBoardGet();
if(cc== DEF_KEY_CANCEL) return;
}
if (_AsyncGetTest())
{
cc = _AsyncGet();
if(cc==0xff) break;
_AsyncPut(dd);
_AsyncPut(cc);
P1_5=0;
P1_6=1;
XBYTE[i] = cc; break;
}
}
}
}
}
}
uchar TestPrint(uint Val)
{
uchar cc;uint i;
memset(PubBuff, 0, DEF_SECTOR_LEN);
// strcpy(PubBuff, " 打印機測試");
_Print(0," 打印機測試");
strcpy(PubBuff, "一二三四五六七八九十1234567890");
_Print(0,PubBuff);
strcpy(PubBuff, "12345678901234567890一二三四五六七八九十");
_Print(0,PubBuff);
strcpy(PubBuff, "一二三四五六七八九十1234567890");
_Print(0,PubBuff);
strcpy(PubBuff, "12345678901234567890一二三四五六七八九十");
_Print(0,PubBuff);
strcpy(PubBuff, "--------------------------------------------");
_Print(0,PubBuff);
strcpy(PubBuff, "12345678901234567890一二三四五六七八九十");
_Print(0,PubBuff);
strcpy(PubBuff, "一二三四五六七八九十1234567890");
_Print(0,PubBuff);
strcpy(PubBuff, "12345678901234567890一二三四五六七八九十");
_Print(0,PubBuff);
strcpy(PubBuff, "一二三四五六七八九十1234567890");
_Print(0,PubBuff);
strcpy(PubBuff, "12345678901234567890一二三四五六七八九十");
_Print(0,PubBuff);
strcpy(PubBuff, "一二三四五六七八九十1234567890");
_Print(0,PubBuff);
strcpy(PubBuff, "12345678901234567890一二三四五六七八九十");
_Print(0,PubBuff);
strcpy(PubBuff, "一二三四五六七八九十1234567890");
_Print(0,PubBuff);
strcpy(PubBuff, "12345678901234567890一二三四五六七八九十");
_Print(0,PubBuff);
strcpy(PubBuff, "一二三四五六七八九十1234567890");
_Print(0,PubBuff);
strcpy(PubBuff, "12345678901234567890一二三四五六七八九十");
_Print(0,PubBuff);
strcpy(PubBuff, "一二三四五六七八九十1234567890");
_Print(0,PubBuff);
strcpy(PubBuff, "12345678901234567890一二三四五六七八九十");
_Print(0,PubBuff);
strcpy(PubBuff, "--------------------------------------------");
_Print(0,PubBuff);
memset(PubBuff, 0, DEF_SECTOR_LEN+1);
for (i=0; i<192; i++)//
PubBuff[i*2] = 0x55;//
_PrintGraph(0,PubBuff);
_PrintGraph(0,PubBuff);
strcpy(PubBuff, " 打印測試結束...");
_Print(0,PubBuff);
_PrintStep(32);
return 1;
}
uchar TestBackup(void)
{
uint i;
uchar j, BlockFrom, BlockTo, k;
uchar Buf[260];
k = 1;
BlockFrom = _GetSysFirstBckBlk();
BlockTo = BlockFrom + _GetSysBackupBlock();
for (j=BlockFrom; j<BlockTo; j++)
{
for (i=0; i<256; i++)
PubBuff[i] = j+i;
if ( _DataBackup(j, 0, PubBuff) )//127
{
memset(Buf, 0, 260);
_DataRestore(j, 0, Buf);//127
if ( memcmp(PubBuff, Buf, 256) )
{
_Buzzer();
_Delay(DEF_DELAY_TIMES/2);
_Buzzer();
_Delay(DEF_DELAY_TIMES/2);
_Buzzer();
sprintf(Buf, "恢復第[%d]塊出錯", j);
k = 0;
break;
}
}
else
{
_Buzzer();
_Delay(DEF_DELAY_TIMES/2);
_Buzzer();
sprintf(Buf, "備份第[%d]塊出錯", j);
k = 0;
break;
}
}
if ( j==BlockTo )
sprintf(Buf, "備份/恢復正確");
_Buzzer();
_Display(1, Buf);
_Delay(DEF_DELAY_TIMES*2);
return k;
}
void TestBkLight(void)
{
uchar i,j;
_ClearScreen();
_DispXY(1, 1,0, "按任意鍵...");
i=1;
_SetBkLight(i);
while (1)
{
while( !_KeyBoardTest());
j = _KeyBoardGet();
if (j==DEF_KEY_CANCEL) return;
i=i^1;
_SetBkLight(i);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -