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

📄 mmisounds.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
/*******************************************************************************

          CONDAT (UK)

********************************************************************************

 This software product is the property of Condat (UK) Ltd and may not be
 disclosed to any third party without the express permission of the owner.

********************************************************************************

 $Project name: Basic MMI
 $Project code: BMI (6349)
 $Module:   Sounds
 $File:       MmiSounds.c
 $Revision:   1.0

 $Author:   Condat(UK)
 $Date:       25/10/00

********************************************************************************

 Description:

    This provides the implementation of the sounds for the basic MMI

    1. Playing various system sounds such as the paging ring,
       new sms message etc. 
    2. The menus used to enable or disable the system sounds
    3. The menu used to select the paging ring tone
    4. The menu used to select the volume.
    5. The menu used to select the key press tone or dtmf

  The mmi should play system sounds by calling soundExec with the appropriate
  SoundsXXXX message it is possible to go directly to the audio driver to play
  a sound but this will bypass any user settings to turn sounds on or off.

  The MelodySelect and SettingXXXX messages are used to control the key events
  during menu handling, entry to the sounds menus is through the soundsXXXX
  functions. These display the appropriate menu and handle the keypad events.

  The settings are read from PCM on startup and saved whenever a setting menu
  is selected.

********************************************************************************
 $History: MmiSounds.c

  25/10/00      Original Condat(UK) BMI version.

 $End

*******************************************************************************/
/********************************************************************************
 $History: MmiSounds.c

 04/08/02     zym   added audio funcion 
  22/07/02      zy Mobile Innovation make the sounds dialog has icon
  12/08/02    zym add 12/08/02 for control voice ampifier
  15/08/02    zy add hallonoff and speak volume
  29/08/02    zy change speak volume
 $End

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

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

                                Include Files

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

#define ENTITY_MFW

#define NEWAUDIO

/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#if defined (NEW_FRAME)

    #include "typedefs.h"
    #include "vsi.h"
    #include "pei.h"
    #include "custom.h"
    #include "gsm.h"

///added by dx
    #include "rv_general.h"
    #include "Audio_api.h"


#else

    #include "stddefs.h"
    #include "custom.h"
    #include "gsm.h"
    #include "vsi.h"

#endif
#include "mfw_sys.h"

#include "mfw_mfw.h"
#include "mfw_kbd.h"
#include "mfw_tim.h"
#include "mfw_lng.h"
#include "mfw_win.h"
#include "mfw_icn.h"
#include "mfw_sim.h"
#include "mfw_nm.h"
#include "mfw_edt.h"
#include "mfw_mnu.h"
#include "mfw_phb.h"
#include "mfw_sms.h"

#include "dspl.h"


#include "p_mmi.h"
#include "aci_cmh.h"
#include "mfw_mme.h"

#include "MmiMmi.h"

#include "MmiIcons.h"
#include "MmiPins.h"
#include "MmiMain.h"
#include "MmiDialogs.h"
#include "MmiIdle.h"
#include "MmiStart.h"
#include "MmiCall.h"
#include "MmiSimToolkit.h"
#include "gdi.h"
#include "Audio.h"
#include "MmiLists.h"
#include "MmiSounds.h"
#include "MmiResources.h"
#include "MmiTimeDate.h"

#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"
#include "MmiTimers.h"
#include "pwr.h"

#include "mmiutilapi.h"

#include "typedefs.h"

#include "melody_struct_i.h"
#include "melody_api.h"
#include "melody_env.h"

//#include "spi_drv.h"	/* Robert.Chen added, 2004-06-08, for access ABB API */

extern const int MelodyTable[14];

extern T_call call_data;
extern driver_Parameter drvpara; // added 09/10/02
extern uint8 SpeakerVols;
extern BOOL call_win_flag;// added 02/12/27
BOOL IncallLedisRun=FALSE;/*add 01-23-2003 for led incomingcall*/

/*glowing, 2003-12-20, comment the following statement */
//UINT8 g_HandsetPcsycMode = 0; 
/*******************************************************************************

                                Constant Definitions

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


/* Control FLUSH mechanism to PCM
*/
#define FLUSH 1
#define NO_FLUSH 0


