예제 #1
0
파일: main.c 프로젝트: AntonLynnyk/Embedded
int main(void)
{
    InitLED();
    LCD_Initialize();

    RefreshLEDState(true, LED_MAX_BRIGHTNESS);
    Delay_ms(1000);
    RefreshLEDState(false, LED_MAX_BRIGHTNESS);

    while(true)
    {
        //LED_PORT->BSRR = LED_PIN;
        LCDFillScreen(0xFF, 0x00, 0x00);
        Delay_ms(1000);

        //LED_PORT->BRR = LED_PIN;
        LCDFillScreen(0x00, 0xFF, 0x00);
        Delay_ms(1000);

        //LED_PORT->BSRR = LED_PIN;
        LCDFillScreen(0x00, 0x00, 0xFF);
        Delay_ms(1000);

        //LED_PORT->BRR = LED_PIN;
        LCDFillScreen(0xFF, 0xFF, 0xFF);
        Delay_ms(1000);
    }
}
예제 #2
0
int main(void) {
	int counter = 0;
	
	ConsoleIO_Init();
	InitLED();
  printf("Hello world!\r\n");
	for(;;) {	   
	  counter++;
#if DEMO_GETS /* enable this to use gets() too */
	  printf("Enter a string:\r\n");
    if (gets(buffer)!=NULL) {
      printf("you entered: %s\r\n", buffer);
    }
    NegLED();
#else
	  printf("counter: %d\r\n", counter);
#if DEMO_USE_FLOAT
    printf("float value: %f\r\n", 3.75f);
#endif
    if ((counter%32)==0) { /* blink LED slowly so it is better visible */
      NegLED();
    }
#endif
	}
	return 0;
}
예제 #3
0
파일: main.c 프로젝트: Fabless/FRDM-KL25Z
int main(void) {
  int counter = 0;
  int buffer[1024];

  InitLED();
  InitADC();
  for(;;) {	   
    counter++;

    buffer[counter%1024]=singleCapture()-32768;
    // wait();
    if ((counter%1024)==0) { /* blink LED slowly so it is better visible */
      NegLED();
    }
    // buffer[counter%64]=counter;
    /* printf("Enter a string:\r\n");

    if (gets(buffer)!=NULL)
    {
		printf("you entered: %s\r\n", buffer);
    }
    */
  }	
  return 0;
}
예제 #4
0
int main(void) {
  InitLED();
  
  RED_ON();
  RED_OFF();
  RED_TOGGLE();
  RED_OFF();
  
  GREEN_ON();
  GREEN_OFF();
  GREEN_TOGGLE();
  GREEN_OFF();

  BLUE_ON();
  BLUE_OFF();
  BLUE_TOGGLE();
  BLUE_OFF();

  if (xTaskCreate(
        MainTask,  /* pointer to the task */
        (signed char *)"Main", /* task name for kernel awareness debugging */
        configMINIMAL_STACK_SIZE, /* task stack size */
        (void*)NULL, /* optional task startup argument */
        tskIDLE_PRIORITY,  /* initial priority */
        (xTaskHandle*)NULL /* optional task handle to create */
      ) != pdPASS) {
    /*lint -e527 */
    for(;;){}; /* error! probably out of memory */
    /*lint +e527 */
  }
  vTaskStartScheduler(); /* does not return */
	return 0;
}
예제 #5
0
static void InitializeSystem(void)
{
	char result = 0;
	
	// initialize not used pins to inputs
	DDRD &= ~((1<<0) | (1<<1));
	DDRB &= ~((1<<4) | (1<<5) | (1<<6) | (1<<7));
	
	InitLED();
	
	result |= DINs_Initialize();
	result |= AINs_Initialize();
	result |= DOUTs_Initialize();
	result |= I2C_Address_Initialize();
	result |= I2C_FSM_Initialize();
	
	// check for error
	if(result) {
		uint32_t delay;
		
		while(1)
		{
			delay = 10000;
			while(delay--);
		
			ToggleLED();
		}		
	}
	
	sei(); /* enable interrupts */
}
예제 #6
0
bool ProjectInitWithID(CHIP_INFO chipinfo,int Index) // by designated ID
{
    DownloadAddrRange.start=0;
    DownloadAddrRange.end=Chip_Info.ChipSizeInByte;
    InitLED(Index);
//    SetTargetFlash(g_StartupMode,Index); //for SF600 Freescale issue
    SetProgReadCommand();
	if(strcmp(g_parameter_vcc,"NO") == 0)
	{
		switch(Chip_Info.VoltageInMv)
		{
			case 1800:
				g_Vcc=vcc1_8V;
				break;
			case 2500:
				g_Vcc=vcc2_5V;
			case 3300:
			default:
				g_Vcc=vcc3_5V;
				break;
		}
	}

    return true;
}
예제 #7
0
파일: main.c 프로젝트: dhruv-saxena/cookoo
int main(void) {
    uint16_t tempSensor, battery;
    uint8_t capPushA, capPushB;
    uint8_t it=1;

    InitWDT();
    InitCLOCK();
    InitUART();
    InitLED();
    InitADC();
    InitBuzzer();
    InitCapPush();
    
    EnableInterrupts();
    while (1) {
        it--;
        if(it == 0) {
            it = 4;
            capPushA = senseCapPushA(); 
            capPushB = senseCapPushB(); 
            tempSensor = ReadTemp();
            battery = ReadBattery(); 
            MainLoop(capPushA, capPushB, tempSensor, battery);
        }
        SetupWDTToWakeUpCPU(2); // Wake up in 16 mS
        Sleep();
    }
    return 0;
}
예제 #8
0
파일: hardware.c 프로젝트: GevenM/giip
void InitHardware(){
	#ifdef __MSP430_HAS_PORT1_R__
		GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_ALL);
		GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_ALL);
	#endif

	#ifdef __MSP430_HAS_PORT2_R__
		GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_ALL);
		GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_ALL);
	#endif

	#ifdef __MSP430_HAS_PORT3_R__
		GPIO_setOutputLowOnPin(GPIO_PORT_P3, GPIO_ALL);
		GPIO_setAsOutputPin(GPIO_PORT_P3, GPIO_ALL);
	#endif

	#ifdef __MSP430_HAS_PORT4_R__
		GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_ALL);
		GPIO_setAsOutputPin(GPIO_PORT_P4, GPIO_ALL);
	#endif

	#ifdef __MSP430_HAS_PORT5_R__
		GPIO_setOutputLowOnPin(GPIO_PORT_P5, GPIO_ALL);
		GPIO_setAsOutputPin(GPIO_PORT_P5, GPIO_ALL);
	#endif

	#ifdef __MSP430_HAS_PORT6_R__
		GPIO_setOutputLowOnPin(GPIO_PORT_P6, GPIO_ALL);
		GPIO_setAsOutputPin(GPIO_PORT_P6, GPIO_ALL);
	#endif

	#ifdef __MSP430_HAS_PORT7_R__
		GPIO_setOutputLowOnPin(GPIO_PORT_P7, GPIO_ALL);
		GPIO_setAsOutputPin(GPIO_PORT_P7, GPIO_ALL);
	#endif

	#ifdef __MSP430_HAS_PORT8_R__
		GPIO_setOutputLowOnPin(GPIO_PORT_P8, GPIO_ALL);
		GPIO_setAsOutputPin(GPIO_PORT_P8, GPIO_ALL);
	#endif

	#ifdef __MSP430_HAS_PORT9_R__
		GPIO_setOutputLowOnPin(GPIO_PORT_P9, GPIO_ALL);
		GPIO_setAsOutputPin(GPIO_PORT_P9, GPIO_ALL);
	#endif

	#ifdef __MSP430_HAS_PORTJ_R__
		GPIO_setOutputLowOnPin(GPIO_PORT_PJ, GPIO_ALL);
		GPIO_setAsOutputPin(GPIO_PORT_PJ, GPIO_ALL);
	#endif


	InitLED();
	InitUserInputButtons();
	InitBubbleSensor();
	InitOcclusionSensor();
	InitReservoirLevelPins();
	InitMotor();
}
예제 #9
0
파일: main.c 프로젝트: Bicknellski/klondike
void UserInit(void)
{
    InitLED();
    InitTempSensor();
    InitFAN();
    InitWorkTick();
    //InitI2CMaster();
    InitResultRx();
    DetectAsics();

}//end UserInit
예제 #10
0
int main(void) {
  int counter = 0;
	
  InitLED();
  for(;;) {	   
    counter++;
    wait();
    if ((counter%128)==0) { /* blink LED slowly so it is better visible */
      NegLED();
    }
  }	
  return 0;
}
예제 #11
0
파일: main.c 프로젝트: AntonLynnyk/Embedded
int main(void)
{
  InitLED();
  RefreshLEDState(true, LED_MAX_BRIGHTNESS);
  LCD_Initialize();
  InitializeNRF24L01();

  ConfigureButtons(&leftButton, &rightButton, &upButton, &downButton);
  InitializeButtons();

  InitializeFileSystem();
  StartReceiveImages();
  return 0;
}
예제 #12
0
파일: main.c 프로젝트: z9u2k/remote
/**
 * prepare system on boot
 */
