static void display_redraw(void) { xSemaphoreTake(lcdLock, portMAX_DELAY); GLCD_clear(White); xSemaphoreGive(lcdLock); display_buttons(); }
void main(void) { u16 i; u8 shortcut = KEY_INVALID; // RS485 Node init_var(); //init data structure // System Initialization Init_Port(); // Init_Timers(); // Init_Ex_Interrupt(); Init_UART(); Enable_XMEM(); Init_554(); InitLED(); Key_Init(); // Global enable interrupts WDTCR = 0x00; //disable dog watch #asm("sei") /*********************************************************************/ // System hardware dection /*********************************************************************/ // intialize LED. nextwin = 0; sleepms(20*ONEMS); LCD_Init(); wnd_msgbox(&bootup); //init the DMM nav_command(NAV_INIT); sleepms(200*ONEMS); navto1v(); nav_command(NAV_SLOWMODE); sleepms(200*ONEMS); nav_command(NAV_AFLTON); sleepms(200*ONEMS); sleepms(2*ONEMS); //wait until all the node is ready after power up State_Init(); SET_BORE_MODE; nextwin = PG_BOOTTYPE; key = KEY_INVALID; curr_ch = 1; //channel for display curr_dispch = 1; while(1) { if(nextwin != 0) { SwitchWindow(nextwin); (*curr_window)(MSG_INIT); nextwin = 0; } if(key != KEY_INVALID) { if((key == KEY_BTN1)||(key == KEY_BTN2)||(key == KEY_BTN3)||(key == KEY_BTN4)) { shortcut = key; //processing shortcut key if(curr_window == pgmain_handler) { LCD_Cls(); wnd_msgbox(&modify); } if(shortcut == KEY_BTN1) //mode switch { SET_TOP1MA; SET_TOPT1000; if(IS_BORE_MODE){ SET_THERM_MODE; }else{ SET_BORE_MODE; } dlg_cnt = 0; onesec_cnt = 0; phase = 0; //reset the state machine } if(shortcut == KEY_BTN2) //auto ktt or not { if(IS_BORE_MODE) { SET_TOP1MA; SET_TOPT1000; if((IS_MODE_KTT)){ CLR_MODE_KTT; SET_PKTT; }else{ SET_MODE_KTT; SET_PKTT; } dlg_cnt = 0; onesec_cnt = 0; phase = 0; //reset the state machine } } if(shortcut == KEY_BTN3) //thermal probe type { display_buttons(KEY_BTN3,1); if(IS_THERM_MODE) { i = sysdata.tid[curr_dispch-1]; if(i != INVALID_PROBE) { if((tprbdata.type[i] >= PRBTYPE_K) &&\ (tprbdata.type[i] <= PRBTYPE_R)) { if(tprbdata.type[i] == PRBTYPE_R) tprbdata.type[i] = PRBTYPE_K; else tprbdata.type[i] +=1; } if(rundata.reading[curr_dispch-1] > -9000) rundata.temperature[curr_dispch-1] = MValueToTValue(rundata.reading[curr_dispch-1], tprbdata.type[i]); } } display_buttons(KEY_BTN3,0); } if(shortcut == KEY_BTN4) //remove zero { display_buttons(KEY_BTN4,1); if(IS_BORE_MODE){ sysdata.R0 = rundata.Rx; }else{ //sysdata.V0 = nav_read(); nav_command(NAV_ZEROON); sleepms(1000*ONEMS); } display_buttons(KEY_BTN4,0); } if(curr_window == pgmain_handler) //redraw the running window { pgmain_handler(MSG_INIT); } shortcut = KEY_INVALID; }else{ (*curr_window)(key); } key = KEY_INVALID; }else{ if(curr_window != pgmain_handler) continue; if(dlg_cnt > 1) { onesec_cnt++; if(onesec_cnt == (ONESEC-10)) { updatestate(); } if(onesec_cnt == ONESEC) onesec_cnt = 0 ; dlg_cnt--; continue; } updatestate(); if((IS_THERM_MODE)) { if(therm_state() == 0) continue; }else{ if(bore_state() == 0) continue; } //shift to next channel while(true) { ch_to_search += 1; if(ch_to_search >= MAX_CH_NUM) { ch_to_search = 0; break; } if(IS_THERM_MODE) { i = sysdata.tid[ch_to_search]; }else{ i = sysdata.rid[ch_to_search]; } if(i == INVALID_PROBE) continue; if(IS_THERM_MODE) { if((tprbdata.type[i] >= PRBTYPE_K) && (tprbdata.type[i] <= PRBTYPE_R)) break; }else{ if((rprbdata.type[i] <= PRBTYPE_MAX) && (rprbdata.type[i] >= PRBTYPE_MIN)) break; } } } } }