/* Timer constants, pretty self explanatory
*/
#define TIMHALFSECOND 300 // 500
#define TIMSECOND   1000
#define TIM4SECOND      4000

#define VIBRATOR_TIME 2000  /* two second timer on the vibrator


/* Define a generic trace mechanism
*/
//#define PTRACE(prn) { char buf[64]; ## prn ##   TRACE_FUNCTION(buf); }
#define PTRACE(prn) { char buf[200]; ## prn ##   MMI_TRACE_EVENT(buf); }



/* Define maximum counter for vibrator
*/
#define VIBRATOR_COUNTER_MAX  4
#define NOT_VIBRATING     0


/* define an invalid tone marker
*/
#define INVALID_TONE  -1


//zym for vibrator

#define SET_BIT(REG,BIT)   (*((volatile unsigned short *) (REG)) |= (1 << (BIT)))
#define RESET_BIT(REG,BIT) (*((volatile unsigned short *) (REG)) &= ~(1 << (BIT)))
#define io_conf_reg_g       (0x0fffef00a)
#define io_cntl_reg_g        (0x0fffe4804)
#define armio_latch_out_g   (0x0fffe4802)
#define armio_latch_out_g   (0x0fffe4802)


UINT8 g_pcsyncstatus = 0;
UINT32 driverFlag=0x00000000;//defined for global Flag for driver 02/12/28
static char gChMelody_Name[20];
static unsigned char gChMelody_Looping;
static unsigned char waitToPlay=0;  
static unsigned char StopMelodyAgain=1;  //add for stop playing melody again when MelodyStop_cb() called 2003.03.03
//static UINT8 gCjMeloList2Free=0;//chenjun defined to remember hoe many list are alloced, we should free,2003-01-14
T_USER_RING tUserRing;

#ifndef _M188_
/* glowing,2004-06-16, this enum defines in mfw_ffs.h in M188, 
 * but in M288, these codes has been removed in mfw_ffs.h, 
 * so we move them to here
 */

/*
 Define the types of volume we cater for
*/
typedef enum
{
    silent = (UBYTE)0,
    volLow,
    volMedium,
    volHigh,
    increasing
}VOL_ENUM;
/* glowing,2004-06-12, end of import */
#endif

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

                            Local Function prototypes

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

static int winEvent( MfwEvt e, MfwWin *w );
static int keyEvent( MfwEvt e, MfwKbd *kc );
static int keyEventLong( MfwEvt e, MfwKbd *kc );

static void ( *show )( void );

static int playCurrentSound( MfwEvt e, MfwTim *tc );
static int getCallingMenu( MfwEvt e, MfwTim *tc );
static int setSelection( MfwEvt e, MfwWin *w );

static void delayThenPlayMelody( void );
static void stopPlayingMelody( void );

static void readSettingsFromPCM( void );
static void writeSettingsToPCM( UBYTE flush );

static void soundsCreate( MfwHnd parent );
static int VibratorTimerEvent( MfwEvt e, MfwTim *t );

