int resist() { unsigned short key; do //¨¾¼u¸õ¶}©l { key=ScanKey(); _delay(3000); }while(key==16); while(ScanKey()!=16); //¨¾¼u¸õµ²§ô return key; }
U0 BlackDiamond() { I64 ch,sc; MenuPush( "File {" " Abort(,CH_SHIFT_ESC);" " Exit(,CH_ESC);" "}" "Play {" " Up(,,SC_CURSOR_UP);" " Down(,,SC_CURSOR_DOWN);" " Left(,,SC_CURSOR_LEFT);" " Right(,,SC_CURSOR_RIGHT);" "}" ); SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$ WinMax; DocCursor; DocClear; Fs->draw_it=&DrawIt; WinBorder; WordStat; Init; try { do { if (ScanKey(&ch,&sc)) { switch (sc.u8[0]) { case SC_CURSOR_RIGHT: x+=10; if (x>=GR_WIDTH) x-=GR_WIDTH; break; case SC_CURSOR_LEFT: x-=10; if (x<0) x+=GR_WIDTH; break; case SC_CURSOR_UP: y-=10; if (y<0) y+=GR_HEIGHT; break; case SC_CURSOR_DOWN: y+=10; if (y>=GR_HEIGHT) y-=GR_HEIGHT; break; } //We don't want keystrokes building-up //in the buf. FlushMsgs; } y=(y+1)%GR_HEIGHT; cur_screen_y=(cur_screen_y+1)%(2048-GR_HEIGHT); Sleep(20); } while (ch!=CH_ESC && ch!=CH_SHIFT_ESC); } catch CatchAll; SettingsPop; MenuPop; }
void TIM6_IRQHandler(void) { #ifdef _DEBUG_ static int t = 0; #endif if (TIM_GetITStatus(TIM6, TIM_IT_Update) != RESET) { #ifdef _DEBUG_ if (t++ >= 1000) { printf("TIM6 IRQ\n"); t = 0; } #endif if (g_en && g_tickgui++ > 10) { ScanKey(); GUI_Exec(); g_tickgui = 0; } g_ucgui_time_ms++; if (g_touch_ms) { g_touch_ms--; if (g_touch_ms == 0) { TP_StartADC(); } } TIM_ClearITPendingBit(TIM6, TIM_IT_Update); } }
/******************************************************************************* * Function Name : timer1_isr * Description : timer1 interrupt per 1ms * Input : None * Output : * Return : None *******************************************************************************/ void timer0_isr(void) { REG32(TMR0_CPND) |= BIT(1); u32Delay_1msCnt++; u32Timer0_1msCnt++; //u32Test_1msCnt++; #if LED_REUSE_ADKEY if(u32Timer0_1msCnt%8 == 7) { if(adc_chk_flag==1) { adc_chk_flag = 2; ADKeyInit(); } } #endif if(u32Timer0_1msCnt%8 == 0) //keep the same timeout as the WDT wakeupt time { #if (USER_CONFIG==CONFIG_AX3251_AIRBORNE) //here not into power save mode #else powerSaveCheck(); #endif ScanKey(0); led_SetStatus(); sd_Detect(); usb20_detect(); { static SYSTEM_STATE prev_state=0xff; if(prev_state != g_SystemState) { prev_state = g_SystemState; //deg_Printf("SYS_State=%d\n",g_SystemState); } } } if((u32Timer0_1msCnt%500)==0) { put_msg(SYSTEM_500MS); OSD_changeFlag = 1; } if((u32Timer0_1msCnt%1000)==0) { #if SOFT_POWER_ON_OFF poweroff_1s_check(); //add for tmp test #endif task_record_1s_check(); //add for md wait some times f_check_rec_video_file_size(); put_msg(SYSTEM_1S); } }
bool Config::LoadKey( char *key, long int &num ) { // Configuration file must be open if ( NULL == m_fIn ) return false; char *a = ScanKey(key); if ( a == NULL ) { return false; } num = strtol( a, NULL, 0 ); return true; }
void Temperature_main(void) { char t_value; char t_string[4]; TopDisp = 13; ClearScreen(); Page0Display(); Print(6,20,"ESC to Exit",1); while(TRUE) { t_value = GetTemperature(); sprintf(t_string, (char*)"%dC", (INT8)t_value); Print(3,52,(INT8U*)t_string,1); if(ScanKey() == K_CANCEL) { TopDisp = 12; //´«¸Ð²Ëµ¥ return; } } }
bool Config::LoadKey( char *key, char *value, int max ) { char *f,*a,*b; // Configuration file must be open if ( NULL == m_fIn ) return false; f = ScanKey( key ); if ( f == NULL ) { //throw("Key Not Found."); //printf("Key not found\n"); return false; } a = strchr(f,'"'); if ( a == NULL ) { //throw("Key Not Text."); //printf("Key Not Text.\n"); return false; } a++; b = strchr(a,'"'); if ( b == NULL ) { //throw("No closing quote"); //printf("No closing quote.\n"); return false; } f = value; while ( ( a != b ) && ( ( f - value ) < max ) ) { *f++ = *a++; } *f=0; return true; }
/*矩阵键盘10ms扫描中断*/ void TIM3_IRQHandler(void) { if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) { TIM_ClearITPendingBit(TIM3, TIM_IT_Update); /*下面是定时器中断到来该做的程序*/ //每次按键扫描都先扫一次(真的一次Once)旋转开关,判断是否与之前的旋转开关值相同, //若不同,则等待5个TIM3定时时间,再次扫一次旋转开关, if(iii == 0) KeyValue = OnceRotaryKey()&0x0F; /*旋转开关处理程序*/ if(KeyValue != RotaryKeyValue_before)//有扫到旋转开关按键值与之前不同,应是真有开关变化 { iii++; if(iii > 5) { u8 temp=KEY_NULL; temp = OnceRotaryKey()&0x0F; if(temp == KeyValue) { if(KeyValue >= KEY_VALUE_6)//0x06->KEY_VALUE_6,KeyValue有0x46,0x47,0x48,0x49,0x4A { RotaryKeyChanged_flag = 1; RotaryKeyValue = (KeyValue&0x0F);//只保留KeyValue中的按键值6-10 RotaryKeyValue_before = RotaryKeyValue;//RotaryKeyValue_before只在前面if(KeyValue != RotaryKeyValue_before)比较用到。 } } iii=0; KEY_LINE_write_high_all(); KeyValue = KEY_NULL;//按键值、状态清零 TIM_Cmd(TIM3, DISABLE);//同时关闭定时器 EXTI->IMR |= Keyboard_EXTI_Line;//同时开放来自线上的中断请求 } } /*软按钮处理程序,及开关抖动处理程序*/ else//若扫到旋转开关按键值与之前相同,可能是旋转开关抖动或有软按键,则扫软按键,若没有软按键,也将TIM3关闭,打开外部中断 { jjj++; KeyValue = ScanKey(); /*开关抖动处理程序*/ if(((KeyValue&0x0F) == KEY_NULL) && jjj > 100+6)//表示无软按键,100表示长按检测次数 (长按键检测阀值为100 所以这里的超时应该大于100) { jjj=0; KEY_LINE_write_high_all(); KeyValue = KEY_NULL;//按键值、状态清零 TIM_Cmd(TIM3, DISABLE);//同时关闭定时器 EXTI->IMR |= Keyboard_EXTI_Line;//同时开放来自线上的中断请求 6789 } /*软按钮处理程序*/ if((KeyValue&0xF0) != 0x00 && (KeyValue&0x0F) < KEY_VALUE_6)//有按键也有状态(短按、长按),其中0x0F->KEY_NULL { jjj=0; SoftKeyChanged_flag = 1; SoftKeyValue_before = SoftKeyValue; SoftKeyValue = (KeyValue&0x0F);//只保留KeyValue中的按键值0-5 if((KeyValue&0xF0)==0x90)//0x90=0b10010000 ShortKey_flag = 1; else if((KeyValue&0xF0)==KEY_LONG) LongKey_flag = 1; KEY_LINE_write_high_all(); KeyValue = KEY_NULL;//按键值、状态清零 TIM_Cmd(TIM3, DISABLE);//同时关闭定时器 EXTI->IMR |= Keyboard_EXTI_Line;//同时开放来自线上的中断请求 } } } }
void Scanner::ScanNextToken() { if (m_endedStream) { return; } if (!m_startedStream) { return StartStream(); } // get rid of whitespace, etc. (in between tokens it should be irrelevent) ScanToNextToken(); // maybe need to end some blocks PopIndentToHere(); // ***** // And now branch based on the next few characters! // ***** // end of stream if (!INPUT) { return EndStream(); } if (INPUT.column() == 0 && INPUT.peek() == Keys::Directive) { return ScanDirective(); } // document token if (INPUT.column() == 0 && Exp::DocStart().Matches(INPUT)) { return ScanDocStart(); } if (INPUT.column() == 0 && Exp::DocEnd().Matches(INPUT)) { return ScanDocEnd(); } // flow start/end/entry if (INPUT.peek() == Keys::FlowSeqStart || INPUT.peek() == Keys::FlowMapStart) { return ScanFlowStart(); } if (INPUT.peek() == Keys::FlowSeqEnd || INPUT.peek() == Keys::FlowMapEnd) { return ScanFlowEnd(); } if (INPUT.peek() == Keys::FlowEntry) { return ScanFlowEntry(); } // block/map stuff if (Exp::BlockEntry().Matches(INPUT)) { return ScanBlockEntry(); } if ((InBlockContext() ? Exp::Key() : Exp::KeyInFlow()).Matches(INPUT)) { return ScanKey(); } if (GetValueRegex().Matches(INPUT)) { return ScanValue(); } // alias/anchor if (INPUT.peek() == Keys::Alias || INPUT.peek() == Keys::Anchor) { return ScanAnchorOrAlias(); } // tag if (INPUT.peek() == Keys::Tag) { return ScanTag(); } // special scalars if (InBlockContext() && (INPUT.peek() == Keys::LiteralScalar || INPUT.peek() == Keys::FoldedScalar)) { return ScanBlockScalar(); } if (INPUT.peek() == '\'' || INPUT.peek() == '\"') { return ScanQuotedScalar(); } // plain scalars if ((InBlockContext() ? Exp::PlainScalar() : Exp::PlainScalarInFlow()) .Matches(INPUT)) { return ScanPlainScalar(); } // don't know what it is! throw ParserException(INPUT.mark(), ErrorMsg::UNKNOWN_TOKEN); }
void stop_watch_main(void){ #else void main(void){ #endif STATE state = START_STATE; initStopWatch(); TIMER3_RUN(FALSE); ClearScreen(); Print(0,5,"--STOP WATCH--",1); Rectangle(2 , 4 , 108 , 7); while(!stopApplication()){ switch (state) { case START_STATE: { t.h = t.m = t.s = 0; overflow = 0; printTime(); if(LanguageSel == 1) { Print6(2,10," OK for START ",1); } else { Print(2,8,"按OK键开始:",1); } if(ScanKey() == K_OK) { while(ScanKey() != 0xff); halWait(5); TIMER3_RUN(TRUE); state = RUN_STATE; if(LanguageSel == 1) { Print6(2,10," OK for STOP ",1); } else { Print(2,8,"按OK键停止:",1); } } }break; case RUN_STATE: { INT_GLOBAL_ENABLE(INT_OFF); if(overflow > 0 && overflow < 0x09) { GLED = LED_ON; } else if(overflow > (UINT16)1000) { //overflow = 0; overflow -= 1000; incrementTime(); printTime(); } else { GLED = LED_OFF; } if(ScanKey() == K_OK) { while(ScanKey() != 0xff); halWait(5); TIMER3_RUN(FALSE); state = STOP_STATE; GLED = LED_OFF; } INT_GLOBAL_ENABLE(INT_ON); }break; case STOP_STATE: { printTime(); if(LanguageSel == 1) { Print6(2,10," Total time is:",1); } else { Print(2,8,"总计时间为:",1); } if(ScanKey() == K_OK) { while(ScanKey() != 0xff); halWait(5); state = START_STATE; } }break; default: break; } } while(ScanKey() != 0xff); halWait(5); INT_GLOBAL_ENABLE(INT_OFF); return; }
// ScanNextToken // . The main scanning function; here we branch out and // scan whatever the next token should be. void Scanner::ScanNextToken() { if(m_endedStream) return; if(!m_startedStream) return StartStream(); // get rid of whitespace, etc. (in between tokens it should be irrelevent) ScanToNextToken(); // check the latest simple key VerifySimpleKey(); // maybe need to end some blocks PopIndentTo(INPUT.column); // ***** // And now branch based on the next few characters! // ***** // end of stream if(INPUT.peek() == EOF) return EndStream(); if(INPUT.column == 0 && INPUT.peek() == Keys::Directive) return ScanDirective(); // document token if(INPUT.column == 0 && Exp::DocStart.Matches(INPUT)) return ScanDocStart(); if(INPUT.column == 0 && Exp::DocEnd.Matches(INPUT)) return ScanDocEnd(); // flow start/end/entry if(INPUT.peek() == Keys::FlowSeqStart || INPUT.peek() == Keys::FlowMapStart) return ScanFlowStart(); if(INPUT.peek() == Keys::FlowSeqEnd || INPUT.peek() == Keys::FlowMapEnd) return ScanFlowEnd(); if(INPUT.peek() == Keys::FlowEntry) return ScanFlowEntry(); // block/map stuff if(Exp::BlockEntry.Matches(INPUT)) return ScanBlockEntry(); if((m_flowLevel == 0 ? Exp::Key : Exp::KeyInFlow).Matches(INPUT)) return ScanKey(); if((m_flowLevel == 0 ? Exp::Value : Exp::ValueInFlow).Matches(INPUT)) return ScanValue(); // alias/anchor if(INPUT.peek() == Keys::Alias || INPUT.peek() == Keys::Anchor) return ScanAnchorOrAlias(); // tag if(INPUT.peek() == Keys::Tag) return ScanTag(); // special scalars if(m_flowLevel == 0 && (INPUT.peek() == Keys::LiteralScalar || INPUT.peek() == Keys::FoldedScalar)) return ScanBlockScalar(); if(INPUT.peek() == '\'' || INPUT.peek() == '\"') return ScanQuotedScalar(); // plain scalars if((m_flowLevel == 0 ? Exp::PlainScalar : Exp::PlainScalarInFlow).Matches(INPUT)) return ScanPlainScalar(); // don't know what it is! throw ParserException(INPUT.line, INPUT.column, ErrorMsg::UNKNOWN_TOKEN); }