Exemplo n.º 1
0
void confirmacion(void)
{
	show_cfg();
	op_select();
	if (read == 'A')
	{
		verificacion();
		reset_flag();
		if(error)
		{
			writeLCD_menu(9);
			op_select();
			error = 0;
		}
	}
	reset_flag();
}
Exemplo n.º 2
0
void cfg_ECG_options(void)
{
	writeLCD_menu(1);
	op_multi_select();
		if (read == 'A')
		{
			writeLCD_menu(2);
			reset_flag();
			op_select();
			if(read == 'A')
			{
				writeLCD_menu(3);
				reset_flag();
				sendCode(nIns,0x94);
				enter_device_name();
			}
			else if (read == 'B')
			{
				writeLCD_menu(4);
				reset_flag();
				sendCode(nIns,0x94);
				enter_pass();
			}
		}
		else if(read == 'B')
		{
			writeLCD_menu(5);
			reset_flag();
			op_select();
			if(read == 'A')
			{
				writeLCD_menu(6);
				reset_flag();
				sendCode(nIns,0x9D);
				enter_fcc_p_bandas();
			}
			else if (read == 'B')
			{
				writeLCD_menu(7);
				reset_flag();
				sendCode(nIns,0x9D);
				enter_fcc_r_bandas();
			}
		}
		else if(read == 'C')
		{
			reset_flag();
		}
}
Exemplo n.º 3
0
void enter_device_name(void)
{
	
	for (counter_name=0;counter_name<5;counter_name++)
	{
		name_device[counter_name] = ' ';
	}
	counter_name = 0;
	while((stop == 0)&&(counter_name < 5))
	{
		write_w_key();
		if(read!='#')
		{
			name_device[counter_name] = read;
		}
		reset_flag();
		counter_name++;
	}	
	stop = 0;
}
Exemplo n.º 4
0
void enter_fcc_r_bandas(void)
{
	for (counter_name=0;counter_name<3;counter_name++)
	{
		fcc_r_bandas[counter_name] = ' ';
	}
	counter_name = 0;
	while((counter_name < 3))
	{
		while(read == 0)
		{
			botread();
		}
		if((read>=0x30)&&(read<0x3A))
		{	
			sendCode(nData,read);
			fcc_r_bandas[counter_name] = read;
			counter_name++;
		}
		reset_flag();
	}	
	stop = 0;
}
Exemplo n.º 5
0
void enter_pass(void)
{
	for (counter_name=0;counter_name<4;counter_name++)
	{
		password[counter_name] = ' ';
	}
	counter_name = 0;
	while((counter_name < 4))
	{
		while(read == 0)
		{
			botread();
		}
		if((read>=0x30)&&(read<0x3A))
		{	
			sendCode(nData,read);
			password[counter_name] = read;
			counter_name++;
		}
		reset_flag();
	}	
	stop = 0;
}
void mainLoop()
{

    while(1) {



	//pid processing and output debug msg
	if (get_flag(FLAG_END_ADC_CONV)) {

	    temp_error = temp_adc[temp_lvl_real] - conv_result;

	    if ( get_flag(FLAG_PREHEAT) && (temp_error<5) ) {			//check if preheat phase completed
		temp_lvl_real = temp_lvl;
		reset_flag(FLAG_PREHEAT);
	    }

	    if ( get_flag(FLAG_BLINK_ON) && ((get_flag(FLAG_PREHEAT))==0) ) {	//BLINK_OFF if temp stabilized
		if ( (temp_error>-5) && (temp_error<5) ) {
		    LEDS_SET(temp_lvl);
		    reset_flag(FLAG_BLINK_ON);
		}
	    }

	    //calculate error for pid
	    temp_error = temp_adc[temp_lvl_real] - conv_result;
	    if (temp_error > 127) 
		temp_error=127;	// for int8_t in pid
	    else if (temp_error<-127)
		temp_error=-127;

	    heat_cycles = update_pid(&pid, (int8_t)(temp_error), conv_result);

	    reset_flag(FLAG_END_ADC_CONV);

//DBG
//	sprintf(txbuf,"%d,%d %d %d %x\r\n",conv_result,(uint16_t)(temp_lvl), (int16_t)heat_cycles, (int16_t)((int8_t)(temp_error)), (uint16_t)(flags));
//	UART_SendStr(txbuf);    //send result to uart
	}


	//zero-detection time-non-critical events processiong
	if (get_flag(FLAG_ZERO_REACHED)) {

	    reset_flag(FLAG_ZERO_REACHED);
	    phase_ticks++;


	    //leds blink
	    if (get_flag(FLAG_BLINK_ON)) {
		if ( (phase_ticks & 0b011111) == 0 ) {
		    LEDS_SET(temp_lvl);
		} else if ( (phase_ticks & 0b100000) == 0 ) {
		    LEDS_SET(0);
		}
	    }


	    //long switch-pressed: pwr-off
	    if (get_flag(FLAG_SWITCH_PRESSED)) {
		switch_pressed_timer++;
//		if ( switch_pressed_timer == 0 ) {
		if ( switch_pressed_timer == 0x90 ) {
		    switch_pressed_timer=0;
		    temp_lvl=0;
		    temp_lvl_real=0;
		    LEDS_SET(0);
		}
	    }

	    //if key is pressed
	    if ( ((SWITCH_PORT->IDR & SWITCH_PIN)==0) && ((get_flag(FLAG_SWITCH_PRESSED))==0) ) {
		set_flag(FLAG_SWITCH_PRESSED);
		switch_pressed_timer=0;
		temp_lvl = (temp_lvl+1) % 8;
		LEDS_SET(temp_lvl);
		set_flag(FLAG_BLINK_ON);
		set_flag(FLAG_PREHEAT);

		pid.pgain=pgains[temp_lvl];
		pid.igain=igains[temp_lvl];

		if ((temp_lvl<7) && (temp_lvl>0)) {
		    temp_lvl_real = temp_lvl+1;
		} else {
		    reset_flag(FLAG_PREHEAT);
		    reset_flag(FLAG_BLINK_ON);
		    temp_lvl_real = temp_lvl;
		}

	    //if key is released (pull-up)
	    } else if ( (SWITCH_PORT->IDR & SWITCH_PIN) && get_flag(FLAG_SWITCH_PRESSED) ) {
		reset_flag(FLAG_SWITCH_PRESSED);
	    }


	}


    } // end while(1)

}