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

📄 mmisounds_v1.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
 $End

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

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

                                Include Files

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

#define ENTITY_MFW

/* 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 zym
#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"



extern char* MelodyTable[];
extern T_call call_data;
/*******************************************************************************

                                Constant Definitions

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


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


/* Timer constants, pretty self explanatory
*/
#define TIMHALFSECOND 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_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)




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

                            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 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);

///zym
void Initial_AuxSpeaker(void);

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
///zym
#define zymTOGBR1 (0x04)
#define zymTOGBR2 (0x05)
#define zymVBCR    (0x08)
#define zymVBUR    (0x07)
#define zymVBDR    (0x06)


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

                                Local typedefs

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

/* Define the types of volume we cater for
*/
typedef enum {
   silent = (UBYTE)0,
   volLow,
   volMedium,
   volHigh,
   increasing
} VOL_ENUM;


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


/* The following definition provides a structure to control the
   ringing operation
*/

typedef struct MMI_CURRENT_RINGER_STRUCT {
                      /* variable to browse a list */
  UBYTE ringer;             // index of permanent active tune in soundlist and ringerItem
  UBYTE vibrator;             // vibrator
  UBYTE volumeSetting;          // values (0 = silent, 4= loud, 5 = increasing)
  UBYTE keypadOn;             // on/off values
  UBYTE AlarmOn;
  UBYTE OrganiserAlert;
  UBYTE CreditLow;
  UBYTE SMSTone;
  UBYTE SMSBroadcast;
  UBYTE battLow;
  UBYTE earpiece;
  UBYTE language;
  UBYTE Equalizer;
} RINGER_STRUCT_BROWSER;

/*  ------------- 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
};

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;

/* Define a default state for the ringer, this will control the
   power up state for the ringer and will be modified as required
   during normal operation
*/
//static RINGER_STRUCT_BROWSER current =
//{
//nm  AUDIO_MEL_TUNES,  // ringer
//  0,          // vibrator
//nm  volMedium,      // volumeSetting
//  2,          // keypadOn dtmf
//  1,          // AlarmOn
//  1,          // OrganiserAlert
//  1,          // CreditLow
//  1,          // SMSTone
//  1,          // SMSBroadcast
//  1,          // battLow
//  3         // earpiece
//};


/* PCM Related control structures
*/
//static drv_Return_Type pcmResult;
//static pcm_FileInfo_Type pcmFileInfo;


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


/* 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 },
//};

//nm static ST_MENU_ITEM VOLUME_MENU_ITEMS[] = {
//nm  { silent,   ST_PICTURE_MENU, VOLUME_ICON_SILENT   },
//nm  { volLow,   ST_PICTURE_MENU, VOLUME_ICON_LOW    },
//nm  { volMedium,  ST_PICTURE_MENU, VOLUME_ICON_MEDIUM   },
//nm  { volHigh,    ST_PICTURE_MENU, VOLUME_ICON_HIGH   },
//nm  { increasing, ST_PICTURE_MENU, VOLUME_ICON_INCREASING }
//nm};


/* Provide a mapping between keys and their associated DTMF tones
*/
//nmstatic const keytonemap[][2] = {
//nm  { KEY_0,       TONES_DTMF_0    },
//nm  { KEY_1,       TONES_DTMF_1    },
//nm  { KEY_2,       TONES_DTMF_2    },
//nm  { KEY_3,       TONES_DTMF_3    },
//nm  { KEY_4,       TONES_DTMF_4    },
//nm  { KEY_5,       TONES_DTMF_5    },
//nm  { KEY_6,       TONES_DTMF_6    },
//nm  { KEY_7,       TONES_DTMF_7    },
//nm  { KEY_8,       TONES_DTMF_8    },
//nm  { KEY_9,       TONES_DTMF_9    },
//nm  { KEY_STAR,    TONES_DTMF_STAR },
//nm  { KEY_HASH,    TONES_DTMF_HASH },
//nm  { KEY_MNUUP,   TONES_DTMF_A    },
//nm  { KEY_MNUDOWN, TONES_DTMF_A    },
//nm  { KEY_LEFT,    TONES_DTMF_B    },
//nm  { KEY_RIGHT,   TONES_DTMF_C    },
//nm  { KEY_CLEAR,   TONES_DTMF_D    },
//nm  { 0,           INVALID_TONE    }
//nm};
//nm
static MfwMnuAttr melody_menuAttrib =
{
    &melody_menuArea,
    MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu       */
    -1,                                 /* use default font         */
    NULL,                               /* with these items         */
    0                                   /* number of items     */
};


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

                                Private Methods

*******************************************************************************/
USHORT getSoundsReason(void)
{
  return soundReason;
}
/*******************************************************************************

 $Function:     setSoundsReason

 $Description:  Set the reason why the volume settings was invoked. Called to indicated
        that the volume settings is being invoked from Idle or from the incoming
        call screens.

 $Returns:    none

 $Arguments:  none

*******************************************************************************/
void setSoundsReason(USHORT reason)
{

  switch(reason)
  {
   case SettingVolume:
    soundReason = SettingVolume;
    break;
   case SoundsNone:
   default:
    soundReason = SoundsNone;
    break;
  }
}
/*******************************************************************************

 $Function:     volMenuItemSelected

 $Description:  A volume menu item has been selected, store the setting into PCM.

 $Returns:    none

 $Arguments:  none

*******************************************************************************/
void volMenuItemSelected(void)
{
  volumeSetting2Pcm =TRUE;
}
/*******************************************************************************

 $Function:     getScrollSelectMenuItem

 $Description:  get the scroll/select menu status.

 $Returns:    Status

 $Arguments:  none

*******************************************************************************/
BOOL getScrollSelectMenuItem(void)
{
  if (scrollSelectMenuItem == TRUE)
    return TRUE;
  else
    return FALSE;
}
/*******************************************************************************

 $Function:     clearScrollSelectMenuItem

⌨️ 快捷键说明

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