UI_PSF_hisi.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002                            C   M O D U L E   F I L E
00003 
00004     Copyright (c) 2003 Neuros Audio LLC, All rights reserved.
00005 
00006 ******************************************************************************/
00007 
00024 
00025 /*-- HEADER FILE INCLUDES ---------------------------------------------------*/
00026 #include "../SYSTEM/sys_main.h"
00027 #include "../SYSTEM/sys_hardware.h"
00028 #include "../SYSTEM/sys_clock.h"
00029 #include "../AUDIO/audio.h"
00030 #include "../encoder/encoder.h"
00031 #include "../coder/coder.h"
00032 #include "../BATTERY/battery.h"
00033 #include "ui.h"
00034 
00035 
00036 /*-- LOCAL DEFINITIONS ------------------------------------------------------*/
00037 // Record file creation error code definition.
00038 typedef enum 
00039 {
00040     HFC_NULL,
00041     HFC_DISKFULL,
00042     HFC_SUCCESS
00043 } HFC_ERR;
00044 
00045 static HFC_ERR _createHisiFile(char *, ES_SOURCE);
00046 static void _loadHisiTmplt(const char *, int);
00047 static void _stopHisi(void);
00048 static void _cancelHisi(void);
00049 static void _updateHisiTime(ULONG);
00050 
00051 /*-- STATIC DATA ------------------------------------------------------------*/
00052 static HMENU            menu = INVALID_MENU_HDL;
00053 //DeepB
00054 //static USHORT         iconCount;
00055 
00056 /*-- GLOBAL DATA ------------------------------------------------------------*/
00057 
00058 /*-- FUNCTIONS --------------------------------------------------------------*/
00059 #pragma CODE_SECTION(UI_PSF_hisi, ".hisi_code")
00068 PARENT_STATE UI_PSF_hisi( st_MSG * msgIN )
00069 {   
00070     MSG_ID          id = msgIN->id;     
00071     MSG_DATA        d1 = msgIN->d1; 
00072     MSG_DATA        d2 = msgIN->d2;
00073 //DeepB
00074 /*
00075     ULONG           hisiIconList[12] = {    
00076                         (ULONG)graf_icon_hisi1,
00077                         (ULONG)graf_icon_hisi2,
00078                         (ULONG)graf_icon_hisi3,
00079                         (ULONG)graf_icon_hisi4,
00080                         (ULONG)graf_icon_hisi5,
00081                         (ULONG)graf_icon_hisi6,
00082                         (ULONG)graf_icon_hisi7,
00083                         (ULONG)graf_icon_hisi8,
00084                         (ULONG)graf_icon_hisi9,
00085                         (ULONG)graf_icon_hisi10,
00086                         (ULONG)graf_icon_hisi11,
00087                         (ULONG)graf_icon_hisi12};   
00088 */
00089     switch(id)
00090     {
00091     case SYS_MSG_ID:
00092         
00093         switch(d1)
00094         {
00095             case SSTATE_START:
00096             {
00097                 SYS_clockSetup(CLOCK_MP3RECORD);
00098                 BAT_setLowThreshold(0x3A66); //3.65V*4096.
00099                 
00100                 ENCODER_setSource((ES_SOURCE)d2);
00101                 
00102                 Audio.freeSpace = FAT_freeSpace(SYS_isHDDpresent()?DISK_C:DISK_D);
00103                 if(Audio.freeSpace < DISK_RESERVED_SPACE)
00104                 {
00105                     UI_msgbxCreate(MSGBX_DISKFULL);
00106                     return P_HISI;
00107                 }
00108                 
00109                 if(HFC_SUCCESS != _createHisiFile(Ui.path, (ES_SOURCE)d2))
00110                 {
00111                     return P_NULL;
00112                 }
00113                 
00114                 AUDIO_initInterface((AUDIO_MODE)ENCODER_getAudioMode((USHORT)d2), 
00115                                     AF_MP3, 0, 0);
00116                 AUDIO_setInterface(AI_START);
00117                 
00118                 _loadHisiTmplt(Ui.fname, (int)d2);
00119                 menu = mMENU_create((void *)&MENU_buf[0]);
00120                 _updateHisiTime(30);
00121                 TMR_create(TMR_HISI, 10, THISIANIMATION, 0, AUTO_RELOAD);
00122 //DeepB
00123 //              iconCount = 0;
00124 
00125                 return P_HISI;
00126             }
00127             case SSTATE_END:
00128             {
00129                 _cancelHisi();
00130                 return P_NULL;
00131             }
00132             case SAUDIOTIME_UPDT:
00133             {
00134                 if(30 < SYS_getCurRecordDuration())
00135                 {
00136                     _stopHisi();
00137                     return P_HISIDONE;
00138                 }
00139                 _updateHisiTime(30-SYS_getCurRecordDuration());
00140                 return P_HISI;
00141             }
00142             case SMSGBOX_EXIT:
00143             {
00144                 if(MENU_curMsgbx() == MSGBX_CANCELHISI)
00145                 {
00146                     if(BTN_YES == d2)
00147                     {
00148                         _cancelHisi();
00149                         return P_NULL;
00150                     }
00151                 }
00152                 else if(MENU_curMsgbx() == MSGBX_DISKFULL) 
00153                 {
00154                     SYS_usbEnabled();
00155                     SYS_recordNotActive();
00156                     return (Audio.mode == AM_RECFM) ? P_RADIO: P_NULL;
00157                 }
00158                 
00159                 break;
00160             }
00161         }   
00162         break;
00163     
00164     case TMR_MSG_ID:
00165         switch(d1)
00166         {
00167             case THISIANIMATION:
00168             {
00169                 ULONG   dptr;
00170                 // Update recorder icon display if not paused.
00171 //DeepB
00172 //              if(++iconCount >= 12) iconCount = 0;
00173 //              dptr = hisiIconList[iconCount];
00174 //              mMENU_update(menu, 3, dptr, FALSE);
00175                 mMENU_refresh(menu);                    
00176                 break;
00177             }
00178         }
00179         break;
00180         
00181     case KBD_MSG_ID:
00182         switch(d1)
00183         {
00184             case KEY_BACK:
00185             case KEY_HBACK:
00186             case KEY_HISI:
00187                 UI_msgbxCreate(MSGBX_CANCELHISI);
00188                 return P_HISI;
00189 
00190         }
00191         break;
00192     }
00193     
00194     return P_HISI;
00195 }
00196 
00197 
00198 
00199 #pragma CODE_SECTION(_loadHisiTmplt, ".hisi_code")
00200 // Function loads the recorder tmplate data.
00201 static void _loadHisiTmplt( const char * pFname, int src )
00202 {
00203 
00204     MENU_buf[0] = DP_HISI;
00205     
00206     // data structure.
00207     // 0:   file name data pointer.
00208     // 1:   audio source
00209     MENU_buf[1] = (int)pFname;  
00210     MENU_buf[2] = src; 
00211 }
00212 
00213 #pragma CODE_SECTION(_createHisiFile, ".hisi_code")
00214 // Function creates the record file.
00215 static HFC_ERR _createHisiFile(char * fname, ES_SOURCE source)
00216 {
00217     char *       pC;
00218     char         strHISIDIR[16];
00219     
00220     GEN_readXstr((ULONG)text_hisiDir, (USHORT*)strHISIDIR, 16);
00221     
00222     if(SYS_isHDDpresent())  strcpy(fname, strDISKC);
00223     else                    strcpy(fname, strDISKD);
00224     
00225     strcat(fname, strHISIDIR);
00226     Ui.fname = Ui.path + strlen(strHISIDIR) + 4;
00227     pC = Ui.fname-1;
00228     *pC++ = '/';
00229     *pC++ = 'H';
00230     *pC++ = 'i';
00231     *pC++ = 'S';
00232     *pC++ = 'i';
00233     // Add source identifier.
00234     switch( source )
00235     {   
00236     case ES_RADIO:
00237         // Station to string.
00238         pC += GEN_int2ASCII( sysParam.station, pC, FALSE, 0);   
00239         *pC++ = ' ';
00240         break;
00241 
00242     case ES_LINEIN:
00243         *pC++ = 'L';
00244         *pC++ = 'i';
00245         *pC++ = 'n';
00246         *pC++ = 'e'; 
00247         *pC++ = ' ';        
00248         break;
00249         
00250     case ES_MIC:
00251     default:        
00252         *pC++ = 'M';
00253         *pC++ = 'i';
00254         *pC++ = 'c';
00255         *pC++ = ' ';
00256         break;
00257     }
00258     
00259     // Get current time.
00260     pC   += UI_currentTimeString(pC);   
00261     *pC++ = '.';
00262     *pC++ = 'm';
00263     *pC++ = 'p';
00264     *pC++ = '3';
00265     *pC = 0;
00266 
00267     if (SYS_isHDDpresent()) FAT_cd(strDISKC);
00268     else                    FAT_cd(strDISKD);
00269                 
00270     if(FAT_cd(strHISIDIR) == FALSE)
00271     {
00272         if( FALSE == FAT_mkdir(strHISIDIR))     return HFC_NULL;
00273         if( FALSE == FAT_cd(strHISIDIR))        return HFC_NULL;    
00274     }
00275 
00276     if(NULL == FAT_bfopen(Ui.fname, wb, &Audio.file)) return HFC_NULL;
00277     
00278     return HFC_SUCCESS;
00279 }
00280 
00281 
00282 #pragma CODE_SECTION(_stopHisi, ".hisi_code")
00283 // Function stops current recording.
00284 static void _stopHisi(void)
00285 {
00286     TMR_delete(TMR_HISI);
00287     BAT_setLowThreshold(0x3999); //3.60V*4096.
00288     
00289     mMENU_action(menu, MENU_CLOSE); 
00290     mMSG_send(uiChildMsgQ, SYS_MSG_ID, SSTATE_END, DONTCARE, SYS_FOREVER);          
00291     AUDIO_setInterface(AI_SHUTDOWN);
00292     FAT_fclose(&Audio.file);
00293 }
00294 
00295 #pragma CODE_SECTION(_cancelHisi, ".hisi_code")
00296 // Function cancels current hisi recording.
00297 static void _cancelHisi(void)
00298 {
00299     _stopHisi();
00300     FAT_delete(Ui.path);
00301     
00302     if (SYS_isHDDpresent()) HDD_setPowerMode(HDD_POWEROFF, 0);
00303 }
00304 
00305 #pragma CODE_SECTION(_updateHisiTime, ".hisi_code")
00306 // Function updates the hisi time display.
00307 static void _updateHisiTime(ULONG t)
00308 {
00309     char    strDuration[16];
00310     GEN_createTimeString(t, strDuration);           
00311     mMENU_update(menu, 4, (ULONG)strDuration, FALSE);
00312     mMENU_refresh(menu);
00313 }
00314 
00315 /*****************************************************************************
00316                 Neuros Audio LLC. Confidential Proprietary
00317  *****************************************************************************/

Generated on Wed Jan 19 01:12:45 2005 for neuros-firmware by  doxygen 1.3.9.1