📄 tst.c
字号:
/*
* $(CUSTOM_DEMO)/tst/tst.c
*
* Module: Tester
*/
#include "../general.h"
#ifdef MT8302_MANUFACTURE_TEST
#include "../fslist/flcmd.h"
#include "../fslist/flcomm.h"
#include "tst.h"
/*
* Internal definition
*/
#define TST_LAST_CARD_NO 2
#define TST_VER_NO '0', '1'
#define TST_END_PROMPT_STR {16, 'M', 'T', '8', '3', '0', '2', ' ', \
'T', 'e', 's', 't', ' ', 'D', 'o', 'n', 'e'}
#define TST_VERSION_STR {7, 'V', 'E', 'R', ':', ' ', TST_VER_NO}
/*
* Enumerator of tester::state
*/
enum {
TST_STT_INIT, /* tester is just inited */
TST_STT_READY, /* tester is ready to trigger next play */
TST_STT_PLAYING, /* testing item is under playing */
TST_STT_END /* test is done */
};
/*
* Member declaration
*/
static BYTE xdata _bTstKey; /* tester::key */
static BYTE xdata _bTstState; /* tester::state */
static BYTE xdata _bTstCardNo; /* tester::card_counter */
/*
* Internal method
*/
#define TST_INT_KEY_ISSUE(key) {_bTstKey = key;}
#define TST_INT_KEY_CLEAR {_bTstKey = IR_NONE;}
#define TST_IS_KEY_PENDING fgFlClIsLock()
#define TST_KEEP_PLAYING_TIME 5 /* in sec */
#if 0
/**
* tester::begine_prompt
*/
static void vTstBeginPrompt(void) large
{
return;
}
#endif //0
/**
* tester::end_prompt
*/
static void vTstEndPrompt(void) large
{
BYTE pbStr[] = TST_END_PROMPT_STR;
BYTE pbStr1[] = TST_VERSION_STR;
/* disable the file menu */
wFlMnLeave(FALSE);
/* show the message */
vCreateWB(WB_SELMENU, TRUE);
vSetWBTcColor(WB_SELMENU);
vSetTcPal(WB_SELMENU, 2, BLEND_3, TRUECOLOR_BLUE);
vSetTcPal(WB_SELMENU, 0, BLEND_3, TRUECOLOR_BLUE);
vSetMsgCol4(WB_SELMENU, 0, 2, 2, 3);
vOsdShowStrXY(160, 65, WB_SELMENU, pbStr);
vOsdShowStrXY(210, 115, WB_SELMENU, pbStr1);
vEnableWB(WB_SELMENU);
return;
}
/**
* tester::evthdr_on_enter_item
*
* des:
* redraw screen is done
* @tester_state_inited:
* press IR_PROGRAM to switch to disc list, ->tester_state_ready
* @tester_state_ready:
* press IR_ENTER to play the first item, ->tester_state_playing
* @tester_state_playing:
* press IR_DOWN to next item ->tester_state_ready
*/
static void vTstEvtHdrOnEnterItem(BYTE bArg1, BYTE bArg2, BYTE bArg3) large
{
switch (_bTstState) {
case TST_STT_INIT:
_bTstKey = IR_PROGRAM;
_bTstState = TST_STT_READY;
break;
case TST_STT_READY:
TST_INT_KEY_ISSUE(IR_ENTER);
_bTstState = TST_STT_PLAYING;
break;
case TST_STT_PLAYING:
TST_INT_KEY_ISSUE(IR_DOWN);
_bTstState = TST_STT_READY;
break;
default:
/* exception handle */
break;
}
return;
}
/**
* tester::evthdr_on_play_item_done
*
* des:
* play item is done.
* @tester_state_playing:
* press IR_DOWN to next item. ->tester_state_ready
*/
static void vTstEvtHdrOnPlayItemDone(BYTE bArg1, BYTE bArg2, BYTE bArg3) large
{
switch (_bTstState) {
case TST_STT_PLAYING:
TST_INT_KEY_ISSUE(IR_DOWN);
_bTstState = TST_STT_READY;
break;
default:
/* exception handle */
break;
}
return;
}
/**
* tester::evthdr_on_no_more_item
*
* des:
* there is no more item on this card
* @ current card is not the last one.
* press IR_MUTE to switch to next card, ->tester_state_inited
* @ current card is the last one.
* show the ending prompt.
*/
static void vTstEvtHdrOnNoMoreItem(BYTE bArg1, BYTE bArg2, BYTE bArg3) large
{
if (_bTstCardNo < TST_LAST_CARD_NO) {
/* there is some more item, move to next card */
_bTstCardNo ++;
TST_INT_KEY_ISSUE(IR_MUTE);
_bTstState = TST_STT_INIT;
} else {
/* on the last card, testing is done */
vTstEndPrompt();
}
return;
}
/**
* tester::evthdr_on_playing_time_update
*
* des:
* the playing time is updated.
* @tester_state_playing
* check if we have to change to stop the current playback.
*/
static void vTstEvtHdrOnPlayingTimeUpdate(BYTE bArg1, BYTE bArg2, BYTE bArg3) large
{
switch (_bTstState) {
case TST_STT_PLAYING:
if (bArg3 > TST_KEEP_PLAYING_TIME) { /* we consider second only */
TST_INT_KEY_ISSUE(IR_STOP);
}
break;
default:
break;
}
return;
}
/*
* Exported interfaces
*/
/**
* tester::init
*
* Init module "Tester"
*/
void vTstInit(void) large
{
#if 0
vTstBeginPrompt();
#endif //0
TST_INT_KEY_CLEAR;
_bTstState = TST_STT_INIT;
_bTstCardNo = 0;
return;
}
/**
* tester::post_event
*
* Event handler of module "Tester".
*/
void vTstPostEvt(BYTE bEvt, BYTE bArg1, BYTE bArg2, BYTE bArg3) large
{
switch (bEvt) {
case TST_EVT_ENTER_ITEM:
vTstEvtHdrOnEnterItem(bArg1, bArg2, bArg3);
break;
case TST_EVT_PLAY_ITEM_DONE:
vTstEvtHdrOnPlayItemDone(bArg1, bArg2, bArg3);
break;
case TST_EVT_NO_MORE_ITEM:
vTstEvtHdrOnNoMoreItem(bArg1, bArg2, bArg3);
break;
case TST_EVT_PLAYING_TIME_UPDATE:
vTstEvtHdrOnPlayingTimeUpdate(bArg1, bArg2, bArg3);
break;
default:
/* exception handler */
break;
}
return;
}
/**
* tester::peek_key
*/
BYTE bTstPeekKey(void) large
{
if (TST_IS_KEY_PENDING)
return IR_NONE;
else
return _bTstKey;
}
/**
* tester::get_key
*/
BYTE bTstGetKey(void) large
{
BYTE bTmpKey;
if (TST_IS_KEY_PENDING) {
return IR_NONE;
}
bTmpKey = _bTstKey;
TST_INT_KEY_CLEAR;
return bTmpKey;
}
#endif /* MT8302_MANUFACTURE_TEST */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -