Exemplo n.º 1
0
void main (void)
{

	while(1){
		char c = get_key();
		display_dec((unsigned int)c);
	}
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: oherik/PIS
void main(void)
{
	while(1)
	{
		int keynumber=get_key();
		display_dec(keynumber);
	}
}
Exemplo n.º 3
0
Arquivo: io.c Projeto: Fornax/RS485
void io_loop() {
	
	//Button decrement
	if ( BTN_DEC == 1u && old_btn_dec == 0u && cnt_dec == 0u ) {
		cnt_dec= 100;
		old_btn_dec= 1u;
		display_on(); //Show current address
	} else 	if ( BTN_DEC == 0u && old_btn_dec == 1u && cnt_dec == 0u ) {
		cnt_dec= 100;
		old_btn_dec= 0u;
		delay_unlock= 0u; //Reset unlocking time
		
		if (old_btn_inc == 0u) {
			if (!btn_ignore) {
				display_dec();
			}
			btn_ignore= 0u;
		} else {
			btn_ignore= 1u;
		}
	}
	//Button increment
	if ( BTN_INC == 1u && old_btn_inc == 0u && cnt_inc == 0u ) {
		cnt_inc= 100;
		old_btn_inc= 1u;
		display_on(); //Show current address
	} else if ( BTN_INC == 0u && old_btn_inc == 1u && cnt_inc == 0u ) {
		cnt_inc= 100;
		old_btn_inc= 0u;
		delay_unlock= 0u; //Reset unlocking time
		
		if (old_btn_dec == 0u) {
			if (!btn_ignore) {
				display_inc();
			}
			btn_ignore= 0u;
		} else {
			btn_ignore= 1u;
		}
	}
	
	//Input buttons
	if ( buttons_input == 0u && (INPUT1 == 0u && INPUT2 == 0u) && cnt_input == 0u ) {
		cnt_input= 100;
		buttons_input= 1u;
	} else if (buttons_input == 1u && (INPUT1 != 0u || INPUT2 != 0u) && cnt_input == 0u ) {
		cnt_input= 100;
		buttons_input= 0u;
		if (INPUT1&0x01) {inputs=9;}
		if (INPUT1&0x02) {inputs=8;}
		if (INPUT1&0x04) {inputs=7;}
		if (INPUT1&0x08) {inputs=6;}
		if (INPUT1&0x10) {inputs=5;}
		if (INPUT1&0x20) {inputs=4;}
		if (INPUT2&0x01) {inputs=3;}
		if (INPUT2&0x02) {inputs=2;}
		if (INPUT2&0x04) {inputs=1;}
	}
	//Input capture
	if ( CAPT1 == 1u && capt1 == 0u && cnt_capt == 0u ) {
		cnt_capt= 100;
		capt1= 1;
	} else if ( CAPT1 == 0u && capt1 == 1u && cnt_capt == 0u ) {
		cnt_capt= 100;
		capt1= 0;
		puls_counter++;
	}
	//both switches pressed
	if ( BTN_INC != 0u && BTN_DEC != 0u ) {
		if (cnt_dec == 0u && cnt_inc == 0u && delay_unlock == 0u) {
			delay_unlock= 2000;
		}
		
		//Unlock up/down counting.
		if (cnt_dec == 0u && cnt_inc == 0u && delay_unlock <= 200u) {
			display_unlock();
		}
	}
	
	//Display on
	if ( BTN_INC != 0u || BTN_DEC != 0u) {
		delay_off= 3000;
	}
	
	//Display off
	if ( delay_off == 0u ) {
		display_lock();
	}
}