📄 main.c
字号:
break;
/*
//enter user defined test
case AP_KEY_EQ | AP_KEY_UP:
result = RESULT_MYTST;
break;
*/
default:
result = ap_handle_hotkey(key);
if(result == RESULT_REDRAW)
{
result = RESULT_NULL; //remember to clear result
need_draw = TRUE;
}
}
ASSERT(active < MAIN_ITEMCOUNT);
//check sec counter
if(sec_tester_count == 5)
{
sec_tester_count = 0;
result = RESULT_TESTER;
}
if(sec_staff_count == 5)
{
sec_staff_count= 0;
draw_staff();
need_draw = TRUE;
}
}//result == 0
else if(result == RESULT_POWERON)
{
ClearScreen(NULL);
UpdateScreen(NULL);
//weng, 20040312
draw_logo(TRUE);
if (g_comval.LightTime == 0) //每次开机判断一次!解决Bug Report:27
sKY_CloseBacklight();
else
sKY_OpenBacklight(); //for s2 add by ccm
//DUMP("result_bak:", result_bak);
result = result_bak;
//standby 起来不要开始录音
if(result == RESULT_RECORD) result = RESULT_REC_NOSTART;
need_draw = TRUE;
}
else //boot with param or result != 0
{
//close when exec ap
ResClose(res_fp);
//boot to what ap?
switch( result)
{
case RESULT_MUSIC:
#ifdef SDK35FD
if ( g_usbval.TransCancelForLowPower == 1 ) //playlist和hds因为低电还未转化
{
result = RESULT_BUILDLIST;
}
else
{
result_bak = result;
result = ExecAP("music.ap", 0);
}
#else
result_bak = result;
result = ExecAP("music.ap", 0);
#endif
break;
case RESULT_RADIO:
result_bak = result;
result = ExecAP("fmradio.ap", 0);
break;
case RESULT_REC_NOSTART: //进入录音
result_bak = result;
if (g_comval.RecordType == 0) //=0:Voice Record. by ccm
{
result = ExecAP("record.ap", 0);
}
else if(g_comval.RecordType == 1)
{
result = ExecAP("fmrecord.ap", 0);
}
else if(g_comval.RecordType == 2) //=1:Music Record. by ccm
{
MY_DUMP("M-Rec:NONFM", 0);
#ifdef MY_TEST
result = RESULT_MAIN;
#else
result = ExecAP("M-Record.ap", 0); //0(M-Record.ap:NON_FMREC):非FM录音
#endif
}
break;
case RESULT_RECORD: //开始录音
result_bak = result;
if (g_comval.RecordType == 0) //=0:Voice Record. by ccm
{
result = ExecAP("record.ap", 1);
}
else if(g_comval.RecordType == 1) // WAV MUSIC
{
result = ExecAP("fmrecord.ap", RESULT_RECORD);
}
else if(g_comval.RecordType == 2) //=1:Music Record. by ccm
{ // MP3 music
MY_DUMP("M-Rec:MIC", 0);
#ifdef MY_TEST
result = RESULT_MAIN;
#else
result = ExecAP("M-Record.ap", result);//进入直接开始MIC录音 by ccm recommended Spec1.13 Ryan.
#endif
}
break;
// FM 录音 by ccm 20040524
case RESULT_FMREC_START:
case RESULT_FMREC_NOSTART:
if (result == RESULT_FMREC_START)
MY_DUMP("M-Rec:FM-START", 0);
else if(result == RESULT_FMREC_NOSTART)
MY_DUMP("M-Rec:FM-NOSTART", 0);
#ifdef MY_TEST
result = RESULT_RADIO;
#else
if(g_comval.RecordType == 2)
result = ExecAP("M-Record.ap", result); //传入result,以判断是否直接开始FM录音?
else
result = ExecAP("fmrecord.ap", result);
#endif
if (result == RESULT_MAIN) //判断是否是FM录音长按mode键退出,是则返回FM界面.
{
//长按MODE键,直接返回FM界面! by ccm
result = RESULT_RADIO;
}
//ASSERT(result==RESULT_RADIO); //FM M-record后必须返回FM界面
break;
case RESULT_STANDBY:
//DUMP("result_bak:", result_bak);
result = ExecAP("standby.ap", 0);
break;
case RESULT_FIRST_BOOT:
//DUMP("result_bak:", result_bak);
result = ExecAP("standby.ap", 1);
break;
case RESULT_SYSTEM:
result_bak = result;
result = ExecAP("setting.ap", 0);
break;
case RESULT_SYSTEM_ADFU:
result_bak = result;
result = ExecAP("setting.ap", 1);
break;
case RESULT_TESTER:
result = ExecAP("tester.ap", 0);
//DUMP("goes to tester", 0);
//result = 0;
break;
case RESULT_UDISK:
#ifdef CHGVDD
output8(0x4f,0xa5); //VCC set to 3.0V, VDD set to 2.1V
#endif
for (counter=0; counter<0x100; counter++){;}
if(IsUDisk)
{
result = ExecAP("usbdisk.ap", 0);
}
else
{
result = ExecAP("pddrm.ap", 0);
if ( result == RESULT_UDISK )
{
result = ExecAP("usbdisk.ap", 1); //MTP AutoSwitch 2 MSC
}
}
#ifdef CHGVDD
output8(0x4f,0xa2); //VCC set to 3.0V, VDD set to 1.8V
for (counter=0; counter<0x100; counter++){;}
#endif
//fix udisk return, drop key up
if(result == RESULT_MAIN)
{
while(1)
{
int standbymsg;
standbymsg = GetSysMsg();
if(standbymsg == Msg_KeyShortUp)break;
if(standbymsg == Msg_KeyLongUp)break;
}
result = RESULT_NULL;
}
break;
case RESULT_UPGRADE:
//DUMP("key to adfu:", 0);
switch(DRV_DetectUD(0))
{
case STG_NAF_LB:
result = ExecAP("adfuf644.ap", 0);
break;
case STG_NAF_SB:
result = ExecAP("adfuf321.ap", 0);
break;
case STG_NAF_MB:
result = ExecAP("adfuf641.ap", 0);
break;
default:
break;
}
//DUMP("result:", result);
//fix udisk return, drop key up
if(result == RESULT_MAIN)
{
while(1)
{
int standbymsg;
standbymsg = GetSysMsg();
if(standbymsg == Msg_KeyShortUp)break;
if(standbymsg == Msg_KeyLongUp)break;
}
//result = RESULT_NULL;
result = RESULT_SYSTEM_ADFU;
}
break;
case RESULT_VOICE:
result_bak = result;
result = ExecAP("voice.ap", 0);
break;
/*
case RESULT_MYTST:
result = ExecAP("mytst.ap",0);
break;
*/ case RESULT_CAMERA:
result_bak = result;
result = ExecAP("camera.ap", 0);
break;
case RESULT_BUILDLIST:
result = ExecAP("buildlist.ap", 0);
break;
case RESULT_XML2HDS:
result = ExecAP("xml2hds.ap", 0);
break;
default:
DUMP("never run here: ", result);
break;
}//switch(reault)
// 解决按键混乱问题
while( ap_get_message() != NULL){ ; }
//g_comval 需要重新读进来
read_var(); //更新Setting修改值
IsUDisk = g_comval.Onlinedev; //更新Onlinedev
#ifdef SDK35FD
VMRead(&g_usbval, VM_AP_UDISK, sizeof(usbval_t)); //更新g_usbval,存放低电退出xml2hds信息
#endif
//re open res_f
res_fp = ResOpen("ui30.res");
ASSERT( res_fp != NULL);
//DUMP("ap return:", result);
//select first item, recommonded by johnlee
//active = 0;
need_draw = TRUE;
}//result != 0
}//while(1)
//never run here
}
#ifdef MAIN_DEBUG
//for test
const WORD pic_inactive[] = {UPGRADE, RATE, MEMORY, LAN, POWER, FW,EXIT};
const WORD pic_active[] = {UPGRADEA, RATEA, MEMORYA, LANA, POWERA, FWA,EXITA};
const WORD string[] = {TEST4, TEST2, TEST1, TEST3, TEST5, TEST6, SMAIN10};
//realtime show the select num
void my_callback(int value)
{
DUMP_NUM(value);
}
//小的测试
void my_test(void)
{
slider.max = +20;
slider.min = -20;
slider.step = 2;
ui_slider(&slider, my_callback);
}
void test()
{
int result;
char key;
slider.value = 0;
//test here
while(1) //main ui for test
{
/* menu test ok! */
menu.active = 0;
menu.pic_active = pic_active;
menu.pic_inactive = pic_inactive;
menu.string = string;
menu.total = 7;
menu.string_id = lan_id;
result = ui_function_menu(&menu, NULL); //auto exit in 5s
//check for usk plugin
if(result == RESULT_UDISK)
{
ResClose(res_fp); //close when ap exec
result = ExecAP("USBDISK.AP", 0);
res_fp = ResOpen("ui30.res"); //open when ap exit
ASSERT(res_fp != NULL);
continue;
}
//check for user selected
switch(menu.active)
{
case 0: //go to true main ap
result = RESULT_MAIN;
break;
case 1: //your test here
ResClose(res_fp); //close when ap exec
result = ExecAP(YOUR_AP_NAME, 1234);
DUMP("your ap return:", result);
res_fp = ResOpen("ui30.res"); //open when ap exit
ASSERT(res_fp != NULL);
break;
case 2: //go to udisk
ResClose(res_fp); //close when ap exec
result = ExecAP("USBDISK.AP", 0);
res_fp = ResOpen("ui30.res"); //open when ap exit
ASSERT(res_fp != NULL);
break;
case 3: //change language
lan_id++;
if(lan_id > 2) lan_id = 0;
break;
case 4:
//test ap_get_message
ClearScreen(NULL);
SetTextPos(0, 16);
PutS("press EQ to exit.", 255);
UpdateScreen(NULL);
while(1)
{
key = ap_get_message();
ClearScreen(NULL);
UpdateScreen(NULL);
if(key == AP_KEY_EQ) break;
else if(key & AP_KEY_UP) MsgBox(key, 0, 8);
else if( (key & AP_KEY_HOLD) != 0 ) MsgBox(key, 0, 16);
else if((key & AP_KEY_LONG) != 0 ) MsgBox(key, 0, 24);
else if( key != AP_MSG_RTC && key != AP_MSG_CHARGING) MsgBox(key, 0, 0);
}
break;
case 5:
//key GetSysMsg test
SetTextPos(0, 16);
PutS("press EQ to exit.", 255);
UpdateScreen(NULL);
while(1)
{
key = GetSysMsg();
if(key != Msg_KeyNull && key != MSG_RTC2HZ) MsgBox(key, 10, 24);
if(key == Msg_KeyEQ) break;
}
break;
case 6: //exit
//result = RESULT_MAIN;
my_test();
break;
default: //never run here
ASSERT(FALSE);
break;
}//switch
//check id user select true main
if(result == RESULT_MAIN) break;
}//while(1)
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -