📄 emc_autosearch.c
字号:
/*******************************************************************************
File name : emc_autosearch.c
Description : auto search
Revision : 1.0
COPYRIGHT (C) EMC-HUST-JRC 2005.
Date Label Auther Comment
---- ---- ------ ---------------------
12-28-2005 Allen Wu Created
01-19-2006 FF03 Fix: After the 1st successful searching, "no signal" is shown in correctly
*********************************************************************************/
/* Includes --------------------------------------------------------------- */
#include <stdio.h>
//#include "stosd.h"
#include "gui.h"
#include "osdwrap.h"
//#include "Hl_stosd.h"
#include "usif.h"
#include "sr_dbase.h"
#include "sr_tuner.h"
//#include "OsdRegionInit.h"
#include "UIPositionDef.h"
#include "emc_font.h"
#include "emc_autosearch.h"
#include "emc_menustate.h"
#include "./pics/data_bitmap_autosearch.h"
#include "./pics/data_struct_autosearch.h"
#include "./pics/data_bitmap_progressbar.h"
#include "./pics/data_struct_progressbar.h"
#define MIN_SEARCH_FREQUENCY_6M 473
#define MIN_SEARCH_FREQUENCY_7M 471.5
#define MIN_SEARCH_FREQUENCY_8M 474
#define MIN_FREQ MIN_SEARCH_FREQUENCY_8M
#define MAX_FREQ 874
static int AutosearchProgress = 0;
static int CurSearchFreq=MIN_SEARCH_FREQUENCY_8M;
static int ChannelsFoundNum=0;
static int ProgramsFoundNum=0;
static clock_t autoSearchStartTime = 0;
extern int iInputFrequency;
extern int iBandWidth;
extern signed char xpdrInManSearch;
extern dvb_state_e currMenuState;
extern int iLastProgramNumber;
extern int CountrySelect;
extern void EMC_ResetTime(void);
extern void InitEPGSkedDateTag(void);
static void updateAutoSearchEditBox(STOSD_RegionHandle_t Handle,U32 x0, U32 y0, char * string,
STOSD_Color_t textcolor,STOSD_Color_t fillcolor)
{
int width = 28+2;
int height = 14;
EMC_DrawTextRectangle(Handle,
x0,y0, width, height, string, JLEFT, FONT_MYFONT, FALSE,
textcolor, fillcolor, fillcolor);
}
static void drawAutoSearchWindow(void)/*drawAutoSearchChannelDialog*/
{
/*fix me,the following are just for test*/
//int i;
char freqTemp[4];
/********************Argument**********************/
/******************Clear the screen******************/
#if 0
STOSD_FillRectangle(Handle_Info4bpp, 0, 0, MainParams8bpp.Width, MainParams8bpp.Height, epgpancolor/*backcolor*/);
STOSD_FillRectangle(Handle_Menu4bpp, 0, 0, MainParams4bpp.Width, MainParams4bpp.Height, lightbluecolor);
STOSD_FillRectangle(Handle_Title4bpp, 0, 0, MainParbmp4bpp.Width, MainParbmp4bpp.Height, epgpancolor);
#else
EMC_HideAllRegions();
#endif
/******************Draw the Dialog******************/
#if 0
STOSD_FillRectangle(Handle_Menu4bpp, MainParams4bpp.Width/6, MainParams4bpp.Height/6-30,
MainParams4bpp.Width*2/3, MainParams4bpp.Height*2/3+60, yellowcolor);
#else
HL_STOSD_DrawBMP(Handle_ProviewWindow, AS_X,AS_Y(iPAL_Mode), Bitmap_Struct_AutoSearch);
#endif
/*********************Draw Title********************/
#if 0
MyDrawTextButton(Handle_Menu4bpp, MainParams4bpp.Width/6, MainParams4bpp.Height/6-30,
MainParams4bpp.Width*2/3, MainParams4bpp.Height/6, currWindow->dialogTitle[(pstBoxInfo->iUILanguage)],
whitecolor,epgpancolor,epgpancolor,100);
#endif
/******************Draw Content********************/
#if 0
currWindow->dialogItemOffset=0;
textrect.x=MainParams4bpp.Width/6+20;
textrect.y=MainParams4bpp.Height/3-10;
textrect.x2=660;
textrect.y2=532;
for(i=0;i<3;i++) /*3 items*/
{
EMC_DrawText(Handle_Menu4bpp,FONT_MYFONT,currWindow->dialogItems[i].dialogItemDepict[(pstBoxInfo->iUILanguage)], &textrect, blackcolor);
MyDrawTextButton(Handle_Menu4bpp, MainParams4bpp.Width*7/12,textrect.y,MainParams4bpp.Width*1/6, 40,
currWindow->dialogItems[i].dialogItemValueArray[0],blackcolor,blackcolor,whitecolor,300);
textrect.y+=50;
}
MyDrawTextButton(Handle_Menu4bpp, MainParams4bpp.Width*1/6+20,textrect.y,MainParams4bpp.Width*5/12-20, 40, //wuhan modified,07-02-2005
currWindow->dialogItems[i].dialogItemDepict[(pstBoxInfo->iUILanguage)],blackcolor,yellowcolor,yellowcolor,300);
#else
sprintf(freqTemp, "%d", CurSearchFreq);
updateAutoSearchEditBox(Handle_ProviewWindow,AS_X+88,AS_Y(iPAL_Mode)+40,freqTemp,whitecolor,dialogcolor);
updateAutoSearchEditBox(Handle_ProviewWindow,AS_X+88,AS_Y(iPAL_Mode)+65,"0",whitecolor,dialogcolor);
updateAutoSearchEditBox(Handle_ProviewWindow,AS_X+210,AS_Y(iPAL_Mode)+40,"0",whitecolor,dialogcolor);
updateAutoSearchEditBox(Handle_ProviewWindow,AS_X+210,AS_Y(iPAL_Mode)+65,"0",whitecolor,dialogcolor);
updateAutoSearchEditBox(Handle_ProviewWindow,AS_X+221,AS_Y(iPAL_Mode)+100,"0%",whitecolor,dialogcolor);
#endif
/*****************Show Dialog Window***********************/
#if 0
STOSD_ShowRegion(Handle_Menu4bpp);
STOSD_ShowRegion(Handle_Info4bpp);
STOSD_ShowRegion(Handle_Title4bpp);
#else
//STOSD_ShowRegion(Handle_ProviewWindow);
EMC_ShowRegion();
#endif
/*********************************************************/
}
#if 0
static void AutoSearchKeyService(dvb_MenuCmd_e iClientCode)/*doAutoSearchChannel*/
{
switch(iClientCode)
{
case rc_kKeySelect:
if(DVB_Screen_State == DVB_PREPARE_AUTO_SEARCH_STATE)
{
#if 0
#if 1/*wuhan modified,09-01-2005*/
SRDBE_InitProgDataBase();
SRDBE_InitXpdrDataBase();
#else
DeleteAllTransponderSlots();//wuhan 06-28-2005
#endif
#endif
SRDBE_DeleteAllTransponders();/*added by Allen,11-05-2005*/
#if 0 /* FF01 disable start 2005-11-08 */
StopSubtitle();/*08-30-2005*/
subt_already_start = 0;
subt_already_show = 0;
subt_already_setstream = 0;
subt_show = 0;/*08-30-2005 end*/
#endif /* FF01 end disable 2005-11-08 */
StartAutoSearch();
}
break;
case rc_kKeyExit:
if(DVB_Screen_State == DVB_PREPARE_AUTO_SEARCH_STATE)
{
#if 0
currentUTCtime = 0;/*added by Allen,09-29-2005*/
#endif
RestoreAutoSearchParameter();
ChangeStateToDVBDisplay(DVB_PREPARE_AUTO_SEARCH_STATE);
}
else
{
ChangeAutoSearchTips("User break!","用户中止!","",3);
/*wuhan added,07-20-2005,解决自动搜台后第一个节目不能自动播放的问题*/
iLastProgramNumber = -1;
UpdateAutoSearchWindow();
DVB_Screen_State = DVB_PREPARE_AUTO_SEARCH_STATE;
sttbx_Print("\nEntering DVB_PREPARE_AUTO_SEARCH_STATE\n");
//bExitAutoSearchWindow = TRUE;
}
break;
}
}
#endif
static void RestoreAutoSearchParameter(void)/*restore*/
{
/*just restore the init value,but doesn't display it*/
#if 0
int i;
ChangeAutoSearchTips("Press OK to Start...","按OK键开始...","",3);
for(i=0;i<3;i++)
{
currWindow->dialogItems[i].dialogItemValueArray[0][0]='0';
currWindow->dialogItems[i].dialogItemValueArray[0][1]='\0';
}
#endif
CurSearchFreq=MIN_FREQ;
ChannelsFoundNum=0;
ProgramsFoundNum=0;
}
static void ChangeAutoSearchTips(char * p0, char * p1, char * p2,int itemnum )/*ChangeSearchTips*/
{
#if 0
int i;
for(i=0;p0[i]!='\0';i++)
{
currWindow->dialogItems[itemnum].dialogItemDepict[0][i]=p0[i];
}
currWindow->dialogItems[itemnum].dialogItemDepict[0][i]=p0[i];
for(i=0;p1[i]!='\0';i++)
{
currWindow->dialogItems[itemnum].dialogItemDepict[1][i]=p1[i];
}
currWindow->dialogItems[itemnum].dialogItemDepict[1][i]=p1[i];
for(i=0;p2[i]!='\0';i++)
{
currWindow->dialogItems[itemnum].dialogItemDepict[2][i]=p2[i];
}
currWindow->dialogItems[itemnum].dialogItemDepict[2][i]=p2[i];
#endif
}
static void UpdateAutoSearchWindow(void)/*UpdateAutoSearchDlg*/
{
/******************Draw Content********************/
char temp[4][10];
sprintf(temp[0], "%d", CurSearchFreq);
sprintf(temp[1], "%d", ChannelsFoundNum);
sprintf(temp[2], "%d", ProgramsFoundNum);
sprintf(temp[3], "%d%%", AutosearchProgress);
updateAutoSearchEditBox(Handle_ProviewWindow,AS_X+88,AS_Y(iPAL_Mode)+40,temp[0],whitecolor,dialogcolor);
updateAutoSearchEditBox(Handle_ProviewWindow,AS_X+88,AS_Y(iPAL_Mode)+65,temp[1],whitecolor,dialogcolor);
//updateAutoSearchEditBox(Handle_ProviewWindow,AS_X+210,AS_Y(iPAL_Mode)+40,"0",whitecolor,dialogcolor);
updateAutoSearchEditBox(Handle_ProviewWindow,AS_X+210,AS_Y(iPAL_Mode)+65,temp[2],whitecolor,dialogcolor);
/*update the progressbar*/
HL_STOSD_DrawBMP(Handle_ProviewWindow, AS_X+87+(AutosearchProgress%4==0?AutosearchProgress*5/4 : (AutosearchProgress-2)*5/4+2),AS_Y(iPAL_Mode)+103, Bitmap_Struct_ProgressBar);
/*added by Allen,09-22-2005,for erasing the '%' left in the dialog*/
#if 0
HL_STOSD_DrawFilledRectangle(Handle_ProviewWindow,AS_X+220,AS_Y(iPAL_Mode)+100,45,14,dialogcolor);
updateAutoSearchEditBox(Handle_ProviewWindow,AS_X+221,AS_Y(iPAL_Mode)+100,temp[3],whitecolor,dialogcolor);
#else
//EMC_DrawTextFlatRectangle(Handle_ProviewWindow,AS_X+220,AS_Y(iPAL_Mode)+100,47, 20, temp[3],whitecolor, dialogcolor,dialogcolor);
EMC_DrawTextRectangle(Handle_ProviewWindow,
AS_X+218,AS_Y(iPAL_Mode)+97, 49, 20,
temp[3], JLEFT, FONT_MYFONT, FALSE,
whitecolor, dialogcolor, dialogcolor);
#endif
}
static int PrepareNewSearchingFrequency(void)/*PrepareNewSearchFrequency*/
{
signed char cLocalTransSlot;
TRANSPONDER_INFO_STRUCT *pstTransponderInfoTemp;
iInputFrequency = CurSearchFreq;
sttbx_Print( "new search: %d MHz\n" ,CurSearchFreq);//wuhan modified,06-28-2005
if ( ( pstTransponderInfoTemp = SRDBE_AppendTransponderSlot ( &cLocalTransSlot ) ) == ( TRANSPONDER_INFO_STRUCT * ) NULL )
{
#ifdef USIF_DEBUG
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -