⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmimain.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
    // nm15.02.01
    // this timer is used for backlight
    // the B-Sample dont support backlight
    //    tim = timCreate(0,1000,(MfwCb)timer); /* backlight timer        */


    mainMmiLng = lngCreate(0,0,&mainLngInfo,0); /* language handler */

    // times clock event
    times = timCreate(0,TIME_MINUTE,(MfwCb)timesEvent);
    timer_Hnd = timCreate(0, 1000, (T_MFW_CB)timer_tim_cb);//gdy add 03/04/03

    //joker
    gtVibator= timCreate(0,TIME_VIBRATOR,(MfwCb)vibratorEvent);
	/* 2004/07/19 sunsj Fix MI18800000465 */
	timStart(gtVibator);
	
    ///zym added
    mme = mmeCreate(0, MfwMmeSignal|MfwMmeBattery|MfwMmeBaState, (MfwCb)globalMme);       //xzy change this "MfwMmeSignal|" for get signal by another way

    // mmeSetVolume(100, 100);                 /* set audio in/out to 100 percent */
    timlowvoltage=timCreate(0, 1000, (MfwCb)tim_LowVoltage_cb);

	// 2004.4.1 wyj call no win
	 hRingVibStartTimer = timCreate( 0, TIM4SECOND, (MfwCb)stopvib2playmelody);
	
#ifdef SEVEN_COLORS_LED
/* zhq, 2004/07/08, we use MA5 to drive led. */
#ifndef SEVEN_COLORS_LED_YAMAHA
   ColorLedBlinkTimer = timCreate( 0, 1200, (MfwCb)ColorLedBlinkEvent );
#endif //SEVEN_COLORS_LED_YAMAHA
   /* 2004/06/10 sunsj modify */
   ServiceLedTimer = timCreate( 0, 10000, (MfwCb)ServiceLedEvent );
   ServiceLedDelay = timCreate( 0, 1000, (MfwCb)ServiceLedDelayEvent );
   timStart(ServiceLedTimer);
#endif
	
    /* Special case:  The charger is connected, battery inside and    */
    /* the user is switching the mobile off. In this case the display */
    /* has to keep on                                                 */
    //zym
    /*
    MmiTraceInt(globalMobileMode);
    if(globalMobileMode == (GlobalCharging|GlobalDisplayFlag))
    {
      TRACE_FUNCTION(" ! clear GlobalDisplayFlag !");
      globalMobileMode = globalMobileMode & (~GlobalDisplayFlag);

      iconsChargeDisplayOnOff(1); //* switch the display on 
      iconsStateOfCharge();  //* display the text "charging.."  

      globalFlashBattery ();
    }*/


    //RM test 14-07 second = 0;
    memset(&currclock,0,sizeof(currclock));
    memset(&currdate,0,sizeof(currdate));
    currclock.sec = timedate.second;
    currclock.min = timedate.minute;
    currclock.hour = timedate.hour;

    currdate.day = timedate.day;
    currdate.month = timedate.month;
    currdate.year= timedate.year + 2000;  //zgz

#ifdef CAMERA_ENABLED
Cam_Ffs_Init();
#endif

	
    /*.......zy Mobile Innovation if flash read is ok read the timedate 04/08/02........*/
    /*.............end of zy change........................*/
    if( flash_CheckStat("/gsm/com/rfcap")<0 )
    {//no file
        if( flash_CheckStat("/gsm/com")<0 )
        {//no com dir
            if( flash_CheckStat("/gsm")<0 )
            {//no gsm dir
                ffs_ret=flash_PBmkdir("/gsm");
                if( ffs_ret<0 )
                {//make dir gsm failer
                    dspl_TextOut(1, 48, 0,"mkdir gsm error");
                    sprintf(err,"errid:%d",ffs_ret);
                    dspl_TextOut(1, 64, 0,err);
                    OverleapRegist=1;//show the flash error info
                }
            }
            //when gsm dir exist we build the com dir
            if( !OverleapRegist )
            {
                ffs_ret=flash_PBmkdir("/gsm/com");
                if( ffs_ret<0 )
                {//make dir com failer
                    dspl_TextOut(1, 48, 0,"mkdir com error");
                    sprintf(err,"errid:%d",ffs_ret);
                    dspl_TextOut(1, 64, 0,err);
                    OverleapRegist=1;//show the flash error info
                }
            }
        }
        //when gsm/com dir exist we build file
        if( !OverleapRegist )
        {
            ffs_ret=FlashRFCAPInitialise();
            if( ffs_ret<0 )
            {
                dspl_TextOut(1, 48, 0,"fwr rfcap err");
                sprintf(err,"errid:%d",ffs_ret);
                dspl_TextOut(1, 64, 0,err);
                OverleapRegist=1;//show the flash error info and overleap regist
            }
        }
    }

    deregis = FALSE;
    timStart(times);                 /*      start clock          */


    /* power-on key handler  */
    //    is not necessary anymore, this needs a additional keypress
    //    kbd = kbdCreate(0,KEY_HUP,(MfwCb)key);



    /*........................end of zy change ..............................................*/


    Gpio_hisr_initialize();
    Melody_Dev_Init( );

    // SetASpk_UpLinkPGA(UPLINKPGAVALUE);
    // SetASpk_V(VOLUMECONTROLVALUE);  
    SetEarMode();//zy 09/03
    ///zym added
    lcdOffControl=0;//zy 08/15
    //For DAR Bob added 03/03/06
    if( flash_CheckStat("/var/dbg")<0 )
    {
        ffs_ret=flash_PBmkdir("/var");
        ffs_ret=flash_PBmkdir("/var/dbg");
    }

