Example #1
0
/** \brief Initialize timer to a given time-out value
 * 	\author 
 *		\li Jari Lahti ([email protected])
 *	\date 18.07.2001
 *	\param nbr handle of timer who's value we're setting
 *	\param tout time-out value to set for this timer
 *
 *	Invoke this function to set timeout value for a timer with
 *	a given handle.
 *
 *	#TIMERTIC defines how quickly the timers' values are decremented so is
 *	it to initialize timers to correct timeouts.
 */
void init_timer ( UINT8 nbr, UINT32 tout )
{
	/* Make a simple check */
	
	UINT32 val;
	
	if( nbr > (NUMTIMERS-1) ) 
		return; 

	if( timer_pool[nbr].free == TRUE ) 
		return;
		
	/* All OK				*/
	
	val = tout;
	
	OS_EnterCritical();
	
	/* Normalize seconds to timer tics	*/
	
	timer_pool[nbr].value = val;

	OS_ExitCritical();

} 
Example #2
0
//插入一个页面索引到记录
static void InsertPageTrack(u8 PageIdx)
{
	OS_DeclareCritical();
	
	OS_EnterCritical();
	if(++gCurTrackIdx==sizeof(gPageTracks)) gCurTrackIdx=0;
	
	gPageTracks[gCurTrackIdx]=PageIdx;
	OS_ExitCritical();
}
Example #3
0
//删除层
static void DeletePageLayer(u8 Num)
{
	OS_DeclareCritical();
	
	OS_EnterCritical();

	if(Num>=gCurLayerNum) //如果大于当前层数,则删除所有层
		gCurLayerNum=0;
	else
		gCurLayerNum-=Num;
	OS_ExitCritical();
}
Example #4
0
//新建一层
static void InsertPageLayer(u8 PageIdx)
{
	OS_DeclareCritical();
	
	OS_EnterCritical();
	if(++gCurLayerNum<=MAX_PAGE_LAYER_NUM)//判断存储空间够不够
		gPageLayers[gCurLayerNum]=PageIdx;
	else
	{
		Q_ErrorStopScreen("Layer is overflow,pls set marco MAX_PAGE_LAYER_NUM\n\r");
	}
	OS_ExitCritical();
}
Example #5
0
//�ر�ϵͳ�¼���־
void Q_DisablePeripEvt(PAGE_RID RegID,PERIP_EVT PeripEvt)
{
	u8 PageIdx;
	OS_DeclareCritical();

	if(RegID)
	{
		if(FindPage("",RegID,&PageIdx)!=SM_State_OK) return;//�˴�״̬��ʧ��
	}
	else //���RegIDΪ0�����ص�ǰҳ����¼���־
	{
		PageIdx=GetPageIdxByTrack(0);
	}
	
	OS_EnterCritical();
	ClrBit(gPagePeripEvtFlag[PageIdx],PeripEvt);
	OS_ExitCritical();
}
Example #6
0
//���ϵͳ�¼���Ӧλ
void Q_ClrPeripEvt(PAGE_RID RegID,u32 PeripEvtCon)
{
	u8 PageIdx;
	OS_DeclareCritical();

	if(RegID)
	{
		if(FindPage("",RegID,&PageIdx)!=SM_State_OK) return;//�˴�״̬��ʧ��
	}
	else //���RegIDΪ0�����ص�ǰҳ����¼���־
	{
		PageIdx=GetPageIdxByTrack(0);
	}
	
	OS_EnterCritical();
	gPagePeripEvtFlag[PageIdx]&=PeripEvtCon;
	OS_ExitCritical();
}
Example #7
0
//����ϵͳ�¼���Ӧλ
void Q_SetPeripEvt(PAGE_RID RegID,u32 PeripEvtCon)
{
	u8 PageIdx;
	OS_DeclareCritical();

	if(RegID)
	{
		if(FindPage("",RegID,&PageIdx)!=SM_State_OK) //�˴�״̬��ʧ�
		{
			Q_ErrorStopScreen("Can't find page!\n\r");
		}
	}
	else //���RegIDΪ0�����ص�ǰҳ����¼���־
	{
		PageIdx=GetPageIdxByTrack(0);
	}
	
	OS_EnterCritical();
	gPagePeripEvtFlag[PageIdx]|=PeripEvtCon;
	OS_ExitCritical();
}
Example #8
0
static SYS_MSG GotoPageHandler(INPUT_EVT_TYPE EventType,u16 PageIdx,int IntParam, void *pSysParam)
{
	u32 TimeMsRecord;
	u8 i;
	OS_DeclareCritical();

	//关闭触摸和外部按键输入,保证在换页面或者程序的过程中忽略所有输入
	Q_DisableInput();

	//在无输入状态下Clean页面
	if(gpCurrentPage)
	{
		if((!(gCurrSysMsg&SM_NoPageClean)) //Q_GotoPage返回值告诉系统不要执行Sys_PageClean或Sys_PreSubPage事件
			&& (GetPageByIdx(PageIdx)->Type != POP_PAGE)) //如果是pop页面,也不需要clean
			gCurrSysMsg|=OldPageClean(EventType,PageIdx);
		Debug("∧∧∧∧∧∧ Leave %s ∧∧∧∧∧∧\n\r",gpCurrentPage->Name);
	}
	else	//没有上一个页面
	{

	}	

	//4--------------------------数据处理-----------------------------
	OS_EnterCritical();//目前,只有一个线程操作这些全局变量,所以临界区并不是必须的。

	//记录页面Tarck
	InsertPageTrack(PageIdx);

	//记录页面层级
	if(EventType==Input_GotoSubPage) //如果是进入子页面
	{
		PushPageCtrlObjData();//保存前层的数据内容
		CleanPageCtrlObjData();//清除页面数据
		InsertPageLayer(PageIdx);//增加一层
	}
	else if(EventType==Input_SubPageReturn)
	{
		DeletePageLayer(1);//删除一层
		PopPageCtrlObjData(FALSE);//还原前层的数据内容
	}
	else if(EventType==Input_GotoNewPage)
	{
		DeletePageLayer(0xff);//删除所有层
		PopPageCtrlObjData(TRUE);//删除所有存储的数据内容
		CleanPageCtrlObjData();//清除页面数据
		InsertPageLayer(PageIdx);//增加一层

		//页面堆检查
		if(gPageHeapRecord)
		{
			Debug("gPageHeapRecord:%d\n\r",gPageHeapRecord);
			Q_ErrorStopScreen("!!!Warnning!!! Page momery don't be freed!");
		}
	}
	else if(EventType==Input_SubPageTranslate)
	{
		DeletePageLayer(1);//删除一层
		CleanPageCtrlObjData();//清除页面数据
		InsertPageLayer(PageIdx);//增加一层
	}
	
	//更换主指针
	gpCurrentPage=Q_GetPageByTrack(0);
	gEntriesOfPage[PageIdx]++;//进页面一次自加一次

	PageSwithcCtrlObjDataHandler(gpCurrentPage);//控件数据处理
	
	OS_ExitCritical();
	//4-------------------------数据处理完成--------------------------

	TimeMsRecord=OS_GetCurrentSysMs();
	Debug("\n\r∨∨∨∨∨∨ Goto %s ∨∨∨∨∨∨\n\r",gpCurrentPage->Name);
	Debug("##Author:%s\n\r",gpCurrentPage->Author);
	Debug("##Description:%s\n\r",gpCurrentPage->Description);

	Debug("##Page Layers:");
	for(i=1;i<GetCurLayerNum();i++) Debug("%s->",GetPageByIdx(PageLayers[i])->Name); 
	Debug("%s\n\r",GetPageByIdx(PageLayers[i])->Name); 

	if((!(gCurrSysMsg&SM_NoPageInit)) //Q_GotoPage返回值告诉系统不要执行page init
		&&(Q_GetPageByTrack(1)->Type!=POP_PAGE)) //从pop页面返回,也不需要page init
		gCurrSysMsg|=CurrentPageInit(EventType,IntParam,pSysParam);

	if((!(gCurrSysMsg&SM_NoTouchInit))//Q_GotoPage或页面SystemEventHandler函数返回值告诉系统不需要touch init
		&&(Q_GetPageByTrack(1)->Type!=POP_PAGE))	 //从pop页面返回,也不需要touch init
		gCurrSysMsg|=CurrPageCtrlObjInit(EventType,IntParam,pSysParam);	

	if(!(gCurrSysMsg&SM_NoPopReturn)//从前面的函数返回掩码
		&&(Q_GetPageByTrack(1)->Type==POP_PAGE))//前一个页面是pop页面
		gCurrSysMsg|=gpCurrentPage->SysEvtHandler(Sys_PopPageReturn,IntParam,pSysParam);

	switch(GetRegIdByIdx(GetPageIdxByTrack(1)))//判断从哪个页面返回
	{
		case PRID_NumCtrlObjPage: //从num控件页返回
			{
				NUM_CTRL_OBJ *pNumCtrlObj=pSysParam;
				if(gpCurrentPage->NumCtrlObjHander)
					gpCurrentPage->NumCtrlObjHander(pNumCtrlObj->ObjID,pNumCtrlObj->Value,pSysParam);
				else 
					Debug("!!!Not Define Handler Function In Page Struct!!!\n\r");
			}break;
		case PRID_StrCtrlObjPage: //从Str控件页返回
			{
				STR_CTRL_OBJ *pStrCtrlObj=pSysParam;
				STR_BOX_OBJ *pStrBoxObj=pSysParam;
				STR_ENUM_OBJ *pStrEnumObj=pSysParam;
				if(gpCurrentPage->StrCtrlObjHandler)
				{
					if(pStrCtrlObj->Type == SCOT_StrBox)
						gpCurrentPage->StrCtrlObjHandler(pStrBoxObj->ObjID,0,pStrBoxObj->pStrBuf,pSysParam);
					else if(pStrCtrlObj->Type == SCOT_StrEnum)
						gpCurrentPage->StrCtrlObjHandler(pStrEnumObj->ObjID,pStrEnumObj->pStrEnumBuf[pStrEnumObj->Idx],&pStrEnumObj->pStrEnumBuf[pStrEnumObj->Idx+1],pSysParam);
				}
				else 
					Debug("!!!Not Define Handler Function In Page Struct!!!\n\r");
			}break;
		defalut:
			while((OS_GetCurrentSysMs()-TimeMsRecord)<300) OS_TaskDelayMs(50);//循环延时300ms,以避免触摸响应混乱
	}
	
	Q_EnableInput();
	
	Input_Debug("%s end: %s\n\r",__FUNCTION__,gpCurrentPage->Name);
	return gCurrSysMsg;
}