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

📄 user.c

📁 凌阳SPDA1000 MP3开发资料
💻 C
📖 第 1 页 / 共 5 页
字号:
		//printf("backlight=%bx\n",gc_BacklightCount);
		if(gc_BacklightCount<0xf0)//if not permanence back light
		{
			//printf("gc_BacklightCount = %bx\n",gc_BacklightCount);
			if(gc_BacklightCount) gc_BacklightCount--;
			if(!gc_BacklightCount)
			{
//				BackLightOff;//turn off backlight
			}
		}
		if(!gc_Busy_Timer)
		{
			UI_Battery_Detect();
//			if(gc_USB_Connect)gc_Battery_Level=10;//lyh add
          //printf("gc_USB_Connect=%bu\n",gc_USB_Connect);
          //printf("gc_Battery_Level=%bu\n",gc_Battery_Level);
			{
				LCD501_Disp_Battery();				
			}
		}
		gc_Battery_Detect_Timer=16;//2s=0.125*16
	}
}
//===========================================================================================
void UI_Battery_Detect()
{
	U8 ADC_Value;
	U8 i;
//	U8 code ADC_Table[]=
//	{0x3e,0x46,0x4e,0x55,0x5f,0x67,0x6d,0x75,0x7c,0x85,0x8d,0x95,0x9c,0xa3,0xad};
	//0.7v0.8v 0.9v 1.0v 1.1v 1.2v 1.3v 1.4v 1.5v 1.6v 1.7v 1.8v 1.9v 2.0v 
	//ADC_Value=0xD0;
	ADC_Value=gc_BatteryValue;//L2_Read_SARADC(2);
	i=0;
	while(ADC_Value>=ADC_Table[i])
	{
		i++;
		if(i>=15) break;
	}
	gc_Battery_Level=i;
	//DbgPrint("ADC_Value=%bx\n",ADC_Value);
	return;
}
//===========================================================================================