#ifdef _MMS_ENABLE_
    //PowerInfoCbInit();
	MMS_Initialize();
#endif

    bat_info_init();
    MmiRsrcSetChinese();

	Backlight_ON( );

    if( OverleapRegist )//hxl add ,when flash error ,we overleap the regist,20021029
        dspl_TextOut(10, 32, 0,MmiRsrcGetText(TxtFlashErr));
    else
        startExec(PhoneInit,0);     // now the mobile is switched on        
    //end of hxl add 0903--------------------------------------------------------
    // LineControl=1;

	/*talcon add for pcsyn,2004.07.06*/
#ifdef MMI_PCSYN_ENABLED
	{
	extern int pcsynmfw_init (void);
		pcsynmfw_init();
    	}
#endif
		/*talcon add for pcsyn,2004.07.19*/
#ifdef MMI_MMSTASK_ENABLED
	{
	extern int mmsmfw_init (void);
		mmsmfw_init();
    	}
#endif

    MMIStart_completed = 1;
	
}

///zym added for kpd handle
void StartSecTime(void)
{
    timStart(timlowvoltage);
}
/*******************************************************************************

 $Function:  mainExit

 $Description:   exit MMI main module

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void mainExit (UBYTE InitCause)
{
    TRACE_FUNCTION("mainExit");

    startExit();
    sim_exit();                         /* finit SIM handler        */
    lngDelete(mainMmiLng); mainMmiLng = 0;

    // nm + 15.02.01
    // this timer is used for backlight
    // the B-Sample dont support backlight
    //    timDelete(tim); tim = 0;
    // nm -

    timDelete(times);
    timDelete(timer_Hnd);//gdy add 03/04/03
    //   nm 15.02.01
    //   the power off timer is not specified
    //   timDelete(timdown);timdown = 0;

    mmeDelete(mme); mme = 0;

    kbdAlways(0);
    dspl_ClearAll();


}

