Example #1
0
void Startup_Task(void *parg)
{
	Show_Main(0,0,0,0);
	Led_Off(0);
	Led_Off(1);
	OSTaskSuspend(CURSOR_TASK_PRIO);
	OSTaskSuspend(TIMER_TASK_PRIO);
	OSTaskSuspend(ADC_TASK_PRIO);
	OSTaskDel(STARTUP_TASK_PRIO);//刪除自己
}
void Motion_window()
{
	T_UBYTE lub_validPress = 0;

	/* Evaluate press down */
	if( !PButt_Press(PBUTT_DOWN) )
	{
		lub_validPress = Valid_Press(PBUTT_DOWN);
		if( lub_validPress == 1 )
		{
			Motion_Window_Down(PBUTT_DOWN);
			
		}
		lub_validPress = 0;
	}
	/* Evaluate press up */
	if( !PButt_Press(PBUTT_UP) )
	{
		Led_Off(LED_GREEN_DOWN);
		lub_validPress = Valid_Press(PBUTT_UP);
		if( lub_validPress == 1 )
		{
			Motion_Window_Up(PBUTT_UP);
		}
		lub_validPress = 0;
	}
	
}
Example #3
0
void Input_Task(void *parg)
{
	u8 err;
	OS_CPU_SR cpu_sr;
	for(;;)
	{
		OSSemPend(PENIRQ,0,&err);
		Exti_Set(0);
		OS_ENTER_CRITICAL();
		touch.FLAG=Read_XY_2(&touch.AD_X,&touch.AD_Y);
		OS_EXIT_CRITICAL();
		if(touch.FLAG)
		{
			touch.FLAG=0;
			touch.LCD_X=CalcXY(touch.AD_X,0);
			touch.LCD_Y=CalcXY(touch.AD_Y,1);
			Set_Color(BLACK,GREEN);
			Show_String(">>AD_X:",2,22);
			Show_Dec(touch.AD_X,4,58,22);
			Show_String("AD_Y:",98,22);
			Show_Dec(touch.AD_Y,4,138,22);
			
			Show_String(">>LCD_X:",2,38);
			Show_Dec(touch.LCD_X,4,66,38);
			Show_String("LCD_Y:",106,38);
			Show_Dec(touch.LCD_Y,4,154,38);
		}
		Led_Off(1);
	}
}
T_SBYTE Mov_Anti_Pinch(T_SBYTE lsb_led)
{
	Led_On(LED_GREEN_DOWN);
	Led_Off(LED_BLUE_UP);
	//
	do
	{
		Led_Off(lsb_led);
		Restart_STM(TM_400MS);
		while( !Flag_STM(TM_400MS) );
		lsb_led++;
	}while(lsb_led <= 9);
	Led_Off (LED_GREEN_DOWN);
	Restart_STM(TM_5S);
	while( !Flag_STM(TM_5S) );
	return lsb_led;
}
void Mov_Auto_Up()
{
	T_UBYTE lub_apinch = 0;
	Led_Off(LED_GREEN_DOWN);
	do
	{
		Led_Off(LED_GREEN_DOWN);
		Led_On(rub_Led);
		Restart_STM(TM_400MS);
		while( !Flag_STM(TM_400MS) );
		rub_Led--;
		if( !PButt_Press(PBUTT_APINCH) )//revisar antipinch
		{
		  rub_Led = Mov_Anti_Pinch(rub_Led);
		  lub_apinch = 1;
		}
	}while( rub_Led >= 0 && lub_apinch == 0 && PButt_Press(PBUTT_DOWN));
	lub_apinch = 0;
}
void Motion_Window_Up()
{
	
	Restart_STM(TM_500MS);
	Led_Off(LED_GREEN_DOWN);
	while( !Flag_STM(TM_500MS) );
	/*Evaluate auto/manual press*/
	if( !PButt_Press(PBUTT_UP) && PButt_Press(PBUTT_DOWN))
	{
		Led_On(LED_BLUE_UP);
		Mov_Manual_Up();
	}
	else
	{
		Led_On(LED_BLUE_UP);
		Mov_Auto_Up();
	}
	Led_Off(LED_BLUE_UP);
}
void Mov_Auto_Down()
{
	//
	do{
		Led_Off(rub_Led);
		Restart_STM(TM_400MS);
		while( !Flag_STM(TM_400MS) );
		rub_Led++;
	}while( rub_Led <= 9 && PButt_Press(PBUTT_UP));
}
Example #8
0
void Led_Task(void *parg)
{
	for(;;)
	{
		Led_On(0);
		OSTimeDlyHMSM(0,0,1,500);
		Led_Off(0);
		OSTimeDlyHMSM(0,0,1,500);
	}
}
void Mov_Manual_Down()
{
	do
	{
		Led_Off(rub_Led);
		Restart_STM(TM_400MS);
		while( !Flag_STM(TM_400MS) );
		rub_Led++;
	}while( !PButt_Press(PBUTT_DOWN) && rub_Led <= 9 && PButt_Press(PBUTT_UP));

}
void Mov_Manual_Up()
{	
	T_UBYTE lub_apinch = 0;
	do
	{
		Led_Off(LED_GREEN_DOWN);
		Led_On(rub_Led);
		Restart_STM(TM_400MS);
		while( !Flag_STM(TM_400MS) );
		rub_Led--;
		if( !PButt_Press(PBUTT_APINCH) )
		{
		  rub_Led = Mov_Anti_Pinch(rub_Led);
		  lub_apinch = 1;
		}
	}while( !PButt_Press(PBUTT_UP) && rub_Led >= 0 && PButt_Press(PBUTT_DOWN));
	lub_apinch = 0;
}
Example #11
0
void CLevel23_Return(void)
{
	//switch(vCounter[1])
	switch(GetCounter2())
	{
        case 1://自检 返回 检测蜂鸣器标志是否已经打开 ,如果已经打开,则开启
			Led_Off();
				

//             if(GetSpeakerClick())
//             {
//                 SetAlarmFlag(0,1);
//             }
            //delay

            DelayMs(10);
            PWM1_Stop();
            PWM1_Set(0,0);
            DelayMs(10);
            BEEPOn();
            PWM1_Start();
            PWM1_Set( PWM_CYCLE, 0 );
            DelayMs(10);
            PWM1_Stop();
            PWM1_Set(0,0);

      
            SetZjFlag(0);//中断里打开喇叭响检测
				
            ClearScreen(0);
			Test_Menu(1);
//			SetSpeaker_Counter(0);
//			CLevel27_Sure();
			break;
		case 2:
			CSetIntenFlag(0);
			ClearScreen(0);
			Test_Menu(2);
			break;
		default:break;		
	}	
	SetCounter3(1);
 	//vCounter[2] = 1;
}
void Motion_Window_Down()
{
	
	Restart_STM(TM_500MS);
	while( !Flag_STM(TM_500MS) );
	
	if( !PButt_Press(PBUTT_DOWN) &&  PButt_Press(PBUTT_UP))
	{
		Led_On(LED_GREEN_DOWN);
		Mov_Manual_Down();
		
	}
	else
	{
		Led_On(LED_GREEN_DOWN);
		Mov_Auto_Down();

	}
	Led_Off(LED_GREEN_DOWN);
}
Example #13
0
void Input_Task(void *parg)
{
	u8 err;
	u8 OK=0;
	u8 buffer[4]={0};
	u8 LEN=0;
	u8 flag=0;
	u16 e=0;
	OS_CPU_SR cpu_sr;
	(void)parg;
	for(;;)
	{
		OSSemPend(PENIRQ,0,&err);
		Exti_Set(0);
		OS_ENTER_CRITICAL();
		touch.FLAG=Read_XY_2(&touch.AD_X,&touch.AD_Y);
		OS_EXIT_CRITICAL();
		if(touch.FLAG)
		{
			Led_On(1);
			touch.FLAG=0;
			touch.LCD_X=CalcXY(touch.AD_X,0);
			touch.LCD_Y=CalcXY(touch.AD_Y,1);
			touch.KEY=Get_Key(touch.PID,touch.LCD_X,touch.LCD_Y);
			if(touch.KEY<=10)
			{
				OS_ENTER_CRITICAL();
				Set_Color(WHITE,BLACK);
				if(touch.KEY==10)
					Show_Char('.',cursor.x,cursor.y);
				else
				{
					Show_Dec(touch.KEY,1,cursor.x,cursor.y);
					if(LEN<4)
					{
						buffer[LEN]=touch.KEY;
						LEN++;
					}
				}
				if(cursor.x<224)
				{
					cursor.x+=8;
					if(cursor.x>=224)
						cursor.x=224;
				}
				OS_EXIT_CRITICAL();
			}
		
			else if(touch.KEY==11)
			{
				OK++;
				if(OK==1)
				{
					VALUE1=CalcDec(buffer,LEN);
					Set_Color(BLACK,GREEN);
					Show_String(">>VALUE1:",2,22);
					Show_Dec(VALUE1,LEN,82,22);
					OS_ENTER_CRITICAL();
					LCD_Clear(4,121,232,38,WHITE);
					cursor.x=8;
					cursor.y=132;
					OS_EXIT_CRITICAL();
					buffer[0]=0;
					buffer[1]=0;
					buffer[2]=0;
					buffer[3]=0;
					LEN=0;
				}
				else if(OK==2)
				{
					VALUE2=CalcDec(buffer,LEN);
					Set_Color(BLACK,GREEN);
					Show_String(">>VALUE2:",2,38);
					Show_Dec(VALUE2,LEN,82,38);
					OS_ENTER_CRITICAL();
					LCD_Clear(4,121,232,38,WHITE);
					cursor.x=8;
					cursor.y=132;
					OS_EXIT_CRITICAL();
					buffer[0]=0;
					buffer[1]=0;
					buffer[2]=0;
					buffer[3]=0;
					LEN=0;
				}
				else if(OK==3)
				{
					VALUE3=CalcDec(buffer,LEN);
					Set_Color(BLACK,GREEN);
					Show_String(">>VALUE3:",2,54);
					Show_Dec(VALUE3,LEN,82,54);
					OS_ENTER_CRITICAL();
					LCD_Clear(4,121,232,38,WHITE);
					cursor.x=8;
					cursor.y=132;
					OS_EXIT_CRITICAL();
					buffer[0]=0;
					buffer[1]=0;
					buffer[2]=0;
					buffer[3]=0;
					LEN=0;
				}
			
				else if(OK==4)
				{
					if(VALUE2>0&&VALUE2<=5000)
					{
						if(VALUE1<VALUE2&&VALUE1>0)
						{
							if(VALUE3>0&&VALUE3<10000)
							{
								e=0;
								Set_Color(BLACK,GREEN);
								Show_String(">>OK!",2,70);
							}
							else
							{
								e=1;
							}
						}
						else
						{
							e=1;
						}
					}
					else
					{
						e=1;
					}

					if(e)	
					{
						Set_Color(BLACK,GREEN);
						Show_String(">>ERROR!",2,70);
					}
				}
				else if(OK==5)
				{
					if(!e)
					{
						OK=0;
						OSTaskSuspend(CURSOR_TASK_PRIO);
						Show_Main(VALUE1,VALUE2,VALUE3,1);
					}
					else
					{
						OK=0;
						e=0;
						LCD_Clear(2,20,236,100,BLACK);
						LCD_DrawEdit(input);
						Set_Cursor(8,132);
					}
					VALUE1=0;
					VALUE2=0;
					VALUE3=0;
				}
				else;
			}
		
			else if(touch.KEY==12)
			{
				OS_ENTER_CRITICAL();
			
				if(LEN>0)
				{
					LEN--;
				}
						
				if(cursor.x>=8) 
				{	
					LCD_Clear(cursor.x,cursor.y,8,16,WHITE);
					cursor.x-=8;
					if(cursor.x<8)
					{
						cursor.x=8;
					}
				}	
				OS_EXIT_CRITICAL();
			}
		
			else if(touch.KEY==13)
			{
				if(flag==0)
				{
					flag=1;
					button1.str="stop";
					button1.len=4;
					button1.line_color=GREEN;
					LCD_DrawButton(button1);
					OSTaskResume(TIMER_TASK_PRIO);
				}
				else
				{
					flag=0;
					button1.str="start";
					button1.len=5;
					button1.line_color=BLACK;
					LCD_DrawButton(button1);
					OSTaskSuspend(TIMER_TASK_PRIO);
				}
			}
		
			else if(touch.KEY==14)
			{
				OSTaskSuspend(TIMER_TASK_PRIO);
				Show_KeyMap();
				OSTaskResume(CURSOR_TASK_PRIO);
			}
			
			else if(touch.KEY==99)//無效輸入
			{}
			else;
			OSTimeDlyHMSM(0,0,0,50);
			Led_Off(1);
		}
		Exti_Set(1);
	}
}