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

📄 uiflow.c

📁 凌阳MP3 spSPCA755yuanma
💻 C
📖 第 1 页 / 共 3 页
字号:
/*++
Copyright (c) 2001 Sunplus Technology Co., Ltd.
Module Name:
        UIflow.c
Abstract:
        Module related to User Interface Definition
Environment:
        Keil C51 Compiler
Note:

Revision History:
        09/18/2002      Chamber Ling    created
--*/
//=============================================================================
//Header file
//=============================================================================
#include "general.h"
#include "storage.h"
#include "timer.h"
#include "cardlink.h"
#include "main.h"
#include "uiflow.h"
#include "SPL10.h"
#include "lcd1.h"
#include "L2_adsp.h"
#include "initio.h"
#include "Dspui.h"
#include "dosusr.h"
#include "audiocodec.h"
#include "LCDVASO.H"
//=============================================================================
//Symbol
//=============================================================================
//void SPL10_ZERO(void);
//---------
//Variable
//---------
bit           G_ShowNowSongNumberFG;
bit           G_DisplayEvent_Happened;
bit           G_HoldKey_Lock=0;
bit           G_LED_BlinkFG;
//bit           _G_L10Key_Pressed;
//bit           _G_ADCKey_Pressed;
bit				_G_Key_Pressed;
bit			  G_LongKeyFlag=0;
bit				G_Flash_HQLP=0;
bit           G_Mute = 0;
data  BIT     _FastFFFR=0;
data  BIT     _G_Openfile=FALSE;         // For Open file Flag behind the UI-State transition
data  BIT     _G_UIPostError = FALSE;    // The Error flag of UI post-processor for Audio Engine, such as Open file fail, initial fail etc.
                                         // here can't initialize,move to main.c to initialize.xyq021228
data  BIT     _GRecordPauseAndStop;	 // chamber@030121 Close file when Stop after Pause!!
//xdata UCHAR   G_SKeyState[2];
xdata UCHAR   G_SPressingKey=0;
xdata UCHAR   G_SOldKey;  //[2];
xdata UCHAR   G_SKeyHoldCnt; //[2];
xdata UCHAR   G_SleepCnt;
xdata UCHAR   REC_name[12];
xdata UCHAR   G_USBReadWriteCount;
xdata UCHAR   G_end_of_file;
xdata USHORT  G_searchCluster;
xdata USHORT  G_AsearchCluster;
xdata USHORT  G_BsearchCluster;
xdata USHORT  G_Currtotalsecond;         // Current time total second
xdata USHORT  G_FileTotalSecond;         // File total seconds
xdata ULONG   G_FreeTotalSecond;
xdata ULONG   G_sectorNUM;
xdata ULONG   G_total_sectorNUM;
xdata ULONG   G_REC_fileSize;
xdata ULONG   G_ASectorNUM;
xdata ULONG   G_BSectorNUM;
xdata ULONG   G_AFrameCnt;
extern bit G_RecLeftTimeOn;

//
void Init_MultiDvr_Dir(void);
void init_pcm1770(void);
void pcm1770_mute(unsigned char val);
//

#if  (Auto_Repeat_OPTION==1)
//xyq add
data  bit     _G_DetectVoice;
xdata UCHAR   G_NoVoiceCount;

unsigned int code SensLevel[10]={0x30,0x40,0x50,0x90,0xb0,0xe0,0x110,0x140,0x180,0x200};
unsigned int code SensDT[10] =  {0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0};
#endif
unsigned char G_LongKey_Speed;
unsigned char ForBackWord_SecondCount;
//
unsigned char code SPL10Key_Table[16]=
{
	
	0x00,R_STOP,R_FR,R_MODE,R_VOS,R_PAUSE,R_FF,R_DEL,
	R_VOLDOWN,R_REC,R_MENU,R_REP,R_VOLUP,R_PLAY,0x00,0x00
};
unsigned char code SPL10Key_LTable[16]=
{
	0x00,P_STOP,P_FR,P_MODE,0x00,0x00,P_FF,P_DEL,
	P_VOLDOWN,P_REC,P_MENU,0x00,P_VOLUP,P_PLAY,0x00,0x00
};

//=============================================================================
//Program
//=============================================================================
//---------------
//L2_Read_SARADC
//---------------
/*
routine description:
        Read the ADC of SAR
arguments:
        MuxChannel: The Channel
                0:Channel
return value:
        ADC value
*/

UCHAR L2_Read_SARADC(UCHAR MuxChannel)
{
  UCHAR ADC;

        XBYTE[0x2060] = 0x01;       // Enable SAR ADC
    MuxChannel &= 0x03;
    XBYTE[0x2060] = (MuxChannel<<1)|0x09;
    while(!XBYTE[0x2061]);

    ADC = XBYTE[0x2062];
    XBYTE[0x2060] &= 0xFE;      // Disable SAR ADC
    return ADC;
}


