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

📄 common.c

📁 智原mp3 SDK 开发包 与巨力 有mp3 wma ogg decoder
💻 C
字号:
/*******************
 *  common.c
 *******************/
#include <string.h>
#include "api.h"
#include "lcd.h"
#include "common.h"
#include "display.h"
#include "ap_common.h"
#include "prefer.h"
#include "global_user.h"
#include "res.h"
#include "res_show.h"
#include "movie_utile.h"
 
UINT32 u16TimerCount=0; 
 
MUSIC_INFORMATION curr_music;
UINT16 curr_lyric_time;

INT8U _buf[256];
INT8U vol_flag=0;
FILE_INFORMATION curr_finfo, curr_dir, play_dir;
SCREENLEVEL screen_level;

UINT16 select;

UINT16 totdir, totfile, totitem;
UINT8 *search_extstr;


BOOLEAN bHotKeyHandle(UINT8 ekey)
{

    	//api_bStop();
    	switch(ekey)
    	{
       		case KEY_LONG_MENU:     
       			key_menu_long = 1;
     			api_bStop();  
			lcd_set_disply_mode(0x00,0x22);
        		api_bSavePreferenceData(&tUserPreference,sizeof(USER_PREFERENCE_T));
        		//close_volume();
#ifdef dynamic_load
			api_vLoad(Code_USER1,1);
#else
			Print("Load Function\n");
#endif							
			break;
		case KEY_LONG_PLAY:	
     			api_bStop();     					    
		    	lcd_set_disply_mode(0x00,0x22);
		    	api_bSavePreferenceData(&tUserPreference,sizeof(USER_PREFERENCE_T));
		    	vShutDown();
		    	break;		  		    	
	    	default:
	    		return FALSE;
	}
}

void key_process(UINT8 key)
{
	u16TimerCount=0;
	
	//vOpenBackLight();
	if(bLCD_PIN_BACKLIGHT && key!=KEY_EOS)
		return;
	//if()	
		
	//now handle hot key
	bHotKeyHandle(key);
	
	//deal other key now.
	if(curr_screen->main)
		curr_screen->main(key);
}

void get_short_name(FILE_INFORMATION *pfinfo, UINT8 xdata *buf)
{
	UINT8 xdata *name = pfinfo->pu8FileName;
	UINT8 xdata *ext = pfinfo->pu8FileExt;
	BOOLEAN flags = false;
	
	while(1) 
	{
		if(*name == '\0' || *name == ' ')
			break;
		*buf++ = *name++;
	}
	
	*buf++ = '.';
	
	while(1) {
		if(*ext == '\0' || *ext == ' ')
			break;
		*buf++ = *ext++;
		flags = true;
	}
	
	if(!flags)
		buf--;
		
	*buf = '\0';
}

void get_long_name(FILE_INFORMATION *pfinfo, UINT8 xdata *buf)
{
	UINT16 xdata *name = (UINT16 xdata *)pfinfo->pu8LongFileName;
	
	while(*name != 0) {
		buf[0] = ((UNION16 *)name)->v8[1];
		buf[1] = ((UNION16 *)name)->v8[0];
		
		if(*(UINT16 *)buf >= 'a' && *(UINT16 *)buf <= 'z')
			*(UINT16 *)buf = *(UINT16 *)buf - 'a' + 'A';
			
		name++;
		buf += 2;
	}

	*(UINT16 *)buf = 0;
}


BOOLEAN change_dir(FILE_INFORMATION *pDir)
{
	if(pDir)
		memcpy(&curr_dir, pDir, sizeof(FILE_INFORMATION));
	else
		curr_dir.u32startclus = 0;	// ROOT dir
	
	return api_bChangeDir(pDir);
}

void scan_dir_file(UINT8 search_mode, UINT8 *extstr, BOOLEAN select_dir)
{
	select = totitem = totdir = totfile = 0;
	
	if(api_bSearchDirInDir(search_mode))
		totdir = api_u16GetTotalFile();
	
	if(api_bSearchFileInDir(search_mode, extstr))
		totfile = api_u16GetTotalFile();
	
	if(select_dir && totdir)
		if(!api_bSearchDirInDir(SEARCH_MODE_CURRDIR))
			return;
	
	totitem = totdir + totfile;
	search_extstr = extstr;
}

BOOLEAN playdir_valid()
{
	if(curr_dir.u32startclus != play_dir.u32startclus)
		return false;
	else
		return true;
}

BOOLEAN init_volume(void)
{	
	//*(INT8U xdata*)(0xF96E) = 0x00;	
	api_bSetVolume(tUserPreference.u8Volume);	
    	return 1;
}

BOOLEAN close_volume(void)
{	
	api_bSetVolume(0-api_s8GetVolume()); 
	//*(INT8U xdata*)(0xF96E) = 0x03;	
    	return 1;  	
}


//--------------------------------------------------------------------------
void vKeyTimeOut(void)
{
	if (u16TimerCount == 0) 
	{
	    if (tUserPreference.u8BackLightTime!=0) 
	        vOpenBackLight();
	}
	u16TimerCount++;
	if((u16TimerCount>=tUserPreference.u8BackLightTime*4) && (tUserPreference.u8BackLightTime>0))
		vCloseBackLight();
	
	if((u16TimerCount>=tUserPreference.u8ShutDownTime*240) && (tUserPreference.u8ShutDownTime>0))
		vShutDown();

}

void vShutDown()
{
	INT16U i;	

    api_bSetVolume(0-api_s8GetVolume());
	for(i=0;i<9;i++)
	{
		delay(20);
		bResShowPic(GJI01+i,0,0);			
	}

	delay(20);
    vCloseBackLight();
    lcd_clear();
	delay(20);

	api_bSetPowerDownMode(POWER_DOWN_ADDA_OFF);
	delay(200);
	b_PIN_POWEROFF = 0;
    while(1){;}
}

void vOpenBackLight(void)
{
         bLCD_PIN_BACKLIGHT = 0;
}

void vCloseBackLight(void)
{
         bLCD_PIN_BACKLIGHT = 1;
}

⌨️ 快捷键说明

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