Example #1
0
static SYS_MSG PeripheralsHandler(PERIP_EVT PeripEvent, int IntParam, void *pParam)
{	
	switch(PeripEvent)
	{	
		case Perip_KeyPress:
			switch(IntParam){
				case ExtiKeyEnter:
					break;
				case ExtiKeyUp:
					break;
				case ExtiKeyDown:
					break; 
			}break;
		case Perip_KeyRelease:
			switch(IntParam){
				case ExtiKeyEnter:
					//Q_GotoPage(GotoNewPage,"MainPage",-1,NULL);
					//PrtScreen();
					
					break;
				case ExtiKeyUp:
					break;
				case ExtiKeyDown:	
					break; 
			}break;
		case Perip_UartInput:
			if((IntParam>>16)==1)//串口1
			{
				Q_Sh_CmdHandler(IntParam&0xffff,pParam);
			}
			break;
	}

	return 0;
}
Example #2
0
//当实体按键、串口、rtc等外设有动作时,会触发此函数
static SYS_MSG PeripheralsHandler(PERIP_EVT PeripEvent, int IntParam, void *pParam)//外设事件处理函数
{
	switch(PeripEvent)
	{
		case Perip_KeyPress:
			if(IntParam==ExtiKeyEnter)
			{
			
			}
			else if(IntParam==ExtiKeyUp)
			{
				Q_PresentTch(LeftArrowKV,Tch_Press);
			}
			else if(IntParam==ExtiKeyDown)
			{
				Q_PresentTch(RightArrowKV,Tch_Press);
			}
			break;
		case Perip_KeyRelease:
			if(IntParam==ExtiKeyEnter)
			{
				PrtScreen();
			}
			else if(IntParam==ExtiKeyUp)
			{
				Q_PresentTch(LeftArrowKV,Tch_Release);
			}
			else if(IntParam==ExtiKeyDown)
			{
				Q_PresentTch(RightArrowKV,Tch_Release);
			}
			break;
		case Perip_UartInput:
			if((IntParam>>16)==1)//串口1
			{
				Q_Sh_CmdHandler(IntParam&0xffff,pParam);
			}
			break;
	}

	return 0;
}
Example #3
0
static SYS_MSG PeripheralsHandler(PERIP_EVT PeripEvent, int IntParam, void *pParam)
{
	switch(PeripEvent)
	{
		case Perip_KeyPress:
			switch(IntParam){
				case ExtiKey0:
					Debug("Key%d,%d\n\r",ExtiKey0,Perip_KeyPress);
					Q_PresentTch(NextKV,Tch_Press);
					break;
				case ExtiKey1:
					Debug("Key%d,%d\n\r",ExtiKey1,Perip_KeyPress);
					Q_PresentTch(PrevKV,Tch_Press);
					break;
				case ExtiKey2:
					Debug("Key%d,%d\n\r",ExtiKey2,Perip_KeyPress);

					break; 
			}break;
		case Perip_KeyRelease:
			switch(IntParam){
				case ExtiKey0:
					Debug("Key%d,%d\n\r",ExtiKey0,Perip_KeyRelease);
					Q_PresentTch(NextKV,Tch_Release);
					break;
				case ExtiKey1:
					Debug("Key%d,%d\n\r",ExtiKey1,Perip_KeyRelease);
					Q_PresentTch(PrevKV,Tch_Release);
					break;
				case ExtiKey2:
					Debug("Key%d,%d\n\r",ExtiKey2,Perip_KeyRelease);
					Q_GotoPage(GotoNewPage,"AppListPage",0,NULL);
					break; 
			}break;
		case Perip_Timer:			
			break;
		case Perip_RtcMin:		
			DispTime();
			break;
		case Perip_RtcAlarm:	
			Debug("Alarm!!!\n\r");
			break;
		case Perip_LcdOff:
			Debug("LCD bg light disable\n\r");
			break;
		case Perip_LcdOn:
			Debug("LCD bg light enable\n\r");
			DispTime();
			break;
		case Perip_UartInput:
			if((IntParam>>16)==1)//串口1
			{
				Q_Sh_CmdHandler(IntParam&0xffff,pParam);
			}
			if((IntParam>>16)==3)//串口3
			{
				IntParam&=0xffff;

				if(IntParam) Debug("###----Uart3----\n\r%s\n\r###----Uart3----\n\r",(u8 *)pParam);
			}
			break;
	}

	return 0;
}
Example #4
0
static SYS_MSG PeripheralsHandler(PERIP_EVT PeripEvent, int IntParam, void *pParam)
{
	switch(PeripEvent)
	{
		case Perip_KeyPress:
			switch(IntParam){
				case ExtiKeyEnter:
					break;
				case ExtiKeyUp:
					break;
				case ExtiKeyDown:
					break; 
			}break;
		case Perip_KeyRelease:
			switch(IntParam){
				case ExtiKeyEnter:
					//PrtScreen();
					QWA_Show();
					break;
				case ExtiKeyUp:
					break;
				case ExtiKeyDown:
					break; 
			}break;

		case Perip_Timer://轮询检查q网
			Q_TimSet(Q_TIM1,10000,500,TRUE);//5s poll
			if(QWA_GetMyAddr()!=QW_ADDR_DEF)//已经入网
			{
				u8 i;
				
				for(i=0;i<DEVICE_INFO_MAX_CLIENT_RECORD;i++)//检查设备还在不在
				{
					if(gpQwpVar->ClientRecord[i].Addr!=0)
						if(QWA_QueryOnline(gpQwpVar->ClientRecord[i].Addr)==0)//设备不在了
						{Debug("@@ Delete %d\n\r",gpQwpVar->ClientRecord[i].Addr);
							DeleteOneDevice(gpQwpVar->ClientRecord[i].Addr);
						}
						else if(gpQwpVar->ClientRecord[i].Name[0]==0)//没名字的,查询名字 //unfinsh:如果查不到,会一直循环查
						{
							QWA_QueryName(gpQwpVar->ClientRecord[i].Addr);
							Q_TimSet(Q_TIM1,10000,200,TRUE);// 2s poll
							break;
						}
				}
			}

			//看看点击的设备,是否依然没有回应,如果超时,点击无效
			if((gpQwpVar->SelectedAddr) && (gpQwpVar->SelectedAddr!=QW_ADDR_HOST)
				&&	(OS_GetCurrentSysMs()-gpQwpVar->SelectedTimeMs > QWEB_PAGE_SELECT_ACT_WAITING_MS) )
			{
				//DeleteOneDevice(gpQwpVar->SelectedAddr);
				gpQwpVar->SelectedAddr=0;
			}
			break;
			
		case Perip_QWebJoin:
			if(QWA_GetMyAddr()==QW_ADDR_HOST)//做为主机得到从机的query ack
			{
				Debug("QWeb Join [%d]%s\n\r",IntParam,(u8 *)pParam);
				AddOneDevice(IntParam,pParam);
			}
			else if(QWA_GetMyAddr()!=QW_ADDR_DEF)//做为从机,得到主机信息
			{
				u8 Addr;
				u8 MyAddr=QWA_GetMyAddr();
				
				Debug("QWeb Get Host Info [%d]%s\n\r",IntParam,(u8 *)pParam);
				AddOneDevice(IntParam,pParam);

				//轮询在线从机
				QWA_QueryNextOnline(TRUE);
				while((Addr=QWA_QueryNextOnline(FALSE))!=0)
				{
					if(Addr!=MyAddr) AddOneDevice(Addr,NULL);//添加无名设备
				}

				if(gpQwpVar->SelectedAddr==QW_ADDR_HOST)//有选定主机作为对话地址,正在等待主机info
				{
					gpQwpVar->SelectedAddr=0;
					Q_GotoPage(gpQwpVar->GotoAct_List,gpQwpVar->GotoName_List,IntParam,pParam);
				}
			}
			break;
		case Perip_QWebQueryName:
			Debug("QWeb Query [%d]%s\n\r",IntParam,(u8 *)pParam);
			AddOneDevice(IntParam,pParam);

			if(IntParam==gpQwpVar->SelectedAddr)//有选定地址,正在等待query ack
			{
				gpQwpVar->SelectedAddr=0;
				Q_GotoPage(gpQwpVar->GotoAct_List,gpQwpVar->GotoName_List,IntParam,pParam);
			}
			break;
		case Perip_QWebRecv://收到信息
			HighLightOneDevice(IntParam>>24);
			break;

		case Perip_UartInput:
			if((IntParam>>16)==1)//串口1
			{
				Q_Sh_CmdHandler(IntParam&0xffff,pParam);
			}
			break;
	}

	return 0;
}
Example #5
0
os_err_t  Q_Sh_rx_callback(char data)
{
    char Recieve=data;
    // osmemset(&shell,0,sizeof(struct finsh_shell));
    if (Recieve == 0x1b)
    {
        shell.status = WAIT_SPEC_KEY;
        goto end;
    }
    else if (shell.status == WAIT_SPEC_KEY)
    {
        if (Recieve == 0x5b)
        {
            shell.status = WAIT_FUNC_KEY;
            goto end;
        }
        
        shell.status = WAIT_NORMAL;
    }
    else if (shell.status == WAIT_FUNC_KEY)
    {
        shell.status = WAIT_NORMAL;
        
        if (Recieve == 0x44) /* left key */
        {
            if (shell.line_curpos)
            {
                printf("\b");
                shell.line_curpos --;
            }
            
            goto end;
        }
        else if (Recieve == 0x43) /* right key */
        {
            if (shell.line_curpos < shell.line_position)
            {
                printf("%c", shell.line[shell.line_curpos]);
                shell.line_curpos ++;
            }
            goto end;
            
        }
        
    }
    
    
    if(Recieve==13)//»Ø³µ
    {
        
        shell.line[shell.line_position]=0;
        printf("\n\r");	
        if(shell.line_position>0||!(shell.ifpass))
        {	
            Q_Sh_CmdHandler(0,shell.line);
        }
        shell.line_position=0;
        shell.line_curpos=0;
        printf("\n\rWSHOS>>");
    }
    /* handle backspace key */
    else if(Recieve == 0x7f || Recieve == 0x08)//»Øɾ
    {
        if(shell.line_curpos>0)
        {
            shell.line_position--;
            shell.line_curpos--;
            if (shell.line_position > shell.line_curpos)
            {
                u16 i;
                os_memmove(&shell.line[shell.line_curpos],
                        &shell.line[shell.line_curpos + 1],
                        shell.line_position - shell.line_curpos);
                shell.line[shell.line_position] = 0;
                
                printf("\b%s  \b", &shell.line[shell.line_curpos]);
                
                /* move the cursor to the origin position */
                for (i = shell.line_curpos; i <= shell.line_position; i++)
                    printf("\b");
            }else
            {
                shell.line[(shell.line_position)]=0;
                printf("\b \b");	
            }
            
        }
    }
    if(shell.line_position>=SHELL_CMD_SIZE)
    {				
        shell.line_position=0;//³¬³ö·¶Î§£¬¾ÍÍ£Ö¹¼ÓÈëеÄÁË¡£
        shell.line_curpos=0;//³¬³ö·¶Î§£¬¾ÍÍ£Ö¹¼ÓÈëеÄÁË¡
    }
    if(Recieve>=0x20)
    {
        
        
        if (shell.line_position > shell.line_curpos)
        {
            u16 i;
            
            os_memmove(&shell.line[shell.line_curpos + 1],
                    &shell.line[shell.line_curpos],
                    shell.line_position - shell.line_curpos);
            shell.line[shell.line_curpos] = Recieve;
            shell.line[shell.line_position+1] = 0;
            printf("%s", &shell.line[shell.line_curpos]);
            
            /* move the cursor to the origin position */
            for (i = shell.line_curpos; i < shell.line_position; i++)
                printf("\b");
        }else
        {
            shell.line[(shell.line_position)]=Recieve;
            shell.line[shell.line_curpos+1] = 0;						
            printf("%c",Recieve);			
        }
        
        shell.line_position++;
        shell.line_curpos++;
    }
    
    
    
    
end:   
    return SUCCESS;
}