//===========================================UI===================================================
//==============================================================================================
void UI_PreProcessor_scan_key(void)// lyh add
{
	gc_EVENT=gc_KeyValue;//gc_SPressingKey;//put the value to gc_EVENT,then,gc_SPressingKey=0.if shield the function--UI_GetShortOrLongKeyCode,gc_SPressingKey will always be 0;
 
	if (gc_KeyValue)
	{	
		gc_KeyValue = 0;
	}
	if ((gc_LongKeyDelay < (MAX_REPEATKEYDELAY - 3)) && (gc_EVENT == LONG_KEY_PLAY_EVENT))
	{//当按键不需要有长按键连发功能,必须在此将连发事件清除
		gc_EVENT = 0;
	}
//	printf("gc_EVENT=%bu\n",gc_EVENT);

//	if(LockPin_Locked)//is the lock event is happened or not?
	if(0)//is the lock event is happened or not? lss 060612
	{
		if(!gc_Menu_State && gc_KeyLockState==0)
		{
			LCD501_Disp_Icon_Lock(1);
		}
		gc_KeyLockState=1;//lock
	}
	else
	{
		if(!gc_Menu_State && gc_KeyLockState==1)
		{
			LCD501_Disp_Icon_Lock(0);
			gc_Busy_Timer=0;
		}
		gc_KeyLockState=0;//unlock			
	}

	if(gc_EVENT)
	{
		if(gc_UserBacklightLevel<5)
		{
			gc_BacklightCount = UserBackLightArray[gc_UserBacklightLevel];
//			BackLightOn;//GPIO1
		}
		gw_PowerOffTimer=USER_SetIdleTime[gc_USR_PowerOffCount];
		gb_DisplayEvent_Happened=1;
	}
#if 1
	if(gc_KeyLockState)//if lock key,then any key is pressing at gc_Menu_State,so show Icon.
	{
		if(gc_EVENT && !gc_Menu_State)
		{
			SPLC501_Disp_PowerOnLock();
			gb_ShowNowSongNumberFG=true;
			gc_Busy_Timer = 16;
		}
		gc_EVENT=0;
	}	
#endif
	gc_SPressingKey=0x00;
	if(gb_ShowNowSongNumberFG && !gc_Busy_Timer)//return to filename and time display
	{
		//printf("disp idle event\n");
		gb_DisplayEvent_Happened=1;
		gc_Menu_State=0;
	}
}
//================================================================================================
void UI_VolumeUpDown(bit tbt_UpDown)
{

	if(tbt_UpDown)
	{
		if(gc_DSP_Volume<=K_DSP_VolumeMax-3) gc_DSP_Volume+=3;
	}else{
		if(gc_DSP_Volume>=3) gc_DSP_Volume-=3;
	}
//	gc_the_CurrentDSP_Volume=gc_DSP_Volume;

	if(gc_SystemStateMode==SYSTEM_STATE1_PLAYING)//dsLONG_KEY_PLAY_EVENT
	{
		System_SetVolume(gc_DSP_Volume);
	}
	LCD501_Disp_VOL_LEVEL(gc_DSP_Volume);
	//gc_Busy_Timer = 16;             //two seconds
	//gb_ShowNowSongNumberFG=true;
	gb_UI_UserSeeting_Changed=1;
	gc_LongKey_Speed=4;

}
//================================================================================================
//at here delete a function to count the bitrate of mp3.UI_ASK_AudioCODEC_AboutMP3_Bitrate()
//================================================================================================
void UI_FastForBackward()//will get bitrate,seconds,then stop; get the new sector,new cluster;set the play
{ 
   // U16 tw_TotalSecond;//,liyonghua;	//lizhn modify the varible to be globe
	if(!gb_FastFFFR)
	{    
		gb_FastFFFR=TRUE;
        gc_SystemStateMode=STATE_FF;//lyh add
		System_FastForBackward();
		gw_TotalSecond = USER_GetMusicTotalTime();//get the totalsec.	
		//	printf("Currt=%x\n",G_Currtotalsecond);	
		//		printf("Total=%x\n",gw_TotalSecond);
		G_Currtotalsecond = UI_GetDispTimeFromDispBuf();//at here ,return the value of currentsec
		ForBackWord_SecondCount=0;//add by xyq    set the counter 0
	}
	//===================================
	//Fast forward&backward time's count
	//===================================
	if(gc_EVENT)
	{
		ForBackWord_SecondCount++;//add by xyq
		if(!(ForBackWord_SecondCount%6))
		{
			if(gc_LongKey_Speed<12) gc_LongKey_Speed++;//the speed increase if 6,12...
		}
	}

	if(gc_EVENT==LONG_KEY_FF_EVENT)
	{
		G_Currtotalsecond += 1;
		//printf("Currt=%x\n",G_Currtotalsecond);	
		//printf("Total=%x\n",gw_TotalSecond);
		UI_SetDispTimeToDispBuf(G_Currtotalsecond);
		if(G_Currtotalsecond>gw_TotalSecond || ((gc_PlaySequenceMode == 0x04) && (G_DISPLAY_TotalSec>10)))
		{

			gc_SystemStateMode=SYSTEM_STATE0_IDLE;//goto play_state
			gb_FastFFFR=FALSE;
			gb_FFFRHoldToPlay=1;
			return;
		}
	}
	else if(gc_EVENT==LONG_KEY_FR_EVENT)
	{
		G_Currtotalsecond -= 1;
		UI_SetDispTimeToDispBuf(G_Currtotalsecond);
		if(G_Currtotalsecond<=0)
		{
			gc_SystemStateMode=SYSTEM_STATE0_IDLE;
			gb_FastFFFR=FALSE;
			gb_FFFRHoldToPlay=1;
			return;
		}
	}
	//==========================
	//Count the current Min&Sec
	//==========================
	G_DISPLAY_TotalSec = G_Currtotalsecond;//so the two variables ,in fastward,G_Currtotalsecond increasing fast!DSP should stop!
	//====================================
	//test release point and restart play
	//====================================
	if((gc_EVENT == LONG_KEY_FF_RELEASE_EVENT) || (gc_EVENT == LONG_KEY_FR_RELEASE_EVENT)) //if the key released
	{
        if(gb_FastFFFR)
        {
        gb_FastFFFR=0;
    	System_FileFixPoint(G_Currtotalsecond);
//liyonghua=
        UI_GetDispTimeFromDispBuf();

        }
		gc_SystemStateMode=SYSTEM_STATE1_PLAYING;//change state ff to play
		gb_FastFFFR=FALSE;
		gc_LongKey_Speed=9;//add by xyq,reset speed
	} 
}
//================================================================================================
void LED_Blink(void)
{
	if((!gc_BlinkTimer) || (!G_USBReadWriteCount))//turn on LED
	{
		G_USBReadWriteCount=2;
		gc_BlinkTimer=9;//LED OFF 3*125mS//by lixt
//		if(G_Powerstate==0x02)
		{
			//G_LED_Blink_On_Timer=5;//LED OFF 3*125mS
			SPLC501_Disp_MusicLogo(_G_USBReadOrWrite_ForUI);
		}
	}

}
//================================================================================================
unsigned int xdata G_APointSeconds;//if G_APointSecond will cause multi error.so --s.
void Rep_AB() USING_0//in void Audio_CoDec(void) USING_0 to judge is at b point
{	
   	switch(gc_AB_Cnt)
   	{   		
		case 0:  //repeat A playing   get the lrctime and the resdiual sectornum of a G_ASectorNUM = L2_DSP_Read_DMem16(DSP_ResBuffer); 
			#ifdef Support_LRCFile
			if((gc_LrcFileName_Exist))
			{
				G_APointLRCStartSecond = gw_LrcRecentTime;//lyh delX_G_LRC_RecentLRCTime;//show  the lrc time
			}
			#endif//#ifdef Support_LRCFile
//			G_DelayFrameCounter = 0;
			LCD501_Disp_Apoint(ON);
			System_SetRepeatAB(gc_AB_Cnt);
            gc_AB_Cnt=1;//lyh add
			break;
		case 1:  //repeat B playing,but at b point will get the all sector
			if(System_SetRepeatAB(gc_AB_Cnt) == gc_AB_Cnt)//for wma very short AB repeat BUG
			{//if set B point is fail, return to A point
				gc_AB_Cnt=1;
				break;
			}
//			G_AsearchCluster = USR_File_Seek(G_ASectorNUM); // Keep the Current searchCluster
//			Rep_AB_Goto_Apoint_To_Play(0);//go to a point to play,0 need stop or not
//          System_SetRepeatAB(3);
			LCD501_Disp_Bpoint(ON);///show point b icon
            gc_AB_Cnt=2;//lyh add
			break;
		case 2:  //Clear A-B Play
            LCD501_Disp_Apoint(OFF);LCD501_Disp_Bpoint(OFF);
			//LCD501_Disp_ABPoint(0);
			System_SetRepeatAB(gc_AB_Cnt);
            gc_AB_Cnt=0;//lyh add
			gc_fileend = 0;
			break;
        default:
    		break;
   	}
}
//================================================================================================
void UI_Close_File()//when SYSTEM_STATE0_IDLE,file_close(NULL, K_DOS_ReadFile, 0)
{
	if(gc_SystemStateMode!=SYSTEM_STATE0_IDLE)
	{
		System_Stop();//some question for don't know the detail of the function.
   		if(_WMA)
		{
			_WMA=0;                //@@chchang_012803
		}
	}
}
//================================================================================================
void Playing_To_Stop()//set some paramter ,SYSTEM_STATE0_IDLE,included gc_Play_Pause_Stop_State=2;SYSTEM_STATE0_IDLE;gc_USR_PowerOffCount=USER_SetIdleTime[gc_USR_PowerOffCount];
{
	UI_Close_File();

	gc_Play_Pause_Stop_State=2;//this variable just in the user.c
	gc_SystemStateMode=SYSTEM_STATE0_IDLE;
	gw_PowerOffTimer=USER_SetIdleTime[gc_USR_PowerOffCount];//if in the SYSTEM_STATE0_IDLE,after the time to poweroff
    gb_USB_PowerPlug_Interrupt=0;
}
//================================================================================================
void UI_Exe_Format()//show format...
{
	LCD501_Disp_IconMenu(S_Del_Disk_FORMATProg);//"FORMAT ...  "

    DOS_Format();//not make sure this function is realized all the functions.
	gc_DOS_ErrorStatus = 0;//must clear dos error status for SearchFreeCluster(040904 add)

	#if (K_CARD_TYPE == 0x03)
	if (gc_DOS_ErrorStatus = SD_STORAGE_Initialize())//try to initialize SD card
	#endif
	{//if SD card is not exist		
		gc_DOS_ErrorStatus = SMC_STORAGE_Initialize();//try to initialize SMC
	}
	//while(1);
    gw_FileTotalNumber[0]=0;
    gw_FileTotalNumber[1]=0;
    gw_FileTotalNumber[2]=0;
	gw_FileIndex[0]=0;//clear file index after format(040830 lzp add)
	gw_FileIndex[1]=0;
	gb_Storage_Full = 0;
	UI_SetDispTimeToDispBuf(0);//clear time
	gdw_USER_DirClus[0] = 0;
	USER_Create_Dir(0,gdw_DOS_RootDirClus);//create DVR	
	gc_KeyValue = 0;//clear key
    LCD501_Clear_ALL();
}
//================================================================================================
void UI_Disp_Page0()//the volume,the lock,abpoint,eq,playeq,battery
{
//	SPLC501_Erase_OnePage(0);
	LCD501_Disp_VOL_LEVEL(gc_DSP_Volume);
	LCD501_Disp_Icon_Lock(gc_KeyLockState);
	LCD501_Disp_ABPoint(gc_AB_Cnt);
	LCD501_Disp_REP1ALL(gc_PlaySequenceMode);
	LCD501_Disp_DSPEQ(gc_PlayEQMode);
	LCD501_Disp_Battery();
}
//================================================================================================
U8 UI_StorageIsError()//show the icon storageerror if gc_DOS_ErrorStatus=1,return 1
{
	if(gc_DOS_ErrorStatus)
	{
		gw_FileTotalNumber[gc_UIMode]=0;//there are no mp3 and dvr's files existed
		gw_FileIndex[gc_UIMode]=0;//hxd030711 add
		LCD501_Disp_StorageError(gc_DOS_ErrorStatus);
		gb_DisplayEvent_Happened=0;
		return 1;
	}else{
			return 0;
	}
}
//================================================================================================
void UI_GetMusicInfo()//lyh add
{
     U8 tc_returnvalue;//,i;
//printf("gc_UIMode=%bu\n",gc_UIMode);
     if(gc_UIMode==0)
     {
//	  	U8 i;
	  

⌨️ 快捷键说明

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