예제 #1
0
파일: app.c 프로젝트: yuiopt/uCOSII-Demo
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);//刪除自己
}
예제 #2
0
파일: Menu.c 프로젝트: diewindowsdie/fc-510
void Mnu_Main(bool ini)
{
  //draw menu:
  if(ini)                        //if redraw needed
  {
    Show_Main(Par[PAR_MODE]);    //draw main menu
    MenuTimer = ms2sys(T_BLINK); //load blink timer
    DispMenu = Menu;             //menu displayed
  }
  //blink display in hold mode:
  if(Hold && !MenuTimer)
  {
    Hide = !Hide;
    DispMenu = MNU_NO;           //redraw menu
  }
  //display measured value:
  if(Count_Ready())              //check counter ready
  {
    DispMenu = MNU_NO;           //redraw menu
  }
#ifdef LCD1602
  if(Meter_Updated())
  {
    Meter_Display();             //display meter line
  }
#endif
  //MENU key:
  if(KeyCode == KEY_MN)
  {
    if(Hold)
    {
      Hold = 0;                  //off hold mode
      Hide = 0;                  //show display
      Count_Start();             //start counter (no stat. clear!)
      DispMenu = MNU_NO;         //redraw menu
    }
    else
    {
#ifdef LCD1602
      Meter_Clear();
#endif
      Param = PAR_MODE;          //param index
      Menu = MNU_SETUP;          //go to setup menu
    }
    KeyCode = KEY_NO;            //key code processed
  }
  //MENU + OK key:
  if(KeyCode == KEY_MK)
  {
#ifdef LCD1602
    Meter_Clear();
#endif
    Param = PAR_RF;              //param index (calibrate)
    Menu = MNU_SETUP;            //go to setup menu
    KeyCode = KEY_NO;            //key code processed
  }
  //OK key:
  if(KeyCode == KEY_OK)
  {
    Hold = !Hold;                //on/off hold mode
    Hide = Hold;                 //hide display value if hold
    if(Hold)
    {
      Count_Stop();              //stop counter if hold
    }
    else
    {
      Count_ClearStat();         //clear statistics
      Count_Start();             //start counter
    }
    DispMenu = MNU_NO;           //redraw menu
    KeyCode = KEY_NO;            //key code processed
  }
  //UP/DOWN key:
  if(KeyCode != KEY_NO)
  {
    if(MoveDP(KeyCode))          //shift DP
    {
      Count_SetScale(Scale);     //set new scale
      EScale[Par[PAR_MODE]] = Scale; //save scale to EEPROM
      DispMenu = MNU_NO;         //redraw menu
      if(KeyCode == KEY_UD)      //UP + DOWN pressed,
        Menu = MNU_AUTO;         //go to auto scale menu
      KeyCode = KEY_NO;          //key code processed
    }
  }
}
예제 #3
0
파일: app.c 프로젝트: yuiopt/uCOSII-Demo
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);
	}
}