void UI_GetShortOrLongKeyCode(unsigned char temp_key) //,unsigned char L10OrADC)
{
			 // initial state for remote control key detection
	if(temp_key==0)
	{
		_G_KeyScanTg = ~_G_KeyScanTg;
		G_SPressingKey=0;
		_G_Key_Pressed=0;
		if(!G_LongKeyFlag)
		{
			if((G_SOldKey==MSPL10Key_Menu))
			{
				G_SPressingKey=G_SOldKey;
			}
			else if((G_STATE==STATE_PLAY)&&((G_SOldKey==MSPL10Key_FR)||(G_SOldKey==MSPL10Key_FF)))
			{
				G_SPressingKey=G_SOldKey;
			}
		}
        else
			G_LongKeyFlag=0;
		G_SOldKey=0;
	}
	else if(temp_key==G_SOldKey)
	{	   
		if(!G_LongKeyFlag)
		{
			G_SKeyHoldCnt++;
			if(G_SKeyHoldCnt>13)
			{
				G_SKeyHoldCnt=G_LongKey_Speed;
				G_LongKeyFlag=1;
				G_SPressingKey = G_SOldKey|0x10;            // the Long press is same as Key Press currently
			}
		}
		else
		{	
			if(temp_key==MSPL10Key_VolUp||temp_key == MSPL10Key_VolDown||temp_key==MSPL10Key_FF||temp_key==MSPL10Key_FR)//@@chchang
			{
				G_SKeyHoldCnt++;
				if(G_SKeyHoldCnt>13)
				{
					G_SPressingKey = G_SOldKey|0x10;            // the Long press is same as Key Press currently
					G_SKeyHoldCnt = G_LongKey_Speed;//add by xyq
				}
			}
		}
	}
	else
	{
		_G_Key_Pressed=1;
		G_SKeyHoldCnt = 0x00;
		G_SOldKey = temp_key;
		G_SPressingKey=temp_key;
		G_LongKeyFlag=0;
		if((G_SOldKey==MSPL10Key_Menu))
		{
				G_SPressingKey=0;
		}
		else if((G_STATE==STATE_PLAY)&&((G_SOldKey==MSPL10Key_FR)||(G_SOldKey==MSPL10Key_FF)))
		{
				G_SPressingKey=0;
		}
	}
}
//=============================================================================
//TIMER0_Get_Hardware_Keypad1
//=============================================================================
void UI_Get_SPL10_Keypad1(void) USING_0
{
	UCHAR temp_key;
	temp_key = SPL10_ReadKey();	
	UI_GetShortOrLongKeyCode(temp_key);//,0);
}

