📄 musicbrowserapi.c
字号:
// 1 : short file name
// 2 : long file name
// Output: none
//
// Description: show file(folder) name
//
//***************************************************************************
void _music_show_name(uint8 result, uint8 index)
{
if(result == 1) //show short file name
{
//API_LcmSetLanguage(CS_BIG5);
API_LcmShowString(sfnPtr,POS_MUSBRO_FN_X,POS_MUSBRO_FN_Y+(index*POS_MUSBRO_FN_GAP_Y));
}
else if(result == 2) //show long file name
{
API_LcmSetLanguage(CS_UNICODE);
API_LcmShowString(lfnPtr,POS_MUSBRO_FN_X,POS_MUSBRO_FN_Y+(index*POS_MUSBRO_FN_GAP_Y));
if(language == 2)
API_LcmSetLanguage(CS_GBK);
else
API_LcmSetLanguage(CS_BIG5);
}
}
//***************************************************************************
// Func: void _music_show_item_icon(uint8 type, uint8 index, int16 file_curr_paint_item)
// Input: type
// return icon : 0
// folder : 1
// file : 2
// play icon : 3
//
// index (0~5) 6 frame
// ile_curr_paint_item : current file
// Output: none
//
// Description: show item icon
//
//***************************************************************************
void _music_show_item_icon(uint8 type, uint8 index, int16 file_curr_paint_item)
{
uint8 result;
uint16 string_ptr;
string_ptr = (uint16)lfnPtr;
// show selection bar and clean previous bar
if(index == file_curr_sel_icon)
{
API_LcmPutSysImage(IMG_SELECT_BAR,POS_MUSBRO_SEL_X,POS_MUSBRO_SEL_Y+(index*POS_MUSBRO_SEL_GAP_Y));
// show source icon
if(nand_sd_flag == FAT_IS_NAND)
API_LcmPutSysImage(IMG_SMALL_ICON_HD_NORMAL,POS_MUSBRO_ICON_X,POS_MUSBRO_ICON_Y);
else
API_LcmPutSysImage(IMG_SMALL_ICON_SD_NORMAL,POS_MUSBRO_ICON_X,POS_MUSBRO_ICON_Y);
//clean music number
API_LcmPutSysImage(IMG_NUMBER_BG,POS_MUSBRO_NUM_X,POS_MUSBRO_NUM_Y);
//if(file_curr_paint_item>0)
if(type > ICON_RETURN)
{
// show current number
API_LcmShowNumber2B(file_curr_paint_item,POS_MUSBRO_NUM_X,POS_MUSBRO_NUM_Y);
API_LcmShowNumber2B((Folders+Files),POS_MUSBRO_NUM_X+40,POS_MUSBRO_NUM_Y);
API_LcmShowString(TXT_PHOTO_LINE,POS_MUSBRO_NUM_X+32,POS_MUSBRO_NUM_Y);
}
}
else
{
API_LcmPutSysImage(IMG_NO_SELECT_BAR,POS_MUSBRO_SEL_X,POS_MUSBRO_SEL_Y+(index*POS_MUSBRO_SEL_GAP_Y));
}
if(type == ICON_RETURN)
{
if(index == file_curr_sel_icon)
API_LcmPutSysImage(IMG_FILE_ICON_RETURN_SELECT,POS_MUSBRO_ICO_X,POS_MUSBRO_ICO_Y+(index*POS_MUSBRO_ICO_GAP_Y));
else
API_LcmPutSysImage(IMG_FILE_ICON_RETURN_NORMAL,POS_MUSBRO_ICO_X,POS_MUSBRO_ICO_Y+(index*POS_MUSBRO_ICO_GAP_Y));
result = 2;
//strcpy(sfnPtr,TXT_PHOTO_RETURN_EN);
API_SysLoadValue(NAND_TEXT_ADR+(language*TIDX_AMOUNT_OF_ONE_LANGUAGE)+TIDX_RETURN,string_ptr,255);
}
else if(type == ICON_FOLDER)// folder icon
{
if(index == file_curr_sel_icon)
API_LcmPutSysImage(IMG_FILE_ICON_FOLDER_SELECT,POS_MUSBRO_ICO_X,POS_MUSBRO_ICO_Y+(index*POS_MUSBRO_ICO_GAP_Y));
else
API_LcmPutSysImage(IMG_FILE_ICON_FOLDER_NORMAL,POS_MUSBRO_ICO_X,POS_MUSBRO_ICO_Y+(index*POS_MUSBRO_ICO_GAP_Y));
//get folder name
result=API_FATGetFolderName(file_curr_paint_item, sfnPtr, lfnPtr);
}
else if(type == ICON_FILE) //music icon
{
if(index == file_curr_sel_icon)
API_LcmPutSysImage(IMG_FILE_ICON_MUSIC_SELECT,POS_MUSBRO_ICO_X,POS_MUSBRO_ICO_Y+(index*POS_MUSBRO_ICO_GAP_Y));
else
API_LcmPutSysImage(IMG_FILE_ICON_MUSIC_NORMAL,POS_MUSBRO_ICO_X,POS_MUSBRO_ICO_Y+(index*POS_MUSBRO_ICO_GAP_Y));
//get file name
result=API_FATGetFileName(FF_MUSIC_FORM,file_curr_paint_item-Folders, sfnPtr, lfnPtr);
}
else if(type == ICON_PLAY) //return music player icon
{
if(index == file_curr_sel_icon)
API_LcmPutSysImage(IMG_ICON_PLAYING_ON,POS_MUSBRO_ICO_X,POS_MUSBRO_ICO_Y+(index*POS_MUSBRO_ICO_GAP_Y));
else
API_LcmPutSysImage(IMG_ICON_PLAYING_NORMAL,POS_MUSBRO_ICO_X,POS_MUSBRO_ICO_Y+(index*POS_MUSBRO_ICO_GAP_Y));
//get file name
result = 2;
//strcpy(sfnPtr,TXT_PHOTO_MUSIC_EN);
API_SysLoadValue(NAND_TEXT_ADR+(language*TIDX_AMOUNT_OF_ONE_LANGUAGE)+TIDX_RETURN_TO_MUSIC,string_ptr,255);
}
API_LcmSetStringLenth((POS_MUSBRO_MOVBAR_X-POS_MUSBRO_FN_X)/8);
_music_show_name(result,index);
}
//***************************************************************************
// Func: uint8 _load_path(uint32 ram_path_adr)
// Input: ram_path_adr : ram address
// Output: result : TRUE
// : FALSE
// Description: load path, assign CUR_FILE_L in RAM_SHARING_ADR and return result
//
//***************************************************************************
uint8 _load_path(uint32 ram_path_adr)
{
uint8 index,result,root_order,i;
uint16 cur_path,pre_path;
root_order = API_SysReadValue(RAM_SHARING_ADR,ROOT_ORDER);
cur_path = 0;
pre_path = 0;
index = 0;
result = 0;
//return to root
while(root_order!=0)
{
API_FATExitFolder();
API_SysWriteValue2B(RAM_CUR_PATH_ADR,root_order*2,0);
root_order--;
}
API_SysWriteValue(RAM_SHARING_ADR,ROOT_ORDER,root_order);
while((cur_path=API_SysReadValue2B(ram_path_adr,(index++)*2 )) !=0 )
{
if(pre_path == 0) // first layer
{
pre_path = cur_path;
}
else
{
if(API_FATEnterFolder(pre_path))
{
if(root_order<8) //only record 8 order path
API_SysWriteValue2B(RAM_CUR_PATH_ADR,root_order*2,pre_path);
API_SysWriteValue(RAM_SHARING_ADR,ROOT_ORDER,++root_order);
pre_path = cur_path;
}
else
{
//if wrong path return to root
while(root_order!=0)
{
API_FATExitFolder();
API_SysWriteValue2B(RAM_CUR_PATH_ADR,root_order*2,0);
root_order--;
}
API_SysWriteValue(RAM_SHARING_ADR,ROOT_ORDER,root_order);
//clean record path and current path
for(i=0;i<8;i++)
{
API_SysWriteValue2B(ram_path_adr,i*2,0);
API_SysWriteValue2B(RAM_CUR_PATH_ADR,i*2,0);
}
return FALSE;
}
}
}
// cur_path=0, handle pre_path
if(pre_path == 0) //no path, jump photo browser
{
result = FALSE;
}
else
{
result = TRUE;
API_SysWriteValue2B(RAM_SHARING_ADR,CUR_FILE_L,pre_path);
}
return result;
}
//***************************************************************************
// Func: uint8 _load_base_path(uint8 *base_folder_ptr)
// Input: base_folder_ptr
//
// Output: result : TRUE
// : FALSE
// Description: return base folder
//
//***************************************************************************
uint8 _load_base_path(uint8 *base_folder_ptr)
{
uint8 result,root_order;
uint16 folder_index;
root_order = API_SysReadValue(RAM_SHARING_ADR,ROOT_ORDER);
//return root
while(root_order!=0)
{
API_FATExitFolder();
API_SysWriteValue2B(RAM_CUR_PATH_ADR,root_order*2,0);
root_order--;
}
API_SysWriteValue(RAM_SHARING_ADR,ROOT_ORDER,root_order);
// get folder index
if(API_FATGetIdxOfSfn(base_folder_ptr,&folder_index) !=2 )
{
#if DEBUG
API_LcmShowString("can't find Music folder",0,0);
return;
#endif
result = FALSE;
}
else
{
// go to Music folder
if(API_FATEnterFolderName(base_folder_ptr))
{
API_SysWriteValue2B(RAM_CUR_PATH_ADR,root_order*2,folder_index);
root_order++;
API_SysWriteValue(RAM_SHARING_ADR,ROOT_ORDER,root_order);
result = TRUE;
}
}
return result;
}
uint8 _get_battery_icon_index(void)
{
uint8 bat_lv_icon_index;
uint8 bat_lv;
bat_lv = API_SysGetVolLv();
if(BATTERY_LV4 <= bat_lv) // > LV4
bat_lv_icon_index = 4;
else if( BATTERY_LV3 <= bat_lv && bat_lv < BATTERY_LV4) // LV3<= <LV4
bat_lv_icon_index = 3;
else if( BATTERY_LV2 <= bat_lv && bat_lv < BATTERY_LV3) // LV2<= <LV3
bat_lv_icon_index = 2;
else if( BATTERY_LV1 <= bat_lv && bat_lv < BATTERY_LV2) // LV1<= <LV2
bat_lv_icon_index = 1;
else if( BATTERY_LV0 <= bat_lv && bat_lv < BATTERY_LV1) // LV0<= <LV1
bat_lv_icon_index = 0;
return bat_lv_icon_index;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -