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

📄 tskmenu.c

📁 本人编写的无线电话程序,给予PIC18C801设计,包括了uCOS的移植以及菜单,自己设计的拼音注入法,完整地一级汉字库,希望对大家有所帮助
💻 C
📖 第 1 页 / 共 4 页
字号:
		}
		pos=48;
		Disp_Word(6,pos,lay[1],PIX8);
		for(i=2;i<=MenuNode[node].node_level;i++){
			pos+=8;
			Disp_Word(6,pos,0x002D,PIX8);	// '-'
			pos+=8;
			Disp_Word(6,pos,lay[i],PIX8);
		}
		while(pos<88){
			pos+=8;
			Disp_Word(6,pos,0x0020,PIX8);	// ' '
		}
	}
}


void MenuDisplayContent(INT8U node)
{
	if(MenuNode[node].attr==MENU_ATT_FIX){
		if(MenuNode[node].pbmp!=NULL){
			Display_Menu_Picture(MenuNode[node].pbmp);
		}
		else{
			if(MenuNode[node].pline1!=NULL)
				app_printf(MenuNode[node].pline1,MenuNode[node].len1,2,0);
		}
	}
}


#pragma romdata EXTRAM
INT8U rom ExitReason;	//if exit due to MSG_MENU_CANCEL, it's "1" , if doe to key press, it's "0"

#pragma code MYCODE


//-------------------------------------------------------------
//                    Main function 		
//-------------------------------------------------------------
void tskMenu(void * data)
{
	INT8U err,i;

	CurMenu=MENU_ROOT;
	CurInputMethod=PINYIN;

	for(;;){                                                                               //The main loop
		ExitReason = 0;
		
		switch(MFunc_WaitForInput(0)){
			case 0xFF:
				CurMenu=MENU_ROOT;
			break;

			case KEY_FUNC1:
			if(CurMenu==MENU_ROOT){
				//function of this part of codes is to add input numbers to phone book directly
				if(IdleNumBufPTR != 0){	//going to add an item into phone book
					for(i=0;i<IdleNumBufPTR;i++){
						CurPhoneNum[i] = IdleNumBuf[i];
					}
					CurPhoneNumLen = i;
					IdleNumBufPTR = 0;
					
					//PrevMenu=MENU_ROOT;
					CurMenu=MENU_BOOK_END;
					CurTextLen=0;
					CurText=tmpCurText;
					ExitReason=EnterPhoneEdit();
					if(ExitReason==2){
						MFunc_InsertPhoneBookItem(CurText, CurTextLen, CurPhoneNum, CurPhoneNumLen, 0);
					}

					CurMenu=MENU_ROOT;
				}
				else{
					CurMenu=MenuNode[CurMenu].next_node;
				}
			}
			else{			//Not MENU_ROOT
				CurMenu=MenuNode[CurMenu].next_node;

				if(MenuNode[CurMenu].attr!=MENU_ATT_FIX){

					Do_Clear_Screen(2,0,5,127);
				
					switch(CurMenu){
					case MENU_SET_RING_END:
						ExitReason = MFunc_Select_Ring();
						break;
					case MENU_REC_RCVNO_END:
						ExitReason = CallRecord_Check(UNACCEPTCALL);//(69,&SystemFile.UnAcceptCall);
						break;
					case MENU_REC_RCVED_END:
						ExitReason = CallRecord_Check(RECENTRXCALL);//(70,&SystemFile.RecentRxCall);
						break;
					case MENU_REC_XMT_END:
						ExitReason = CallRecord_Check(RECENTTXCALL);//(71,&SystemFile.RecentTxCall);
						break;
					case MENU_SET_LIGHT_END:
						ExitReason = MFunc_BackLedSet();
						break;
					case MENU_SET_LOCAL_END:
						ExitReason = MFunc_LocalNumberSet();
						break;
					case MENU_SMS_RDRCV_NUM:
						ExitReason = MFunc_CheckSM(0);
						break;
					case MENU_SMS_RDXMT_NUM:
						ExitReason = MFunc_CheckSM(1);
						break;
					case MENU_SMS_WR_TXT:
						CurText=tmpCurText;
						CurTextLen=0;
						CurPhoneNumLen=0;
						ExitReason = MFunc_EditSMS(1);
						break;
					}
					if(ExitReason==1)
						CurMenu=MENU_ROOT;
					else
						CurMenu=MenuNode[CurMenu].prev_node;
				}		//Not Fixed
			}
			break;

			case KEY_FUNC2:
				if(CurMenu==MENU_ROOT){		//MENU_KEY_BOOK
					CurMenu=MENU_BOOK_END;

					ExitReason = MFunc_CheckPhoneBook();
					CurMenu=MENU_ROOT;
				}
				else{						//MENU_KEY_CAN
					CurMenu=MenuNode[CurMenu].prev_node;
				}
			break;
			
			case KEY_C:
				CurMenu=MenuNode[CurMenu].prev_node;
			break;
			
			case KEY_UP:
				if(MenuNode[CurMenu].attr==MENU_ATT_FIX){
					if(MenuNode[CurMenu].node_sn==0)
						CurMenu=CurMenu+MenuNode[CurMenu].node_num-1;
					else
						CurMenu--;
				}
			break;

			case KEY_DOWN:
				//MenuKeyOption(MENU_KEY_DOWN);
				if(MenuNode[CurMenu].attr==MENU_ATT_FIX){
					if(MenuNode[CurMenu].node_sn==MenuNode[CurMenu].node_num-1)
						CurMenu=CurMenu-MenuNode[CurMenu].node_sn;
					else
						CurMenu++;
				}
			break;
		}
		
		//Lines below are about display
		if(CurMenu==MENU_ROOT){
		
			if(MainWndType==WND_MENU){
				Do_Clear_Screen(2,0,5,127);
			}
			Do_Clear_Screen(6,32,7,95);	//clear the menu index field
			MenuDisplayKey(MENU_ROOT);
			(void)OSQPost(peventDVS,(OS_EVENT *)MSG_MENU_EXIT);
		}
		else{
			Do_Clear_Screen(2,0,5,127);

			MenuDisplaySequence(CurMenu);
			MenuDisplayKey(CurMenu);
			MenuDisplayContent(CurMenu);	//note : this function will call app_printf() and it will pend displaysem itself
		}
	}		//end of "for"
} 