//=============================================================================
//TIMER0_Get_Hardware_Keypad1
//=============================================================================
//ada@0415 test ui
//patch4.2@ada@0527 for key scan
void UI_Get_ADC_Keypad1(void) USING_0
{
	UCHAR temp_key;

	if((XBYTE[0x2040] & 0x04))//play key press
	{
		temp_key = MSPL10Key_Play;
	}
	else
	{
		temp_key = 0; //UI_GetKeyID(1);
	}

	UI_GetShortOrLongKeyCode(temp_key);//,1);
}
//-----------------------------------------------------------------------------
//xyq 021227
//unsigned char dis_adc_val;
void UI_Battery_Detect()
{
	unsigned char ADC_Value;
//	ADC_Value=0xD0;
	ADC_Value=L2_Read_SARADC(2);
//    dis_adc_val=ADC_Value;
	//DbgPrint("ADC_Value=%bx\n",ADC_Value);
	/*if (ADC_Value<0x3e)
		G_Battery_Level=0;          //<0.8V
	else if(ADC_Value<0x46)
		G_Battery_Level=1;          //0.8V
	else if(ADC_Value<0x4e)
		G_Battery_Level=2;          //0.9V
	else if(ADC_Value<0x55)
		G_Battery_Level=3;          //1.0V
	else if(ADC_Value<0x5e)
		G_Battery_Level=4;          //1.1V
	else if(ADC_Value<0x66)
		G_Battery_Level=5;          //1.2V
	else if(ADC_Value<0x6d)
		G_Battery_Level=6;          //1.3V
	else if(ADC_Value<0x75)
		G_Battery_Level=7;          //1.4V
	else if(ADC_Value<0x7c)
		G_Battery_Level=8;          //1.5V
	else if(ADC_Value<0x85)
		G_Battery_Level=9;          //1.6V
	else if(ADC_Value<0x8d)
		G_Battery_Level=10;         //1.7V
	else if(ADC_Value<0x95)
		G_Battery_Level=11;         //1.8V
	else if(ADC_Value<0x9c)
		G_Battery_Level=12;         //1.9V
	else*/ 
	if(ADC_Value<=158)       //1.9v
		G_Battery_Level=0;
   else if(ADC_Value<=178)
   		G_Battery_Level=1;         //2.1V
	else
		G_Battery_Level=15;         //>2.1V
	//G_Battery_Level=ADC_Value;
	/*
	if (ADC_Value<0x42)
		G_Battery_Level=0;          //<0.8V
	else if(ADC_Value<0x49)
		G_Battery_Level=1;          //0.8V
	else if(ADC_Value<0x52)
		G_Battery_Level=2;          //0.9V
	else if(ADC_Value<0x5a)
		G_Battery_Level=3;          //1.0V
	else if(ADC_Value<0x63)
		G_Battery_Level=4;          //1.1V
	else if(ADC_Value<0x6c)
		G_Battery_Level=5;          //1.2V
	else if(ADC_Value<0x74)
		G_Battery_Level=6;          //1.3V
	else if(ADC_Value<0x7e)
		G_Battery_Level=7;          //1.4V
	else if(ADC_Value<0x84)
		G_Battery_Level=8;          //1.5V
	else if(ADC_Value<0x8d)
		G_Battery_Level=9;          //1.6V
	else if(ADC_Value<0x95)
		G_Battery_Level=10;         //1.7V
	else if(ADC_Value<0x9e)
		G_Battery_Level=11;         //1.8V
	else if(ADC_Value<0xa6)
		G_Battery_Level=12;         //1.9V
	else if(ADC_Value<0xae)
		G_Battery_Level=13;         //2.0V
	else if(ADC_Value<0xb6)
		G_Battery_Level=14;         //2.1V
	else
		G_Battery_Level=15;         //>2.1V
*/
	return;
}
//-----------------------------------------------------------------------------
//TIMER0_GetGPIOByte
//-----------------------------------------------------------------------------
/*UCHAR UI_GetKeyID(UCHAR MuxChannel) USING_0
{
	UCHAR GetKeyID;
	UCHAR Tmp;

	GetKeyID = L2_Read_SARADC(MuxChannel);

//	DbgPrint("GetKeyID = %bx\n",GetKeyID);

	if (GetKeyID<0x3a) Tmp=MSPL10Key_Mode;
	else if(GetKeyID<0x5d) Tmp=MSPL10Key_Stop;
	else if(GetKeyID<0x81) Tmp=MSPL10Key_VolUp;
	else if(GetKeyID<0xa1) Tmp=MSPL10Key_FR;
	else if(GetKeyID<0xbf) Tmp=MSPL10Key_VolDown;
	else if(GetKeyID<0xd7) Tmp=MSPL10Key_FF;
//	else if(GetKeyID<0xef) Tmp=MSPL10Key_Play;
	else Tmp = 0;

	return Tmp;
}*/
/*==========================
  Editor:chchang_11_13_2002
  Describe:scan key
===========================*/
void UI_PreProcessor_scan_key(void) USING_0
{
	if(_UIEvent)
	{
#if (EVBoard_OPTION==0)
		XBYTE[0x2038]=XBYTE[0x2038] & 0xfe;  //GPIO0 input enable for Hold key
		//XBYTE[0x2102]=XBYTE[0x2102] & 0xfd;  //P11 input enable for Hold key
		//if(DbgP11)
		if(HOLDDETECT)
		{
			if(G_HoldKey_Lock==0)
			{
				LCD10_Disp_Icon_Lock(1);
				G_HoldKey_Lock=1;//lock
			}
			return ;
		}
		else
		{
			if(G_HoldKey_Lock==1)
			{
				LCD10_Disp_Icon_Lock(0);
				G_HoldKey_Lock=0;//unlock
			}
		}
#endif
		if(_G_KeyScanTg)
		{
			if(G_LCDTMoutCnt<8)
			{
				UI_Get_SPL10_Keypad1();	// Get the Key ID
			}
		}
		else
		{
#if (EVBoard_OPTION==0)
			UI_Get_ADC_Keypad1();
#endif
		}
	//	_G_KeyScanTg = ~_G_KeyScanTg;
		_UIEvent = FALSE;
	}
#if 1
     if(G_SPressingKey & 0x10) //long term
     {//2
		G_EVENT=SPL10Key_LTable[G_SPressingKey&0x0f]; 
	    /*switch(G_SPressingKey)

⌨️ 快捷键说明

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