void SetMelodyMode_aloud(void);
void SetHandsetMode(void);
void AudioFullAcessWrite(UINT8 varid, void* ptr);
void sounds (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
void sounds_dialog_cb(T_MFW_HND win, UBYTE identifier, UBYTE reason);
static void sounds_dialog(void);
static int sounds_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static int melody_win_cb (MfwEvt e, MfwWin *w);
void melody_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
void sounds_destroy (T_MFW_HND own_window);
T_MFW_HND sounds_create (T_MFW_HND parent_window);
void sounds_Exit (T_MFW_HND own_window);
T_MFW_HND sounds_Init (T_MFW_HND parent_window);
void MelodyList_cb(T_MFW_HND * Parent, ListMenuData * ListData);
static void melody_destroy(MfwHnd own_window);
void SetMVol_DownLinkPGA(UINT16 Amp);
void SetASpk_DownLinkPGA(UINT16 Amp);
void getVolSetting(UINT8 * amp);	/* Robert.Chen added, 2004-06-08 */

void SRReco_cb (void* parameter);
void SREnroll_cb (void* parameter);
void SRUpdate_cb (void* parameter);


#define SHOW_CONFIRM          3
#define ACTIVATE_CONFIRM       4
#define DEACTIVATE_CONFIRM     5


/* glowing: add it for new melody api */
UINT8 curMelodyId;  //for replacing the var currentringstr
int gPlayKeytoneFlag = 1;




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

                                Local typedefs

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

/* And the key tones
*/
typedef enum
{
    KEYTONE_NONE,
    KEYTONE_BEEP,
    KEYTONE_DTMF
} SoundsKeyTones;


/*  ------------- Variables ---------------   */

static SoundSettingState soundReason=SoundsNone;
// Change behavior of menu scroll up/down, meni item selected on scrolling.
static BOOL scrollSelectMenuItem= FALSE;
static BOOL volumeSetting2Pcm =FALSE;
static RINGER_STRUCT_BROWSER current =
{ // default settings.
    AUDIO_MEL_TUNES,  // ringer
    0,          // vibrator - off by default
    volMedium,      // volumeSetting
    2,          // keypadOn dtmf
    1,          // AlarmOn
    1,          // OrganiserAlert
    1,          // CreditLow
    1,          // SMSTone
    1,          // SMSBroadcast
    1,          // battLow
    3,          // earpiece
    1,          // language
    1         // Equalizer
};

const char UserRingIdStr[]="/meloe2/user/userid";//chenjun add for user ring index file 2003-01-15

typedef enum
{
    E_INIT = 0x0801,
    E_BACK,
    E_ABORT,
    E_EXIT,
    E_RETURN,
    E_OK
} e_M_events;

T_MELODY_INFO sounds_data;


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

                                Module local variables

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

static UBYTE oldVolumeSetting;     /* Previous setting of the volume      */
static MfwHnd win;                     /* our window              */
static MfwHnd kbd;                     /* our keyboard handler          */
static MfwHnd kbdLong;                 /* our keyboard handler for Long pressed    */
static MfwHnd hRingerStartTimer;         /* timeout till start of melody    */
static MfwHnd hRingerVolSettingTimeOut;   /* 4 second timeout for volume setting menu */

static MfwHnd hWinDispTimer;     /* timer to show result windows      */

/* Maintain vibrator state information here
*/
static MfwHnd VibratorTimer;
static UBYTE  Vibrating = NOT_VIBRATING;
static UBYTE  vibrator_counter=0;

/* General state information
*/
static MmiState nextState;
static MfwHnd lastFocus;

/* Tune details
*/
static int CurrentTune = 0;
static int LastTune = 0;

/*Globle varaible add by xsf  2002.06.26*/
UINT8    Gu8_Enviro_vol=0;//in enviroment setting adjust vol,1:in other place adjust vol
extern UINT8    Gu8_Envio_num;//enter which enviroment flag  
//extern UINT16  l_playing; 
//extern UINT16  vib_playing;  //xsf add 2002.08.12
//extern UINT16  ton_playing;
extern UINT8   melody_status;
extern UINT8   tone_status;
extern UINT8   vibra_status;
extern int     CurrentMode;  //xsf add 12.30
//UINT8 currentring=0; 
char currentringstr[20];
char oldringstr[20];   //xsf add 2002.09.06
INT8 e2_status;
//yq added for voicedial
static char  current_vd_file[20];
static char enrollname[10];
static unsigned char startenroll=0;
static unsigned char startupdate=0;
static unsigned char startdial=0;
//end yq added 
//Bob added 01/21
MfwHnd ledblink=0;
UBYTE ledblinkflag=0;
static UBYTE ledblinkison=1;
//Bob added to indicate Hall state 01/23
extern driver_Parameter drvpara;
//Bob added to indicate if incoming call or not 01/23
extern BOOL IncallLedisRun;
extern pwr_Status_Type    pwr_Status;
/* Menu definitions
*/
//static ST_MENU on_off_menu ;
//static ST_MENU dynamenu;
//static ST_MENU volume_menu;

//static ST_MENU_ITEM ONOFF_MENU_ITEMS[] = {
//  { 0, ST_PROMPT_MENU, TxtOff  },
//  { 1, ST_PROMPT_MENU, TxtOn   },
//  { 2, ST_PROMPT_MENU, TxtNull },

⌨️ 快捷键说明

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