//Added by CJ 2003.3.30
void MFunc_Set_Focus(INT8U line);

#define FOCUS_F 0x3010
#define FOCUS_E 0x3011


#pragma code MYCODE
INT8U MFunc_Select_Ring(void){
	INT8U Head,Tail,Focus,RingTypeSave, fhdl;
	F_LocalPara * pup;
	
	Func_SetVoiceCh(VOX_HANDFREE);
	Display_Menu_Icon(0,&PIC_ACKNOWLEDGE);
	Display_Menu_Icon(1,&PIC_RETURN);
	
	fhdl = file_open(localpara_file, &pup);

	Do_Clear_Screen(6,32,7,95);	//clear the menu index field
	
	if(pup->RingType >9) pup->RingType = 9;
	RingTypeSave = pup->RingType;//SystemFile.RingType;
	//if(SystemFile.RingType > 9) SystemFile.RingType = 9;
	Focus = RingTypeSave;//SystemFile.RingType;
	Head = Focus;
	Tail = Head+1;
	if(Tail > 9) Tail = 0;
	for(;;){
		Do_Clear_Screen(2,32,5,80);
		app_printf(RingSelectWords,0,2,32);
		app_printf(RingSelectWords,0,4,32);
		if(Head == 9){
			Disp_Word(2, 64, 0x31, PIX8);
			Disp_Word(2, 72, 0x30, PIX8);
		}
		else{
			Disp_Word(2, 64, Head+0x31, PIX8);
		}
		if(Tail == 9){
			Disp_Word(4, 64, 0x31, PIX8);
			Disp_Word(4, 72, 0x30, PIX8);
		}
		else{
			Disp_Word(4, 64, Tail+0x31, PIX8);
		}
		
		MFunc_Set_Focus(Focus - Head);
		OSQPost(peventWICCmd, (OS_EVENT *)MSG_RING_BEGIN);
		
		switch(MFunc_WaitForInput(0)){
			case 0xff: 
				return(1);
			case KEY_FUNC1:	//Enter 
				file_save(fhdl, offsetof(F_LocalPara, RingType), sizeof(pup->RingType));
				OSQPost(peventWICCmd,(OS_EVENT *)MSG_RING_STOP);
				Func_SetVoiceCh(VOX_HANDSET);
				return(0);
			case KEY_FUNC2:	//Cancel
				OSQPost(peventWICCmd,(OS_EVENT *)MSG_RING_STOP);
				//SystemFile.RingType=RingTypeSave;
				pup->RingType = RingTypeSave;
				Func_SetVoiceCh(VOX_HANDSET);
				return(0);
			case KEY_C:		//Cancel
				OSQPost(peventWICCmd,(OS_EVENT *)MSG_RING_STOP);
				//SystemFile.RingType=RingTypeSave;
				pup->RingType=RingTypeSave;
				Func_SetVoiceCh(VOX_HANDSET);
				return(0);
			case KEY_UP:
				if(Focus == Head){
					if(Head == 0){
						Head = 9;
						Tail = 0;
					}
					else{
						Head--;
						Tail = Head+1;
					}
				}
				Focus = Head;
				MFunc_Set_Focus(Focus-Head);
				//SystemFile.RingType = Focus;
				pup->RingType = Focus;
				OSQPost(peventWICCmd, (OS_EVENT *)MSG_RING_BEGIN);
				break;
			case KEY_DOWN:
				if(Focus == Tail){
					if(Tail == 9){
						Tail = 0;
						Head = 9;
					}
					else{
						Tail++;
						Head = Tail-1;
					}
				}
				Focus = Tail;
				MFunc_Set_Focus(Focus-Head);
				//SystemFile.RingType = Focus;
				pup->RingType = Focus;
				OSQPost(peventWICCmd, (OS_EVENT *)MSG_RING_BEGIN);
				break;
		}
	}
}

	
//--------------------------------------------------------------------------------

void MFunc_Set_Focus(INT8U line){
	INT8U err;
	
	if(line >= 2) line = 1;
	Disp_Word(line*2+2, 8, FOCUS_F, PIX16);
	Disp_Word(line*2+2, 104, FOCUS_E, PIX16);
	if(line == 0){
		Disp_Word(4, 8, 0x3000, PIX16);
		Disp_Word(4, 104, 0x3000, PIX16);
	}
	else{
		Disp_Word(2, 8, 0x3000, PIX16);
		Disp_Word(2, 104, 0x3000, PIX16);
	}
}

INT8U MFunc_BackLedSet(void){
	//INT8U rom *pMsg;
	INT8U err,fhdl;
	INT8U chrSave;
	F_LocalPara * plp;
	
	fhdl = file_open(localpara_file, &plp);
	//Read_Domain(75, &SystemFile.BackGroundLED);
	//1 for background led open
	//0 for close
	chrSave = plp->BackLED;//SystemFile.BackGroundLED;
	
	if(chrSave >1) chrSave = 1;
	
	Display_Menu_Icon(0,&PIC_ACKNOWLEDGE);
	Display_Menu_Icon(1,&PIC_RETURN);

	Do_Clear_Screen(6,32,7,95);	//clear the menu index field

	Do_Clear_Screen(2,32,5,80);
	app_printf(TextBackLightClose, 0, 2, 32);
	app_printf(TextBackLightOpen, 0, 4, 32);
	
	for(;;){
		MFunc_Set_Focus(chrSave);//SystemFile.BackGroundLED);
		
		switch(MFunc_WaitForInput(0)){
			case 0xff:
				return(1);
			case KEY_FUNC1:	//Enter
				plp->BackLED = chrSave;//SystemFile.BackGroundLED = chrSave;
				file_save(fhdl, offsetof(F_LocalPara, BackLED), sizeof(plp->BackLED));
				err = sysdev_open(DEV_ID_KBD);
				sysdev_ioctl(err, 0, plp->BackLED);
				return(0);
			case KEY_FUNC2:	//Cancel
				return(0);
			case KEY_C:		//Cancel
				return(0);
			case KEY_UP:
				chrSave = 0;
				break;
			case KEY_DOWN:
				chrSave = 1;
				break;
		}
	}	
}

⌨️ 快捷键说明

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