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); }
static void LedStep(Direction eDirection) { static unsigned char cStateLed; switch(eDirection){ case LEFT: { cStateLed++; Led_On(cStateLed%4); break; } case RIGHT: { cStateLed--; Led_On(cStateLed%4); break; } } }
void Led_Task(void *parg) { for(;;) { Led_On(0); OSTimeDlyHMSM(0,0,1,500); Led_Off(0); OSTimeDlyHMSM(0,0,1,500); } }
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); }
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_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; }
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; }
//################################################################################################################################ //-------------------------------------------------------------------------------------------------------------------------------- //函数名称:CLevel21_Sure() //-------------------------------------------------------------------------------------------------------------------------------- //函数功能:确认键的第二层第3个任务 //-------------------------------------------------------------------------------------------------------------------------------- //输入参数: tmp为第几个按键的值 //-------------------------------------------------------------------------------------------------------------------------------- //输出参数: null //-------------------------------------------------------------------------------------------------------------------------------- //说 明: //-------------------------------------------------------------------------------------------------------------------------------- //################################################################################################################################ void CLevel23_Sure(uint8 tmp)// { switch(tmp) { case 1://自检 喇叭响完就关闭了 ClearScreen(0); UartCom(CMD_139W,2); //发送心跳命令 SetZjFlag(1); //加声光 Led_On(); DelayMs(10); PWM1_Start(); PWM1_Set( PWM_CYCLE, 0 ); //delay DelayMs(10); PWM1_Stop(); DelayMs(10); PWM1_Start(); PWM1_Set( PWM_CYCLE, 0 ); TestSelf_Menu(); // SetSpeaker_Counter(1); // CLevel27_Sure(); break; case 2://部件信号强度 ClearScreen(0); CompInten_Menu(0,0,0,0); CSetIntenFlag(1); break; default:break; } }
void EVAL_COM1_IRQHandler(void) { static uint8_t state = 0; static uint8_t lencnt = 0; static uint8_t length = 0; static uint8_t flag = 101; uint16_t ch=0; Led_On(LED3); Led_On(LED2); TIM_ITConfig(Tx_TIM,TIM_IT_Update,DISABLE); if(USART_GetFlagStatus(EVAL_COM1, USART_FLAG_RXNE) != RESET) { USART_ClearFlag(EVAL_COM1, USART_FLAG_RXNE); ch = USART_ReceiveData(EVAL_COM1); } switch(state) { case 0: if(ch == flag) { lencnt ++; flag ++; if(lencnt == 10) { flag = 101; lencnt = 0; state = 1; } } else { flag = 101; length = 0; lencnt = 0; state = 0; } break; case 1: gl_RxLen = ch; length = ch; lencnt = 0; state = 2; break; /********有效数字接收*************/ case 2: gl_Buff[lencnt++] = ch; if(lencnt == length) { lencnt = 0; state = 3; } break; /************校验******************/ case 3: if((uint8_t)(~gl_Buff[lencnt]) == ch) { lencnt++; if(lencnt == length) { lencnt = 0; state = 4; } } else { length = 0; lencnt = 0; state = 0; } break; case 4: if(ch == flag ) { flag ++; lencnt++; if(lencnt == 10) { gl_RxRight = 1; //成功接收到10个123,将gl_RxRight置1,state置0,方便下次接收 flag = 101; state = 0; lencnt = 0; } } else { flag = 101; length = 0; lencnt = 0; state = 0; } break; } }
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); } }