static void InitializeSystem(void) {
    #if defined(__18CXX)
        SetupTimer();
        INTCONbits.GIEH = 1;
    #endif
    
    InitLED();
    LED_Off();

    InitReceiver();
    ReceiverOff();
    
    USBDeviceInit();
}
예제 #13
0
int main(void)
{
	int counter = 0;
	
	ConsoleIO_Init();
	InitLED();
	for(;;) {	   
	  counter++;
	  printf("Hello world!\r\n");
	  if ((counter%32)==0) {
      NegLED();
	  }
	}
	
	return 0;
}
예제 #14
0
/********************************************************************
* Function: 	main()
*
* Precondition: 
*
* Input: 		None.
*
* Output:		None.
*
* Side Effects:	None.
*
* Overview: 	Main entry function. If there is a trigger or 
*				if there is no valid application, the device 
*				stays in firmware upgrade mode.
*
*			
* Note:		 	None.
********************************************************************/
INT main(void)
{
	UINT pbClk;
        UINT bSoftResetFlag = 0;

	// Setup configuration
	pbClk = SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);
	
	InitLED();

    TRISBbits.TRISB15 = 1;//test

    bSoftResetFlag = *(unsigned int *)(NVM_DATA);
    if(bSoftResetFlag == 1)
    {
        NVMErasePage((void*)NVM_DATA);
        NVMWriteWord((void*)(NVM_DATA), (unsigned int)0x00);
    }

	// Enter firmware upgrade mode if there is a trigger or if the application is not valid
	if(bSoftResetFlag == 1 || CheckTrigger() || !ValidAppPresent())
	{
		// Initialize the transport layer - UART/USB/Ethernet
		TRANS_LAYER_Init(pbClk);
		
		while(!FRAMEWORK_ExitFirmwareUpgradeMode()) // Be in loop till framework recieves "run application" command from PC
		{
			// Enter firmware upgrade mode.
			// Be in loop, looking for commands from PC
			TRANS_LAYER_Task(); // Run Transport layer tasks
			FRAMEWORK_FrameWorkTask(); // Run frame work related tasks (Handling Rx frame, process frame and so on)
			// Blink LED (Indicates the user that bootloader is running).
			BlinkLED();	
		}
		// Close trasnport layer.
		TRANS_LAYER_Close();
	}

	
	// No trigger + valid application = run application.
	JumpToApp();
	
	return 0;
}			
/********************************************************************
* Function: 	main()
*
* Precondition:
*
* Input: 		None.
*
* Output:		None.
*
* Side Effects:	None.
*
* Overview: 	Main entry function. If there is a trigger or
*				if there is no valid application, the device
*				stays in firmware upgrade mode.
*
*
* Note:		 	None.
********************************************************************/
INT main(void)
{
	UINT pbClk;

	// Setup configuration
	pbClk = SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);

	InitLED();
    mLED = 0;

    TRISAbits.TRISA4 = 1; // TEST pin
    CNPDAbits.CNPDA4 = 1; // Pull-down
    delay_us( 10 ); // Wait a bit until the port pin got pulled down.

	// Enter firmware upgrade mode if there is a trigger or if the application is not valid
	if(CheckTrigger() || !ValidAppPresent())
	{
		// Initialize the transport layer - UART/USB/Ethernet
		TRANS_LAYER_Init(pbClk);

		while(!FRAMEWORK_ExitFirmwareUpgradeMode()) // Be in loop till framework recieves "run application" command from PC
		{
			// Enter firmware upgrade mode.
			// Be in loop, looking for commands from PC
			TRANS_LAYER_Task(); // Run Transport layer tasks
			FRAMEWORK_FrameWorkTask(); // Run frame work related tasks (Handling Rx frame, process frame and so on)
			// Blink LED (Indicates the user that bootloader is running).
			BlinkLED();
		}
		// Close trasnport layer.
		TRANS_LAYER_Close();

        mLED = 0;
        while ( CheckTrigger() ) {}; // Do not run the application while TEST is still tied to VCC.
	}

    // No trigger + valid application = run application.
    CNPDAbits.CNPDA4 = 0; // turn off Pull-down
    JumpToApp();

	return 0;
}
예제 #16
0
/* ------------------------------------------------------------------ */
int main (void)
{
	uint8_t state = ST_TOP_MENU;
	uint8_t nextstate = ST_TOP_MENU;
	uint8_t key = KEY_NONE;
	func_p pStateFunc = states[state];
	
	
	/* disable watchdog */
	wdt_reset();
	Wdt_clear_flag();
	Wdt_change_enable();
	Wdt_stop();
		
	Clear_prescaler();
	InitLED();
	Led1On();
	
	Timer0_Init();
	SPEAKER_Init();
	BUTTON_Init();
	LCD_Init();
	
	sei();
	
	while (1)
	{
		key = BUTTON_GetKey();
		nextstate = pStateFunc(key);
		
		if (nextstate != state) {
			pStateFunc = states[nextstate];
			state = nextstate;
		}
		
	} /* end of while(1) */
	return 0;
}
예제 #17
0
int32_t main(void){
	gain g = { 0.0, 0.0, 0.0};
	
	uint32_t index = 0;
	
	int32_t size;
	uint8_t data_rx[64];
	uint8_t data_tx = 0x00;
	uint32_t start, end;
	
	//初期化開始
	conio_init(57600UL);
	
	Init_timer();
	InitLED();
	rcin_enable(0);
	
	Init_i2c();
	Init_fram();
	Init_DT();
	
	printf("Initialize OK.\r\n");
	//初期化終了
	
	i2c->Cfg.SlaveAddr = 0x42;
	i2c->Cfg.BaudRate = 400000;
	
	g.p_gain = read_float(0);
	g.i_gain = read_float(4);
	g.d_gain = read_float(8);
	
	printf("%f, %f, %f\r\n", g.p_gain, g.i_gain, g.d_gain);
	
	while(1){
	} 
}
예제 #18
0
/*********************************************************************//**
 * @brief		c_entry: Main program body
 * @param[in]	None
 * @return 		int
 **********************************************************************/
int c_entry (void)
{
	PINSEL_CFG_Type PinCfg;
	EXTI_InitTypeDef EXTICfg;

	/* Initialize debug via UART0
	 * – 115200bps
	 * – 8 data bit
	 * – No parity
	 * – 1 stop bit
	 * – No flow control
	 */
	debug_frmwrk_init();

	// print welcome screen
	print_menu();

	/* Initialize LEDs
	 * - If using MCB1700 board:
	 * 		LEDs: P1.28 and P1.29 are available
	 * - If using IAR1700 board:
	 * 		LEDs: LED1(P1.25) and LED2(P0.4) are available
	 * Turn off LEDs after initialize
	 */
	InitLED();

	/* Initialize EXT pin and registers
	 * - If using MCB1700 board: EXTI0 is configured
	 * - If using IAR1700 board: EXTI2 is configured
	 */
#ifdef MCB_LPC_1768
	/* P2.10 as /EINT0 */
	PinCfg.Funcnum = 1;
	PinCfg.OpenDrain = 0;
	PinCfg.Pinmode = 0;
	PinCfg.Pinnum = 10;
	PinCfg.Portnum = 2;
	PINSEL_ConfigPin(&PinCfg);
#elif defined (IAR_LPC_1768)
	/* P2.12 as /EINT2 */
	PinCfg.Funcnum = 1;
	PinCfg.OpenDrain = 0;
	PinCfg.Pinmode = 0;
	PinCfg.Pinnum = 12;
	PinCfg.Portnum = 2;
	PINSEL_ConfigPin(&PinCfg);
#endif

	EXTI_Init();

	EXTICfg.EXTI_Line = _EXTINT;
	/* edge sensitive */
	EXTICfg.EXTI_Mode = EXTI_MODE_EDGE_SENSITIVE;
	EXTICfg.EXTI_polarity = EXTI_POLARITY_LOW_ACTIVE_OR_FALLING_EDGE;
	EXTI_ClearEXTIFlag(_EXTINT);
	EXTI_Config(&EXTICfg);

	NVIC_SetPriorityGrouping(4);
	NVIC_SetPriority(_EXT_IRQ, 0);
	NVIC_EnableIRQ(_EXT_IRQ);

	_DBG_("First LED is blinking in normal mode...\n\r"	\
		  "Press '1' to enter system in sleep mode.\n\r"\
		  "If you want to wake-up the system, press INT/WAKE-UP button.");
	while(_DG !='1')
	{
		//Blink first LED
#ifdef MCB_LPC_1768
		//blink LED P1.28
		GPIO_SetValue(1, (1<<28));
		delay();
		GPIO_ClearValue(1, (1<<28));
		delay();
#elif defined (IAR_LPC_1768)
		//blink LED1 (P1.25)
		GPIO_SetValue(1, (1<<25));
		delay();
		GPIO_ClearValue(1, (1<<25));
		delay();
#endif
	}

	_DBG_("Sleeping...");
	// Enter target power down mode
	CLKPWR_Sleep();

	// MCU will be here after waking up
	_DBG_("System wake-up! Second LED is blinking...");
	//turn off first LED
#ifdef MCB_LPC_1768
	GPIO_ClearValue(1, (1<<29));
#elif defined (IAR_LPC_1768)
	GPIO_SetValue(1, (1<<25));
#endif
	while (1)
	{
		//Blink second LED
#ifdef MCB_LPC_1768
		//blink LED P1.29
		GPIO_SetValue(1, (1<<29));
		delay();
		GPIO_ClearValue(1, (1<<29));
		delay();
#elif defined (IAR_LPC_1768)
		//blink LED2 (P0.4)
		GPIO_SetValue(0, (1<<4));
		delay();
		GPIO_ClearValue(0, (1<<4));
		delay();
#endif
	}
}
예제 #19
0
void CreateDisplayManager(void)
{
   InitDisplay();
   InitLED();
}
예제 #20
0
// ============================================================================
int main( void )
{
	int	ch = 0;
	uint32_t ccount = 0;
	uint32_t lastTick;
	int pwm;

	SystemCoreClockUpdate();
	SysTick_Config( SystemCoreClock / HB_HZ);

	// Enable peripheral clocks
	// TODO:	Remove GPIOCEN when moving to the smaller CPU
	RCC->AHBENR |= (RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN | RCC_AHBENR_GPIOCEN);
	
#ifdef USE_USART
	InitUSART(400);
#endif	// USE_USART

	InitLED();
	InitServo();

	configButtons();

	while( 1 ) {
		if ( curTick > (HB_HZ) ) {
			curTick -= (HB_HZ);

			// Once per second processing...

		}
		if ( curTick != lastTick ) {
			lastTick = curTick;

			// On each timer tick move the turnout slightly closer to the new position
			for ( int idx=0; idx<SERVO_COUNT; ++idx ) {
				if ( servo[idx].currentPos < servo[idx].targetPos ) {
					servo[idx].currentPos += SERVO_DELTA;
					if ( servo[idx].currentPos > servo[idx].targetPos ) {
						servo[idx].currentPos = servo[idx].targetPos;
					}
				}
				else
				if ( servo[idx].currentPos > servo[idx].targetPos ) {
					servo[idx].currentPos -= SERVO_DELTA;
					if ( servo[idx].currentPos < servo[idx].targetPos ) {
						servo[idx].currentPos = servo[idx].targetPos;
					}
				}
			}

			TIM1->CCR1 = servo[SERVO1].currentPos;
			TIM1->CCR2 = servo[SERVO2].currentPos;
			TIM1->CCR3 = servo[SERVO3].currentPos;
			TIM1->CCR4 = servo[SERVO4].currentPos;

			btnCheck();
		}
#ifdef USE_USART
		if ( usartTxEmpty() ) {
			usartWriteByte(ch+33);
			++ch;
			ch &= 0x3F;
		}
#endif	// USE_USART
	}
}
예제 #21
0
파일: main.c 프로젝트: Biotron/kpgweigher
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;
	        		}
	                }
		}
	}	
}