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

📄 keyfunc.c

📁 按键扫描 塔顶 DASDA FASF
💻 C
📖 第 1 页 / 共 3 页
字号:
/*
 ********************************************************************************************************************
 *描述:    	键盘处理函数
 *文件名:   	keyFunc.C
 *应用语言: 	KEIL C51
 *版本 :   		V1.0
 *作者:   	 	刘养海
 ********************************************************************************************************************
 */
 #define	_KEYFUNC_GLOBAL_
 #include 	"includes.h" 


 void	DelPragItem(UINT16	Item)
{
	UINT32	i;
	for(i=0;i<sizeof(TimerPartBak);i++)
	{
		TimerPartBak[i]=TimerPartTab[i];
	}
	//保存当次的设置
	if(Item == 999)
	{
		//删除所有
		for(i=0;i<MAX_PRAM_ITEM;i++)
		{
			((stcTimerPiont *)&TimerPartBak)[i].Flag=0;
		}
		
	}
	else if(Item >= MAX_PRAM_ITEM)
	{
		Item=MAX_PRAM_ITEM-1;
	}
	else
		((stcTimerPiont *)&TimerPartBak)[Item].Flag=0;
	IAPPRG();
	//
}

void	SetTimerRightPrg(void)
{
	UINT16	num;
	if(QueryFlag == 0xAA)
	{
		if(KeyEditFlag != 0xAA)
		{
			if(SysLcdFramePoint!=0)SysLcdFramePoint=0;
			else SysLcdFramePoint=34;
			return;
		}
		num=++TimerPiontApp.PragNum;
		if(num>=MAX_PRAM_ITEM)
		{
			num = 1;
		}
		TimerPiontApp=((stcTimerPiont *)&TimerPartTab)[num];
		TimerPiontApp.PragNum=num;	
		return;
	}
	if(KeyEditFlag != 0xAA)
	{
		if(TimerPiontApp.PlayMode == 5)
		{
			switch(SysLcdFramePoint)
			{
				case	0:	//序号
				case	1:	
				case	2:	
				case	3:	//序号
				case	4:	
				case	5:	
				case	6:	//序号
				case	7:	
				case	8:	
				case	18:	//序号
				case	19:	
				case	20:	
				case	21:	//序号
				case	22:	
				case	23:	
				case	24:	//序号
				case	25:	
				case	26:	
				case	27:	//序号
				case	28:	
				case	29:	
				case	30:	//序号
				case	31:	
				case	32:	
				case	33:	//序号
				
				case	35:	
				case	36:	//序号
				case	37:	
				case	38:	
				case	39:	//序号
				case	40:	
				case	41:	
				case	42:	//序号
					++SysLcdFramePoint;
					break;
				case	43:	
					SysLcdFramePoint=18;
					break;
				case	9:	//序号
					SysLcdFramePoint=14;
					break;
				case	10:	
				case	11:	
				case	12:	//序号
				case	13:	
				case	14:	
					SysLcdFramePoint=18;
					break;
				case	34:	
					
				default:				//
					SysLcdFramePoint=0;
					break;
			}	
			return;
		}		if(TimerPiontApp.PlayMode == 4)
		{
			switch(SysLcdFramePoint)
			{
				case	0:	//序号
				case	1:	
				case	2:	
				case	3:	//序号
				case	4:	
				case	5:	
				case	6:	//序号
				case	7:	
				case	8:	
				case	18:	//序号
				case	19:	
				case	20:	
				case	21:	//序号
				case	22:	
				case	23:	
				case	24:	//序号
				case	25:	
				case	26:	
				case	27:	//序号
				case	28:	
				case	29:	
				case	30:	//序号
				case	31:	
				case	32:	
				case	33:	//序号
				
				case	35:	
				case	36:	//序号
				case	37:	
				case	38:	
				case	39:	//序号
				case	40:	
				case	41:	
				case	42:	//序号
					++SysLcdFramePoint;
					break;
				case	43:	
					SysLcdFramePoint=18;
					break;
				case	9:	//序号
					SysLcdFramePoint=14;
					break;
				case	10:	
				case	11:	
				case	12:	//序号
				case	13:	
				case	14:	
					SysLcdFramePoint=35;
					break;
				case	34:	
					
				default:				//
					SysLcdFramePoint=0;
					break;
			}	
			return;
		}
		if(SysLcdFramePoint == 9)
		{
			SysLcdFramePoint = 14;
			return;
		}
		if(++SysLcdFramePoint>34)
		{
			SysLcdFramePoint=0;
		}
		return;
	}
	//else
	switch(SysLcdFramePoint)
	{
		case	0:	//序号
		case	1:	
		case	2:	
			HexToFourBcdPrgInt(TimerPointBuf,TimerPiontApp.PragNum);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(++TimerPointBuf[SysLcdFramePoint+1] > 9)
			{
				TimerPointBuf[SysLcdFramePoint+1]=0;
			}
			TimerPointBuf[0]=0;
			TimerPiontApp.PragNum=FourBcdToHexPrgInt(TimerPointBuf);
			break;
		case	15:	//曲目号
		case	16:	
		case	17:	
			HexToFourBcdPrgInt(TimerPointBuf,TimerPiontApp.MusicNum[0]);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(++ TimerPointBuf[SysLcdFramePoint+1-15] > 9)
			{
				TimerPointBuf[SysLcdFramePoint+1-15]=0;
			}
			TimerPointBuf[0]=0;
			TimerPiontApp.MusicNum[0]=FourBcdToHexPrgInt(TimerPointBuf);
			break;
		case	14+4:	//时间
			HexToTwoBcdPrg(TimerPointBuf,TimerPiontApp.Hour);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(++ TimerPointBuf[SysLcdFramePoint-18] > 2)
			{
				TimerPointBuf[SysLcdFramePoint-18]=0;
			}
			TimerPiontApp.Hour=TwoBcdToHexPrg(TimerPointBuf);
			
			if(TimerPiontApp.Hour > 23)
			{
				TimerPointBuf[SysLcdFramePoint-18+1]=0;
				TimerPiontApp.Hour=TwoBcdToHexPrg(TimerPointBuf);
			}
			break;
		case	15+4:
			HexToTwoBcdPrg(TimerPointBuf,TimerPiontApp.Hour);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(++ TimerPointBuf[SysLcdFramePoint-18] > 9)
			{
				TimerPointBuf[SysLcdFramePoint-18]=0;
			}
			TimerPiontApp.Hour=TwoBcdToHexPrg(TimerPointBuf);
			
			if(TimerPiontApp.Hour > 23)
			{
				TimerPointBuf[SysLcdFramePoint-18]=0;
				TimerPiontApp.Hour=TwoBcdToHexPrg(TimerPointBuf);
			}
			
			break;
		case	16+4:	
			HexToTwoBcdPrg(TimerPointBuf,TimerPiontApp.Min);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(++ TimerPointBuf[SysLcdFramePoint-20] > 5)
			{
				TimerPointBuf[SysLcdFramePoint-20]=0;
			}
			TimerPiontApp.Min=TwoBcdToHexPrg(TimerPointBuf);
			break;
		case	17+4:
			HexToTwoBcdPrg(TimerPointBuf,TimerPiontApp.Min);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(++ TimerPointBuf[SysLcdFramePoint-20] > 9)
			{
				TimerPointBuf[SysLcdFramePoint-20]=0;
			}
			TimerPiontApp.Min=TwoBcdToHexPrg(TimerPointBuf);
			break;
		case	18+4:	
			HexToTwoBcdPrg(TimerPointBuf,TimerPiontApp.Sec);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(++ TimerPointBuf[SysLcdFramePoint-22] > 5)
			{
				TimerPointBuf[SysLcdFramePoint-22]=0;
			}
			TimerPiontApp.Sec=TwoBcdToHexPrg(TimerPointBuf);
			break;

		case	19+4:
			#if	1
			HexToTwoBcdPrg(TimerPointBuf,TimerPiontApp.Sec);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(++TimerPointBuf[SysLcdFramePoint-22] > 9)
			{
				TimerPointBuf[SysLcdFramePoint-22]=0;
			}
			TimerPiontApp.Sec=TwoBcdToHexPrg(TimerPointBuf);
			#endif /* BOGUS */
			//if(++TimerPiontApp.Sec>59)TimerPiontApp.Sec=0;
			break;
		case	26+4:	//增加
		case	27+4:	//删除
		case	28+4:	//全删
		case	29+4:	//退出
		case	34:
			break;
		case 	35:
		case	36:
		case	37:
			HexToFourBcdPrgInt(TimerPointBuf,TimerPiontApp.MusicNum[0]);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(++ TimerPointBuf[SysLcdFramePoint+1-35] > 9)
			{
				TimerPointBuf[SysLcdFramePoint+1-35]=0;
			}
			TimerPointBuf[0]=0;
			TimerPiontApp.MusicNum[0]=FourBcdToHexPrgInt(TimerPointBuf);
			break;
		case 	38:
		case	39:
		case	40:
			HexToFourBcdPrgInt(TimerPointBuf,TimerPiontApp.MusicNum[1]);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(++ TimerPointBuf[SysLcdFramePoint+1-38] > 9)
			{
				TimerPointBuf[SysLcdFramePoint+1-38]=0;
			}
			TimerPointBuf[0]=0;
			TimerPiontApp.MusicNum[1]=FourBcdToHexPrgInt(TimerPointBuf);
			break;
		case 	41:
		case	42:
		case	43:
			HexToFourBcdPrgInt(TimerPointBuf,TimerPiontApp.MusicNum[2]);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(++ TimerPointBuf[SysLcdFramePoint+1-41] > 9)
			{
				TimerPointBuf[SysLcdFramePoint+1-41]=0;
			}
			TimerPointBuf[0]=0;
			TimerPiontApp.MusicNum[2]=FourBcdToHexPrgInt(TimerPointBuf);
			break;
		default:				//
			SysLcdFramePoint=0;
			break;
	}
	if(SysLcdFramePoint<3)
	{
		num=FourBcdToHexPrgInt(&TimerPointBuf[0]);
		//__PRINTF("\r\nPragNum=%x,%x",TimerPiontApp.PragNum,FourBcdToHexPrgInt(&TimerPointBuf[0]));
		if(num>=MAX_PRAM_ITEM)
		{
			num = MAX_PRAM_ITEM-1;
		}
		if(num==0)num = 1;
		TimerPiontApp=((stcTimerPiont *)&TimerPartTab)[num];
		TimerPiontApp.PragNum=num;
		//if(TimerPiontApp.Flag != 0xAA)
		if(TimerPiontApp.PlayMode > 5)	TimerPiontApp.PlayMode =0;
		//__PRINTF("\r\nPragNum=%x,%x",TimerPiontApp.PragNum,num);

	}
}


void	SetTimerLeftPrg(void)
{
	UINT16	num;
	if(QueryFlag == 0xAA)
	{
		if(KeyEditFlag != 0xAA)
		{
			if(SysLcdFramePoint!=0)SysLcdFramePoint=0;
			else SysLcdFramePoint=34;
			return;
		}
		num=--TimerPiontApp.PragNum;
		if(num==0)num = MAX_PRAM_ITEM-1;
		if(num>=MAX_PRAM_ITEM)
		{
			num = MAX_PRAM_ITEM-1;
		}
		TimerPiontApp=((stcTimerPiont *)&TimerPartTab)[num];
		TimerPiontApp.PragNum=num;	
		return;
	}
	if(KeyEditFlag != 0xAA)
	{
		if(TimerPiontApp.PlayMode == 5)
		{
			switch(SysLcdFramePoint)
			{
				case	0:	//序号
					SysLcdFramePoint=34;
					break;
				case	1:	
				case	2:	
				case	3:	//序号
				case	4:	
				case	5:	
				case	6:	//序号
				case	7:	
				case	8:	
				case	9:	//序号
				case	19:	
				case	20:	
				case	21:	//序号
				case	22:	
				case	23:	
				case	24:	//序号
				case	25:	
				case	26:	
				case	27:	//序号
				case	28:	
				case	29:	
				case	30:	//序号
				case	31:	
				case	32:	
				case	33:	//序号
				case	34:	
				case	36:	//序号
				case	37:	
				case	38:	
				case	39:	//序号
				case	40:	
				case	41:	
				case	42:	//序号
				case	43:	
					--SysLcdFramePoint;
					break;
				case	15:	//序号
				case	16:	
				case	17:	
				case	18:	//序号
					SysLcdFramePoint=14;
					break;
				case	35:	
					SysLcdFramePoint=14;
					break;
				case	10:	
				case	11:	
				case	12:	//序号
				case	13:	
				case	14:	
					SysLcdFramePoint=9;
					break;
				default:				//
					SysLcdFramePoint=0;
					break;
			}	
			return;
		}

		
		if(TimerPiontApp.PlayMode == 4)
		{
			switch(SysLcdFramePoint)
			{
				case	0:	//序号
					SysLcdFramePoint=34;
					break;
				case	1:	
				case	2:	
				case	3:	//序号
				case	4:	
				case	5:	
				case	6:	//序号
				case	7:	
				case	8:	
				case	9:	//序号
				case	19:	
				case	20:	
				case	21:	//序号
				case	22:	
				case	23:	
				case	24:	//序号
				case	25:	
				case	26:	
				case	27:	//序号
				case	28:	
				case	29:	
				case	30:	//序号
				case	31:	
				case	32:	
				case	33:	//序号
				case	34:	
				case	36:	//序号
				case	37:	
				case	38:	
				case	39:	//序号
				case	40:	
				case	41:	
				case	42:	//序号
				case	43:	
					--SysLcdFramePoint;
					break;
				case	15:	//序号
				case	16:	
				case	17:	
				case	18:	//序号
					SysLcdFramePoint=43;
					break;
				case	35:	
					SysLcdFramePoint=14;
					break;
				case	10:	
				case	11:	
				case	12:	//序号
				case	13:	
				case	14:	
					SysLcdFramePoint=9;
					break;
				default:				//
					SysLcdFramePoint=0;
					break;
			}	
			return;
		}


		
		if(SysLcdFramePoint == 14)
		{
			SysLcdFramePoint = 9;
			return;
		}
		if(--SysLcdFramePoint>34)
		{
			SysLcdFramePoint=34;
		}
		__PRINTF("\r\nSysLcdFramePoint=%x",SysLcdFramePoint);
		return;
	}
	//else
	switch(SysLcdFramePoint)
	{
		case	0:	//序号
		case	1:	
		case	2:	
			__PRINTF("\r\nTimerPiontApp.PragNum=%x",TimerPiontApp.PragNum);

			HexToFourBcdPrgInt(TimerPointBuf,TimerPiontApp.PragNum);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(-- TimerPointBuf[SysLcdFramePoint+1] > 9)
			{
				TimerPointBuf[SysLcdFramePoint+1]=9;
			}
			
			TimerPointBuf[0]=0;
			TimerPiontApp.PragNum=FourBcdToHexPrgInt(TimerPointBuf);
			if(TimerPiontApp.PragNum == 0)TimerPiontApp.PragNum=1;
			__PRINTF("\r\nTimerPiontApp.PragNum=%x",TimerPiontApp.PragNum);

			break;
	
		case	15:	//曲目号
			
		case	16:	
			
		case	17:	
			HexToFourBcdPrgInt(TimerPointBuf,TimerPiontApp.MusicNum[0]);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(-- TimerPointBuf[SysLcdFramePoint+1-15] > 9)
			{
				TimerPointBuf[SysLcdFramePoint+1-15]=9;
			}
			TimerPointBuf[0]=0;
			TimerPiontApp.MusicNum[0]=FourBcdToHexPrgInt(TimerPointBuf);
			break;
		case	14+4:	//时间
			HexToTwoBcdPrg(TimerPointBuf,TimerPiontApp.Hour);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(-- TimerPointBuf[0] > 2)
			{
				TimerPointBuf[0]=2;
			}
			TimerPiontApp.Hour=TwoBcdToHexPrg(TimerPointBuf);
			if(TimerPiontApp.Hour > 23)
			{
				TimerPointBuf[SysLcdFramePoint-18+1]=0;
				TimerPiontApp.Hour=TwoBcdToHexPrg(TimerPointBuf);
			}
			break;
		case	15+4:
			HexToTwoBcdPrg(TimerPointBuf,TimerPiontApp.Hour);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(-- TimerPointBuf[1] > 9)
			{
				TimerPointBuf[1]=9;
			}
			TimerPiontApp.Hour=TwoBcdToHexPrg(TimerPointBuf);
			if(TimerPiontApp.Hour > 23)
			{
				TimerPointBuf[SysLcdFramePoint-18]=0;
				TimerPiontApp.Hour=TwoBcdToHexPrg(TimerPointBuf);
			}
			break;
		case	16+4:	
			HexToTwoBcdPrg(TimerPointBuf,TimerPiontApp.Min);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(-- TimerPointBuf[0] > 5)
			{
				TimerPointBuf[0]=5;
			}
			TimerPiontApp.Min=TwoBcdToHexPrg(TimerPointBuf);
			break;
		case	17+4:
			HexToTwoBcdPrg(TimerPointBuf,TimerPiontApp.Min);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(-- TimerPointBuf[SysLcdFramePoint-20] > 9)
			{
				TimerPointBuf[SysLcdFramePoint-20]=9;
			}
			TimerPiontApp.Min=TwoBcdToHexPrg(TimerPointBuf);
			break;
		case	18+4:	
			HexToTwoBcdPrg(TimerPointBuf,TimerPiontApp.Sec);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(-- TimerPointBuf[0] > 5)
			{
				TimerPointBuf[0]=5;
			}
			TimerPiontApp.Sec=TwoBcdToHexPrg(TimerPointBuf);
			break;
		case	19+4:
			#if	1
			HexToTwoBcdPrg(TimerPointBuf,TimerPiontApp.Sec);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(-- TimerPointBuf[SysLcdFramePoint-22] > 9)
			{
				TimerPointBuf[SysLcdFramePoint-22]=9;
			}
			TimerPiontApp.Sec=TwoBcdToHexPrg(TimerPointBuf);
			#endif /* BOGUS */
			//if(--TimerPiontApp.Sec>59)TimerPiontApp.Sec=59;
			break;
		case	26+4:	//增加
		case	27+4:	//删除
		case	28+4:	//全删
		case	29+4:	//退出
		case	34:
			
			break;
		case 	35:
		case	36:
		case	37:
			HexToFourBcdPrgInt(TimerPointBuf,TimerPiontApp.MusicNum[0]);
			//TimerPointBuf[SysLcdFramePoint+1]=i;
			if(-- TimerPointBuf[SysLcdFramePoint+1-35] > 9)
			{
				TimerPointBuf[SysLcdFramePoint+1-35]=9;
			}
			TimerPointBuf[0]=0;
			TimerPiontApp.MusicNum[0]=FourBcdToHexPrgInt(TimerPointBuf);
			break;
		case 	38:
		case	39:
		case	40:
			HexToFourBcdPrgInt(TimerPointBuf,TimerPiontApp.MusicNum[1]);
			if(-- TimerPointBuf[SysLcdFramePoint+1-38] > 9)
			{
				TimerPointBuf[SysLcdFramePoint+1-38]=9;
			}
			TimerPointBuf[0]=0;
			TimerPiontApp.MusicNum[1]=FourBcdToHexPrgInt(TimerPointBuf);
			break;
		case 	41:
		case	42:
		case	43:
			HexToFourBcdPrgInt(TimerPointBuf,TimerPiontApp.MusicNum[2]);
			if(-- TimerPointBuf[SysLcdFramePoint+1-41] > 9)
			{
				TimerPointBuf[SysLcdFramePoint+1-41]=9;
			}
			TimerPointBuf[0]=0;
			TimerPiontApp.MusicNum[2]=FourBcdToHexPrgInt(TimerPointBuf);
			break;
		default:				//
			SysLcdFramePoint=0;
			break;
	}
	if(SysLcdFramePoint<3)
	{
		num=FourBcdToHexPrgInt(&TimerPointBuf[0]);
		__PRINTF("\r\nPragNum=%x,%x",TimerPiontApp.PragNum,FourBcdToHexPrgInt(&TimerPointBuf[0]));
		if(num>=MAX_PRAM_ITEM)
		{
			num = MAX_PRAM_ITEM-1;
		}
		if(num==0)num = 1;
		TimerPiontApp=((stcTimerPiont *)&TimerPartTab)[num];
		TimerPiontApp.PragNum=num;
		__PRINTF("\r\nPragNum=%x,%x",TimerPiontApp.PragNum,num);
		if(TimerPiontApp.PlayMode > 5)	TimerPiontApp.PlayMode =0;
	}
}

void	SetTimerEnterPrg(void)
{
	UINT32	i;
	if(SysLcdFramePoint < 30)
	{
		if(KeyEditFlag == 0xAA)
		{
			KeyEditFlag=0;
		}
		else
		{
			KeyEditFlag =	0xAA;
		}
		__PRINTF("\r\nEnterDefMenuFlag=%x",EnterDefMenuFlag);
	}
	else	if(SysLcdFramePoint == 30)
	{
		//增加
		TimerPiontApp.Flag=0xAA;
		SaveProgramPrg();
		SysLcdFramePoint=0;
	}
	else	if(SysLcdFramePoint == 31)
	{
		//删除
		DelPragItem(TimerPiontApp.PragNum);
		i= TimerPiontApp.PragNum ;
		if(i>=MAX_PRAM_ITEM)i=MAX_PRAM_ITEM-1;
		TimerPiontApp = ((stcTimerPiont *)&TimerPartBak)[i];
		TimerPiontApp.PragNum=i;
	}

⌨️ 快捷键说明

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