/*******************************************************************************

 $Function:  keyAction

 $Description:   handler called on every keyboard action

 $Returns:

 $Arguments:

*******************************************************************************/
static int keyAction (MfwEvt e, MfwKbd *res)
{
    T_RTC_DATE_TIME time_date;
    T_RV_RETURN path;
    char temp[100];
    int i;  /*2004/4/14, wangyan add*/

    //this function "keyAction" is called 4*times from MFW per each keypress
    // twice for keypress and twice for keyrelease
    // the variable "toggle" is using to avoid to play the keypadtone twice !
    static UBYTE toggle = TRUE;

    // this mask is use to filter the keyevent "e"
    // want to use KEY_0, KEY_1,......  KEY_HASH
    USHORT  mask = 0x0FFF;

    //TRACE_EVENT("zgz,keyAction");  // zgz , for trace
    //terminate the ringing in all situation (it doesnt matter where the user is
    //TraceMMIValueFunction("Key",e);
    //TraceMMIValueFunction("animation",animation_complete);

    /*zy 2003-04-04 if in callwin halloff return to idle */
		MMI_TRACE_EVENT(("wangyan keyAction e=%d; res->code=%d",e,res->code));
    if( (e & KEY_F4) )
    {

        if( !HallStatus() )
        {

//            if( (call_data.win)&&(!IsHandsetPlugin()) ) 
            if( (call_data.win)&&(!IsHandsetPlugin()) &&(!call_data.win_incoming)) /*2004/4/2, wangyan modify*/
            {

		/*if( call_data.win_incoming )
                {

                    saveRejNuminhalloff();
                    stopIncallLed();
                    SEND_EVENT(call_data.win_incoming,DIALOG_DESTROY,0,0);
                    call_data.win_incoming = 0;
                }*/
                /*begin of zy 2003-04-24 change if dial an switched off number then dial 
                a new number. hall off it willnot disconnect anyway*/
                /*2004/4/14, wangyan modify*/
                /*if( call_data.win_calling )
                {
                    cm_disconnect(call_data.outCall);
                }*/
                /*2004/4/14, wangyan modify*/
                i = 0;
		while (i<call_data.calls.numCalls)
		{
			if (call_data.calls.status[i].call_number!=singleCall)
			{
				if (!removeCall(call_data.calls.status[i].call_number))
					i++;

			}
			else
				i++;
		}
		/*2004/4/14, wangyan add*/
		/*2004/4/22, wangyan modify*/
                if( call_data.win_calling )
                {
                    cm_disconnect(call_data.outCall);
                }
                /*2004/4/22, wangyan modify*/

                /*end of zy change 2003-04-24*/
                TRACE_EVENT("key_hall will hangup all calls");
                RELEASEAllCALL();
   //             returntoidle();
                return 1;
            }
        }
    }
    /*end of zy change 2003-04-03*/

/*2004/4/2, wangyan add*/
	if( e & KEY_LONG )
	{
		if(!HallStatus() )
    		{
    			if( e & KEY_F3)
			{/*2004/04/08,talcon add for long KEY_F3 handle*/ 
				if(FlashSettingData.hallonconnect)
					incoming_call_kbd_long_KeyAction();
				else
				{
					MC_StopVibra();						// 2004.4.16 WYJ add
					StopPlayByReasonId(INCALL);
				}
					
				return MFW_EVENT_CONSUMED;
			}
			/*
			else if( e & KEY_VOLUP)
			{
				MMI_TRACE_EVENT(("sunsj---------------key volup"));
				LedLightnessAdjust(200);
				timStart(gtVibator);
				return MFW_EVENT_CONSUMED;
			}
			*/
		}
	}
 /*2004/4/2, wangyan add*/	

    if( (e & KEY_HUP) && (e & KEY_MAKE) )
    {

        UBYTE currentRinger = getCurrentRingerSettings();

        // terminate the ringing
        //Stopplayingdevice(); //xsf add 2002.08.12 MI18800000126
        //audio_StopSoundbyID( AUDIO_BUZZER, currentRinger );

    }

    //the power-off-key !
    if( (e & KEY_POWER) && (e & KEY_MAKE) && animation_complete )
    {
        TRACE_EVENT("KEY_POWER pressed !!!!");
        set_latest_alarm();

        AutoPowerOn();
        if( (pinsIsFocussed() EQ FOCUSSED_PINS) || idleIsFocussed() )
        {

            pin_exit();
			dspl_ClearAll();	//wyj MI18800000375
            //  if(pinsIsFocussed() EQ FOCUSSED_PINS)
            HUPKeyOrigin=1;
        }
        if( (hostkeyASKIsFocussed() EQ FOCUSSED_PINS) || idleIsFocussed() )
        {
            hostkey_exit();
            HUPKeyOrigin=1;
        }

        /* SH - check to make sure we're in idle screen before starting shutdown
        SPR877 - SH - also check that welcome animation is complete */

        if( HUPKeyOrigin==1 )
        {
            {
                /* 2004/07/09 sunsj add for forbidden hall off */
                HallOffForbid = TRUE;
#ifdef MMS_WAP_ENABLED
{
extern void mms_pushfile_exit();
	mms_pushfile_exit();
}
#endif

#ifdef _MMS_ENABLE_
	MMS_Exit();
#endif
                FfsWriteAllEvent();//hxl add for save file completely 20021125
                FieldTestExit();
                showGoodBye ( idle_get_window () ); //gb
				//2004-04-26 Synny remove
                //times_switchoff = timCreate(0,THREE_SECS,(MfwCb)goodbye_cb);
                //timStart(times_switchoff);
            }
        }
        deregis = FALSE;
    }
    HUPKeyOrigin = 0;

    //every other calls
    if( toggle )
    {
#ifdef SIM_TOOLKIT
        satEvtDownload(SatEvtUserAction);
#endif
        //"KEY_MAKE"  makes sure to call it only by keypress
        //xsf 2002.07.04 if ((FFS_flashData.settings_status & SettingsKeypadClick) && (e & KEY_MAKE))
        if( (FlashEnvironmentData.EnviroProfile[FlashEnvironmentData.CurrentEnv].KeypadTone) && (e & KEY_MAKE) )
        {
            TRACE_EVENT ("Keypad Click activ");
            //play KeypadClick
            //xsf 2002.08.05
            // StartKeyBeep();    //ganchh 2002/8/27
            //audio_PlaySoundID(0, TONES_KEYBEEP, 200, 0 );
        }
        //"KEY_MAKE"  makes sure to call it only by keypress
        else if( (FFS_flashData.settings_status & SettingsKeypadDTMF) && (e & KEY_MAKE) )
        {
            TRACE_EVENT ("Keypad DTMF activ");
            switch( e &= mask )
            {
            case KEY_0:
                audio_PlaySoundID(0, (TONES_DTMF_0), 0, 0 );
                break;
            case KEY_1:
                audio_PlaySoundID(0, TONES_DTMF_1, 0, 0 );
                break;
            case KEY_2:
                audio_PlaySoundID(0, TONES_DTMF_2, 0, 0 );
                break;
            case KEY_3:
                audio_PlaySoundID(0, TONES_DTMF_3, 0, 0 );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -