Esempio n. 1
0
void lcd_dec(uint8_t val) {

	lcd_char('0' + (val/100), 0, 0);
	val %= 100;
	lcd_char('0' + (val/10), 0, 0);
	val %= 10;
	lcd_char('0' + val, 0, 0);
}
Esempio n. 2
0
static void gs_backlight_time(u8 change) {
    s8 i;
    u16 *addr = &cg.backlight_time;

    if (change == 0xff) {
	lcd_set(L7SEG, LB_EMPTY);
	return;
    }
    if (change) {
	if (btn(BTN_ROT_L)) {
	    // find lower value
	    for (i = BL_STEPS_SIZE - 1; i >= 0; i--) {
		if (bl_steps[i] >= *addr)  continue;
		*addr = bl_steps[i];
		break;
	    }
	    if (i < 0)
		*addr = bl_steps[BL_STEPS_SIZE - 1];
	}
	else {
	    // find upper value
	    for (i = 0; i < BL_STEPS_SIZE; i++) {
		if (bl_steps[i] <= *addr)  continue;
		*addr = bl_steps[i];
		break;
	    }
	    if (i == BL_STEPS_SIZE)
		*addr = bl_steps[0];
	}
    }
    lcd_7seg(L7_L);
    if (*addr < 60) {
	// seconds
	bl_num2((u8)*addr);
	lcd_char(LCHR3, 'S');
    }
    else if (*addr < 3600) {
	// minutes
	bl_num2((u8)(*addr / 60));
	lcd_char(LCHR3, 'M');
    }
    else if (*addr != BACKLIGHT_MAX) {
	// hours
	bl_num2((u8)(*addr / 3600));
	lcd_char(LCHR3, 'H');
    }
    else {
	// max
	lcd_chars("MAX");
    }
}
Esempio n. 3
0
void lcd_print (char str[], uint8_t location) {
    lcd_command(location);
    uint8_t cntr;
	for(cntr=0;cntr<strlen(str);cntr++) {
	    lcd_char(str[cntr]);
	}
}
Esempio n. 4
0
static QState mmi_busy(struct mmi_ao *me)
{
    static const char busy_char[] = ". ";
    static uint8_t busy_index;

    switch (Q_SIG(me)) {
    case Q_ENTRY_SIG:
        // Print hello message
        lcd_clear();
        lcd_write(0, 0, "Busy ...", 0);
        QActive_arm((QActive *) me, TIMEOUT_BUSY);
        return Q_HANDLED();
    case Q_EXIT_SIG:
        QActive_disarm((QActive *) me);
        return Q_HANDLED();
    case Q_TIMEOUT_SIG:
        lcd_char(15, 0, busy_char[busy_index]);
        busy_index = (busy_index + 1) % (sizeof(busy_char) - 1);
        QActive_arm((QActive *) me, TIMEOUT_BUSY);
        return Q_HANDLED();
    case SIG_KEY_PRESS:
        if (Q_PAR(me) == KEY_LEFT) {
            QActive_post((QActive *) &prog_ao, SIG_PROG_STOP, 0);
            return Q_TRAN(mmi_navigate);
        }
        return Q_HANDLED();
    case SIG_PROG_DONE:
        return Q_TRAN(mmi_navigate);
    }

    return Q_SUPER(&QHsm_top);
}
Esempio n. 5
0
void lcd_int(u16 no)
{
s8 i;
u8 a[5]={0};
if(no==0)
lcd_char('0');

for(i=0;i<5;i++)
{
a[i]=(no%10)+48;
no/=10;
}
for(--i;i>=0;i--)
{
lcd_char(a[i]);
}
}
Esempio n. 6
0
File: lcd.c Progetto: kates/lcd
uint8_t lcd_write(const char *str) {
    uint8_t i = 0;
    while (*str) {
        lcd_char(*str++);
        i++;
    }
    return i;
}
/* wyœwietlanie temperatury na pozycji X w pierwszej linii LCD */
void display_temp(uint8_t x) {
	lcd_locate(0,x);
	if(subzero) lcd_str("-");	/* jeœli subzero==1 wyœwietla znak minus (temp. ujemna) */
	else lcd_str(" ");	/* jeœli subzero==0 wyœwietl spacjê zamiast znaku minus (temp. dodatnia) */
	lcd_int(cel);	/* wyœwietl dziesiêtne czêœci temperatury  */
	lcd_str(".");	/* wyœwietl kropkê */
	lcd_int(cel_fract_bits); /* wyœwietl dziesiêtne czêœci stopnia */
	lcd_str(" C"); /* wyœwietl znak jednostek (C - stopnie Celsiusza) */
	lcd_char(0xDF);
}
Esempio n. 8
0
void main(void)
{
	lcd_init();

    kb_init();

	kb_cmd(0xED);
	kb_cmd(0x07);

	lcd_char(kb_getdata());

	kb_cmd(0xED);
	kb_cmd(0x03);

	while(1)
	{
		lcd_char(kb_getdata());
	}
}
Esempio n. 9
0
int main(void)
{
 	uart_init();
	lcd_init();
	delayms(100);
	
	while(1)
	{
		lcd_char(uart_read());
	}
}
Esempio n. 10
0
void main(void)
{
	DDRC = 0xff;
	PORTC = 0xff;
	unsigned char ch,ch1;
	unsigned char buf[10];

	uart1_init();
	lcd_init();	
	lcd_char('*');
	
	init_i2c();
	
	WR_I2C(0,0x57);//Sec
    WR_I2C(1,0x59);//Min
	WR_I2C(2,0x11 | (1<<5)|(1<<6) );//Hr
    WR_I2C(3,1);//Day
	WR_I2C(4,0x31);//Date
    WR_I2C(5,0x12);//Month
	WR_I2C(6,0x99);//year
	
	while(1)
	{	
		ch = RD_I2C(0,0);//sec
		sprintf(buf,"\n\rSec = %02d",Hex2Dec(ch));
		uart1_transmit_string(buf);

		ch = RD_I2C(1,0);//min
		sprintf(buf,"\n\rMin = %02d",Hex2Dec(ch));
		uart1_transmit_string(buf);
	
		ch = RD_I2C(2,0);//hr
		sprintf(buf,"\n\rHr = %02d",Hex2Dec( ch & 0x1F ) );
		uart1_transmit_string(buf);
	
		ch = RD_I2C(3,0);//day
		sprintf(buf,"\n\rDay = %02d",Hex2Dec(ch));
		uart1_transmit_string(buf);

		ch = RD_I2C(4,0);//date
		sprintf(buf,"\n\rDate = %02d",Hex2Dec(ch));
		uart1_transmit_string(buf);
	
		ch = RD_I2C(5,0);//month
		sprintf(buf,"\n\rMonth = %02d",Hex2Dec(ch));
		uart1_transmit_string(buf);

		ch = RD_I2C(6,0);//year
		sprintf(buf,"\n\rYear = %02d",Hex2Dec(ch));
		uart1_transmit_string(buf);
		_delay_ms(1000);
	
	}
}
Esempio n. 11
0
void lcd_float(float f)
{
u16 t;
t=f;
lcd_int(t);
lcd_char('.');
f-=t;
f*=100;
t=f;
lcd_int(t);
}
Esempio n. 12
0
int fputs(const char *_ptr, register FILE *_fp)				//function necessary to use printf
{
  unsigned int i, len;

  len = strlen(_ptr);

  for(i=0 ; i<len; i++)
  {
    lcd_char((unsigned char) _ptr[i]);
  }

  return len;
}
void M12_func_ustawienia_lcd(char *str)
{
	if(Flagi.flaga_lcd)
	{
		lcd_locate(0, 10);
		lcd_char(0x7E);
		lcd_str(str);
		EI2C_read_buf(ADDR_EEMEM_24C64, offsetof(EXT_EEPROM_var, empty), SIZEOF (EXT_EEPROM_var, empty), (uint8_t *)str);
		lcd_locate(1, 0);
		lcd_str(str);
		Flagi.flaga_lcd=0;
	}
}
Esempio n. 14
0
static void mix_4WS(u8 action) {
    u8 val;

    if (action == MLA_CHG) {
	// change value
	switch (menu_set) {
	    case 0:
		// channel number/off
		val = cm.channel_4WS;
		if (!val)  val = 2;
		val = (u8)menu_change_val(val, 2, channels, 1, 1);
		if (val == 2)   cm.channel_4WS = 0;
		else		cm.channel_4WS = val;
		break;
	    case 1:
		// mix value
		menu_4WS_mix = (s8)menu_change_val(menu_4WS_mix, -100, 100,
						   MIX_FAST, 0);
		break;
	    case 2:
		// crab/no-crab
		menu_4WS_crab ^= 1;
	}
    }
    else if (action == MLA_NEXT) {
	// select next value
	if (++menu_set > 2)   menu_set = 0;
	if (!cm.channel_4WS)  menu_set = 0;
    }

    // show value
    lcd_7seg(4);
    switch (menu_set) {
	case 0:
	    // channel number/OFF
	    if (!cm.channel_4WS)  lcd_chars("OFF");
	    else		  lcd_char_num3(cm.channel_4WS);
	    lcd_segment(LS_SYM_CHANNEL, LS_ON);
	    break;
	case 1:
	    // mix value
	    lcd_char_num3(menu_4WS_mix);
	    lcd_segment(LS_SYM_PERCENT, LS_ON);
	    break;
	case 2:
	    // crab/no-crab
	    lcd_chars("CR");
	    lcd_char(LCHR3, (u8)(menu_4WS_crab + '0'));
	    menu_blink &= (u8)~(MCB_CHR1 | MCB_CHR2);
    }
}
Esempio n. 15
0
void lcd_string_P(PGM_P str, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) {

	while(pgm_read_byte(str)) {
		lcd_char(pgm_read_byte(str++), x1, y1);
		x1 += 6;
		if (x1 > x2) {
			x1 = 0;
			y1 += 8;

			if (y1 > y2)
				return;
		}
	}
}
Esempio n. 16
0
void lcd_string(char *str, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) {
	uint8_t curr_x = x1;
	while(*str) {
		lcd_char(*(str++), curr_x, y1);
		curr_x += 6;
		if (curr_x > x2) {
			curr_x = x1;
			y1 += 8;

			if (y1 > y2)
				return;
		}
	}
}
Esempio n. 17
0
static void gs_inactivity_alarm(u8 change) {
    if (change == 0xff) {
	lcd_set(L7SEG, LB_EMPTY);
	return;
    }
    if (change) {
	cg.inactivity_alarm = (u8)menu_change_val(cg.inactivity_alarm, 0, 10,
						  1, 1);
	reset_inactivity_timer();
    }
    lcd_7seg(L7_A);
    if (!cg.inactivity_alarm)  lcd_chars("OFF");
    else {
	bl_num2(cg.inactivity_alarm);
	lcd_char(LCHR3, 'M');
    }
}
Esempio n. 18
0
int fputc(int _c, register FILE *_fp)						//function necessary to use printf
{
	lcd_char((unsigned char) _c);
	return((unsigned char)_c);
}
Esempio n. 19
0
int main(void)
{
unsigned char i,a[14],temp=0;
 lcd_init();
 lcd_string("  RC 5"); 
 lcd_cmd(0XC0);
 lcd_string("decoder");
 delayms(1000);
 lcd_clear();
 delayms(100);
 DDRB=0X00;
 DDRD=0XFF;
 PORTD=0X00;

 
 while(1)
  {
   if((PINB&0x02)==0x02)
   {
    delayus(100);
    for(i=0;i<14;i++)
	 {
	  if((PINB&0x02)==0x02)
	    {a[i]=1;}
	  else{a[i]=0;}	
	  delayus(1777);
	 }
	  lcd_gotoxy(0,0);			//  to use it as a IR remote controller receiver 
	  lcd_char((a[0])+0x30);	//instread 0f displaying its received data in LCD 
	  lcd_char((a[1])+0x30);	//separate the data and address bit check the 
	  lcd_char((a[2])+0x30);	//address and on the respective matching command 
	  lcd_char((a[3])+0x30);	//or data do the necessary action
	  lcd_char((a[4])+0x30);
	  lcd_char((a[5])+0x30);
	  lcd_char((a[6])+0x30);	  
	  lcd_char((a[7])+0x30);
	  lcd_gotoxy(1,0);
	  lcd_char((a[8])+0x30);
	  lcd_char((a[9])+0x30);
	  lcd_char((a[10])+0x30);
	  lcd_char((a[11])+0x30);
	  lcd_char((a[12])+0x30);
	  lcd_char((a[13])+0x30);
	  
	 temp=0x00;
		for(i=8;i<=13;i++)
		{
			if((a[i]&0x01)==0x01)
			{
				temp=temp|0x01;
			}
				temp<<=1;
				
		}		
		lcd_gotoxy(1,9);
		temp>>=1;					// To avoide the 1 bit extra shift
					
		
		lcd_showvalue(temp);
		
		switch(temp)
		{
			case 30: PORTD=0X50;
						break;
			case 28: PORTD=0XA0;
						break;
			case 18: PORTD=0x40;
						break;
			case 20: PORTD=0X10;
						break;
			case 38: PORTD=0X00;
						break;
		}
		
		

  }
 }}
Esempio n. 20
0
static void bl_num2(u8 val) {
    if (val < 10)  lcd_char(LCHR1, ' ');
    else           lcd_char(LCHR1, (u8)((u8)(val / 10) + '0'));
    lcd_char(LCHR2, (u8)((u8)(val % 10) + '0'));

}
Esempio n. 21
0
// 7seg:  C b E 1l 1r 2l 2r 3l 3r dl dr
// chars:
// function
//   OFF    -> function_long
//   2STATE -> momentary
//               switch    -> reverse -> prev_val -> function_long
//               momentary -> reverse -> prev_val
//   other  -> function_long
//
// function_long (identified by symbol V)
//   OFF
//   2STATE -> reverse -> prev_val
//   other
static void km_key(u8 action) {
    config_key_map_s *km = &ck.key_map[menu_id - NUM_TRIMS];
    u8 idx, new_idx = 0;

    if (action == 1) {
	// change value
	switch (menu_set) {
	    case 0:
		// function
		// select new function, map through key_functions
		idx = menu_key_function_idx(km->function);
		while (1) {
		    idx = (u8)menu_change_val(idx, 0, key_functions_max, 1, 1);
		    new_idx = key_functions[idx];
		    if (!new_idx)  continue;				// empty slot
		    new_idx--;	// was one more
		    if (menu_key_function_is_allowed(new_idx))  break;	// we have it
		}
		// set values to defaults
		if (km->momentary)  *(u16 *)km = 0;  // was momentary, zero all
		else {
		    // zero only no-long function parameters
		    km->reverse = 0;
		    km->previous_val = 0;
		}
		km->function = new_idx;
		break;
	    case 1:
		// momentary setting
		km->momentary ^= 1;
		// after change momentary, reset long setting
		km->function_long = 0;
		km->reverse_long = 0;
		km->previous_val_long = 0;
		break;
	    case 2:
		// reverse
		km->reverse ^= 1;
		break;
	    case 3:
		// previous_val
		km->previous_val ^= 1;
		break;
	    case 4:
		// function long
		// select new function, map through key_functions
		idx = menu_key_function_idx(km->function_long);
		while (1) {
		    idx = (u8)menu_change_val(idx, 0, key_functions_max, 1, 1);
		    new_idx = key_functions[idx];
		    if (!new_idx)  continue;				// empty slot
		    new_idx--;	// was one more
		    if (menu_key_function_is_allowed(new_idx))  break;	// we have it
		}
		// set values to defaults
		km->reverse_long = 0;
		km->previous_val_long = 0;
		km->function_long = new_idx;
		break;
	    case 5:
		// reverse_long
		km->reverse_long ^= 1;
		break;
	    case 6:
		// previous_val_long
		km->previous_val_long ^= 1;
		break;
	}
    }

    else if (action == 2) {
	// switch to next setting
	switch (menu_set) {
	    case 0:
		if (menu_key_function_2state(km->function))  menu_set = 1;
		else  menu_set = 4;
		break;
	    case 1:
		menu_set = 2;
		break;
	    case 2:
		menu_set = 3;
		break;
	    case 3:
		if (km->momentary)  menu_set = 0;
		else  menu_set = 4;
		break;
	    case 4:
		if (menu_key_function_2state(km->function_long))  menu_set = 5;
		else  menu_set = 0;
		break;
	    case 5:
		menu_set = 6;
		break;
	    case 6:
		menu_set = 0;
		break;
	}
    }

    // show value of menu_set
    switch (menu_set) {
	case 0:
	    // function
	    lcd_chars(menu_key_function_name(km->function));
	    break;
	case 1:
	    // momentary setting
	    lcd_chars("MO");
	    lcd_char(LCHR3, (u8)(km->momentary + '0'));
	    menu_blink &= (u8)~(MCB_CHR1 | MCB_CHR2);
	    break;
	case 2:
	    // reverse
	    lcd_chars("RE");
	    lcd_char(LCHR3, (u8)(km->reverse + '0'));
	    menu_blink &= (u8)~(MCB_CHR1 | MCB_CHR2);
	    break;
	case 3:
	    // previous_val
	    lcd_chars("PV");
	    lcd_char(LCHR3, (u8)(km->previous_val + '0'));
	    menu_blink &= (u8)~(MCB_CHR1 | MCB_CHR2);
	    break;
	case 4:
	    // function long
	    lcd_chars(menu_key_function_name(km->function_long));
	    lcd_segment(LS_SYM_VOLTS, LS_ON);
	    break;
	case 5:
	    // reverse_long
	    lcd_chars("RE");
	    lcd_char(LCHR3, (u8)(km->reverse_long + '0'));
	    menu_blink &= (u8)~(MCB_CHR1 | MCB_CHR2);
	    lcd_segment(LS_SYM_VOLTS, LS_ON);
	    break;
	case 6:
	    // previous_val_long
	    lcd_chars("PV");
	    lcd_char(LCHR3, (u8)(km->previous_val_long + '0'));
	    menu_blink &= (u8)~(MCB_CHR1 | MCB_CHR2);
	    lcd_segment(LS_SYM_VOLTS, LS_ON);
	    break;
    }
}
void M11_func_ustawienia_godzina(char *str)
{
	static uint8_t i=0, edit=0;
	static uint8_t state=0;
	static uint32_t cnt=0, offset_cnt=0;
	
	if(Flagi.flaga_lcd)
	{
		lcd_locate(0, 10);
		lcd_char(0x7E);
		lcd_str(str);
		EI2C_read_buf(ADDR_EEMEM_24C64, offsetof(EXT_EEPROM_var, empty), SIZEOF (EXT_EEPROM_var, empty), (uint8_t *)str);
		lcd_locate(1, 0);
		lcd_str(str);
		Flagi.flaga_lcd=0;
	}

	switch(state)
	{
		case 0:
			state=1;	
			
			if(i>8)
				i=0;
			lcd_locate(0, 10);
			lcd_char(0x7E);
			fifo_bufor_lcd(str,i,strlen(str));
			lcd_str(str);
			
			cli();
			cnt=25000;
			offset_cnt=licznik;
			sei();
			break;
		case 1:
			if(cnt<=licznik-offset_cnt)
			{
				i++;
				state=0;
			}
			break;
	}
	
	if (key_code == PRZYCISK_ENTER)
	{
		edit++;
		if (edit>3)
			edit=1;
		Flagi.flaga_klawiatura=0;
	}
	else if (key_code == PRZYCISK_POWROT && Flagi.flaga_klawiatura==0)
	{
		edit=0;
		Flagi.flaga_klawiatura=1;
		ustaw_czas(&czas);
	}
	
	
	switch(edit)
	{
		case 1:
			if (key_code == PRZYCISK_GORA && Flagi.flaga_klawiatura==0)
			{
				czas.godziny++;
				if(czas.godziny>23)
					czas.godziny=0;
				lcd_locate(1,0);
				if( czas.godziny < 10 ) lcd_char('0');
				lcd_int(czas.godziny);
			}
			else if (key_code == PRZYCISK_DOL && Flagi.flaga_klawiatura==0)
			{
				czas.godziny--;
				if((int8_t)czas.godziny<0)
					czas.godziny=23;	
				lcd_locate(1,0);
				if( czas.godziny < 10 ) lcd_char('0');
				lcd_int(czas.godziny);
			}

			lcd_cursor_on();
			lcd_blink_on();
			lcd_locate(1,1);
			break;
		case 2:
			if (key_code == PRZYCISK_GORA && Flagi.flaga_klawiatura==0)
			{
				czas.minuty++;
				if(czas.minuty>59)
				czas.minuty=0;
				lcd_locate(1,3);
				if( czas.minuty < 10 ) lcd_char('0');
				lcd_int(czas.minuty);
			}
			else if (key_code == PRZYCISK_DOL && Flagi.flaga_klawiatura==0)
			{
				czas.minuty--;
				if((int8_t)czas.minuty<0)
				czas.minuty=59;
				lcd_locate(1,3);
				if( czas.minuty < 10 ) lcd_char('0');
				lcd_int(czas.minuty);
			}
			lcd_cursor_on();
			lcd_blink_on();
			lcd_locate(1,4);
			break;
		case 3:
			if (key_code == PRZYCISK_GORA && Flagi.flaga_klawiatura==0)
			{
				czas.sekundy++;
				if(czas.sekundy>59)
				czas.sekundy=0;
				lcd_locate(1,6);
				if( czas.sekundy < 10 ) lcd_char('0');
				lcd_int(czas.sekundy);
			}
			else if (key_code == PRZYCISK_DOL && Flagi.flaga_klawiatura==0)
			{
				czas.sekundy--;
				if((int8_t)czas.sekundy<0)
				czas.sekundy=59;
				lcd_locate(1,6);
				if( czas.sekundy < 10 ) lcd_char('0');
				lcd_int(czas.sekundy);
			}
			lcd_cursor_on();
			lcd_blink_on();
			lcd_locate(1,7);
			break;
		default:
			lcd_cursor_off();
			lcd_blink_off();
			if(Flagi.flaga_rtc)
			{
				pobierz_czas(&czas);
				Flagi.flaga_rtc=0;
			}
			lcd_locate(1,0);
			if( czas.godziny < 10 ) lcd_char('0');
			lcd_int(czas.godziny);
			lcd_char(':');
			if( czas.minuty < 10 ) lcd_char('0');
			lcd_int(czas.minuty);
			lcd_char(':');
			if( czas.sekundy < 10 ) lcd_char('0');
			lcd_int(czas.sekundy);
		break;
	}

}
void M10_func_ustawienia_data(char *str)
{
	static uint8_t state=0, edit=0, i=0;
	static uint32_t cnt=0, offset_cnt=0;
	
	if(Flagi.flaga_lcd)
	{
		lcd_locate(0, 10);
		lcd_char(0x7E);
		lcd_str(str);
		EI2C_read_buf(ADDR_EEMEM_24C64, offsetof(EXT_EEPROM_var, empty), SIZEOF (EXT_EEPROM_var, empty), (uint8_t *)str);
		lcd_locate(1, 0);
		lcd_str(str);
		Flagi.flaga_lcd=0;
	}
	
	if (key_code == PRZYCISK_ENTER)
	{
		edit++;
		if (edit>4)
			edit=1;
		Flagi.flaga_klawiatura=0;
	}
	else if (key_code == PRZYCISK_POWROT && Flagi.flaga_klawiatura==0)
	{
		edit=0;
		Flagi.flaga_klawiatura=1;
		ustaw_date(&data);
	}
	
	switch(edit)
	{
		case 1:
			if (key_code == PRZYCISK_GORA && Flagi.flaga_klawiatura==0)
			{
				data.dzien_tygodnia++;
				if (data.dzien_tygodnia>6)
					data.dzien_tygodnia=0;
			}
			else if (key_code == PRZYCISK_DOL && Flagi.flaga_klawiatura==0)
			{
				data.dzien_tygodnia--;
				if ((int8_t)data.dzien_tygodnia<0)
					data.dzien_tygodnia=6;
			}
			break;
		case 2:
			if (key_code == PRZYCISK_GORA && Flagi.flaga_klawiatura==0)
			{
				data.dzien++;
				switch(data.miesiac)
				{
					case PCF_January:
						if (data.dzien>31)
						{	
							data.dzien=1;
						}
						break;
					case PCF_February:
						if(!(data.rok % 4))
						{
							if (data.dzien>29)
							{
								data.dzien=1;
							}	
						}
						else
						{
							if (data.dzien>28)
							{
								data.dzien=1;
							}							
						}

						break;			
					case PCF_March:
						if (data.dzien>31)
						{
							data.dzien=1;
						}
						break;
					case PCF_April:
						if (data.dzien>30)
						{
							data.dzien=1;
						}
						break;
					case PCF_May:
						if (data.dzien>31)
						{
							data.dzien=1;
						}
						break;
					case PCF_June:
						if (data.dzien>30)
						{
							data.dzien=1;
						}
						break;
					case PCF_July:
						if (data.dzien>31)
						{
							data.dzien=1;
						}
						break;
					case PCF_August:
						if (data.dzien>31)
						{
							data.dzien=1;
						}
						break;
					case PCF_September:
						if (data.dzien>30)
						{
							data.dzien=1;
						}
						break;
					case PCF_October:
						if (data.dzien>31)
						{
							data.dzien=1;
						}
						break;
					case PCF_November:
						if (data.dzien>30)
						{
							data.dzien=1;
						}
						break;			
					case PCF_December:
						if (data.dzien>31)
						{
							data.dzien=1;
						}
						break;
				}
			}
			else if (key_code == PRZYCISK_DOL && Flagi.flaga_klawiatura==0)
			{
				data.dzien--;
				switch(data.miesiac)
				{
					case PCF_January:
						if ((int8_t)data.dzien<1)
						{
							data.dzien=31;
						}
						break;
					case PCF_February:
						if(!(data.rok % 4))
						{
							if ((int8_t)data.dzien<1)
							{
								data.dzien=29;
							}
						}
						else
						{
							if ((int8_t)data.dzien<1)
							{
								data.dzien=28;
							}
						}

						break;
					case PCF_March:
						if ((int8_t)data.dzien<1)
						{
							data.dzien=31;
						}
						break;
					case PCF_April:
						if ((int8_t)data.dzien<1)
						{
							data.dzien=30;
						}
						break;
					case PCF_May:
						if ((int8_t)data.dzien<1)
						{
							data.dzien=31;
						}
						break;
					case PCF_June:
						if ((int8_t)data.dzien<1)
						{
							data.dzien=30;
						}
						break;
					case PCF_July:
						if ((int8_t)data.dzien<1)
						{
							data.dzien=31;
						}
						break;
					case PCF_August:
						if ((int8_t)data.dzien<1)
						{
							data.dzien=31;
						}
					break;
					case PCF_September:
						if ((int8_t)data.dzien<1)
						{
							data.dzien=30;
						}
						break;
					case PCF_October:
						if ((int8_t)data.dzien<1)
						{
							data.dzien=31;
						}
						break;
					case PCF_November:
						if ((int8_t)data.dzien<1)
						{
							data.dzien=30;
						}
						break;
					case PCF_December:
						if ((int8_t)data.dzien<1)
						{
							data.dzien=31;
						}
						break;
				}
			}
			break;
		case 3:
			if (key_code == PRZYCISK_GORA && Flagi.flaga_klawiatura==0)
			{
				data.miesiac++;
				if (data.miesiac>12)
					data.miesiac=1;
					
				switch(data.miesiac)
				{
					case PCF_January:
						break;
					case PCF_February:
						if(!(data.rok % 4))
						{
							if (data.dzien>29)
							{
								data.dzien=29;
							}
						}
						else
						{
							if (data.dzien>28)
							{
								data.dzien=28;
							}
						}

						break;
					case PCF_March:

						break;
					case PCF_April:
						if (data.dzien>30)
						{
							data.dzien=30;
						}
						break;
					case PCF_May:
						break;
					case PCF_June:
						if (data.dzien>30)
						{
							data.dzien=30;
						}
						break;
					case PCF_July:
						break;
					case PCF_August:
						break;
					case PCF_September:
						if (data.dzien>30)
						{
							data.dzien=30;
						}
						break;
					case PCF_October:
						break;
					case PCF_November:
						if (data.dzien>30)
						{
							data.dzien=30;
						}
						break;
					case PCF_December:
						break;
				}
			}
			else if (key_code == PRZYCISK_DOL && Flagi.flaga_klawiatura==0)
			{
				data.miesiac--;
				if ((int8_t)data.miesiac<1)
					data.miesiac=12;
			}
			break;
		case 4:
			if (key_code == PRZYCISK_GORA && Flagi.flaga_klawiatura==0)
			{
				data.rok++;
			}
			else if (key_code == PRZYCISK_DOL && Flagi.flaga_klawiatura==0)
			{
				data.rok--;
			}
			break;
		default:
			if(Flagi.flaga_rtc)
			{
				pobierz_date(&data);
				Flagi.flaga_rtc=0;
			}
			break;
	}
	
	switch(state)
	{
		case 0:
			state=1;
			
			if (!i)
			{
			lcd_wyswietl_date(&data, str, edit);
			lcd_locate(1,0);
			lcd_str(str);
			}
			else
			{
				if(edit==3 || edit==4)
					lcd_wyswietl_date(&data, str, 5);
				else
					lcd_wyswietl_date(&data, str, 0);
					lcd_locate(1,0);
					lcd_str(str);
			}
			
			cli();
			cnt=50000;
			offset_cnt=licznik;
			sei();
			break;
		case 1:
			if(cnt<=licznik-offset_cnt)
			{
				i=~i;
				state=0;
			}
			break;
	}
}
void M0(char *str)
{	
	static uint8_t state=0, term_state=0, i=0;
	static uint32_t cnt=0, offset_cnt=0;
	static char buf[41], buf_lcd[9];
	if(Flagi.flaga_lcd)
	{
		lcd_locate(0, 0);
		lcd_str(str);
		lcd_locate(1, 0);
		lcd_str(str);
		Flagi.flaga_lcd=0;
	}
	if (Flagi.flaga_term)
	{
		switch(term_state)
		{
			case 0:
					DS18X20_start_meas( DS18X20_POWER_EXTERN, NULL );
					term_state=1;
					break;
			case 1:
					if( DS18X20_OK == DS18X20_read_meas(gSensorIDs[0], &subzero, &cel, &cel_fract_bits) ) display_temp(0);
					else {
						lcd_locate(0,0);
						lcd_str("term. error ");	/* wyœwietlamy informacjê o b³êdzie jeœli np brak czujnika lub b³¹d odczytu */
					}
					term_state=0;
					break;
		}
		Flagi.flaga_term=0;

	}
	
	if(Flagi.flaga_rtc)
	{
		pobierz_czas(&czas);
		pobierz_date(&data);
		Flagi.flaga_rtc=0;
	}

	lcd_locate(1,0);
	if( czas.godziny < 10 ) lcd_char('0');
	lcd_int(czas.godziny);
	lcd_char(':');
	if( czas.minuty < 10 ) lcd_char('0');
	lcd_int(czas.minuty);
	lcd_char(':');
	if( czas.sekundy < 10 ) lcd_char('0');
	lcd_int(czas.sekundy);
	
	switch(state)
	{
		case 0:
				state=1;
				
				if(i>= 2*strlen(buf))
					i=0;
				
				lcd_wyswietl_date(&data, buf, 0);
				fifo_bufor_lcd(buf, i, strlen(buf));
				lcd_locate(1,8);
				strncpy(buf_lcd,buf,sizeof(buf_lcd)-1);
				lcd_str(buf_lcd);
				
				cli();
				cnt=25000;
				offset_cnt=licznik;
				sei();
				break;
		case 1:
				if(cnt<=licznik-offset_cnt)
				{
					i++;
					state=0;
				}
				break;
	}
}
Esempio n. 25
0
// 7seg:  1 2 3 d
// chars:
// function
//   OFF
//   other -> buttons
//              MO	 -> 	    reverse              -> prev_val
//           NL/RP/RE/EN -> step -> reverse -> opp_reset             -> rotate
// id:                       V
static void km_trim(u8 action) {
    config_et_map_s *etm = &ck.et_map[menu_id];
    u8 idx, btn, new_idx = 0;

    if (action == 1) {
	// change value
	switch (menu_set) {
	    case 0:
		// function
		// select new function, map through trim_functions
		if (!etm->is_trim)  etm->function = 0;
		idx = menu_et_function_idx(etm->function);
		while (1) {
		    idx = (u8)menu_change_val(idx, 0, trim_functions_max, 1, 1);
		    new_idx = trim_functions[idx];
		    if (!new_idx)  continue;				// empty slot
		    new_idx--;  // was one more
		    if (menu_et_function_is_allowed(new_idx))  break;	// we have it
		}
		// set values to defaults
		((u16 *)etm)[0] = 0;
		((u16 *)etm)[1] = 0;
		etm->function = new_idx;
		if (etm->function)
		    etm->is_trim = etm->is_trim2 = 1;
		break;
	    case 1:
		// buttons
		// show special ("SP") only when selected function has it
		if (menu_et_function_long_special(etm->function))
			idx = 1;
		else	idx = 2;
		btn = etm->buttons;
		btn = (u8)menu_change_val(btn, 0, TRIM_BUTTONS_SIZE - idx,
					  1, 1);
		// skip MOMentary for list functions
		if (btn == ETB_MOMENTARY &&
		    menu_et_function_is_list(etm->function)) {
		    if (etm->buttons < ETB_MOMENTARY)  btn++;
		    else  btn--;
		}
		etm->buttons = btn;
		break;
	    case 2:
		// step
		etm->step = (u8)menu_change_val(etm->step, 0,
						STEPS_MAP_SIZE - 1, 1, 0);
		break;
	    case 3:
		// reverse
		etm->reverse ^= 1;
		break;
	    case 4:
		// opposite reset
		etm->opposite_reset ^= 1;
		break;
	    case 5:
		// return to previous value
		etm->previous_val ^= 1;
		break;
	    case 6:
		etm->rotate ^= 1;
		break;
	}
    }

    else if (action == 2) {
	// switch to next setting
	if (menu_set || etm->is_trim) {
	    if (etm->buttons == ETB_MOMENTARY) {
		if (++menu_set > 5)       menu_set = 0;
		else if (menu_set == 2)   menu_set = 3;  // skip "step" for momentary
		else if (menu_set == 4)   menu_set = 5;  // skip "opposite_reset"
	    }
	    else {
		if (++menu_set > 4)  menu_set = 0;
		else if (menu_et_function_is_list(etm->function)) {
		    if (menu_set == 2) {
			// skip "step"
			menu_set++;
			etm->step = 0;
		    }
		    else if (menu_set == 4) {
			// skip "opposite reset"
			menu_set = 6;
			etm->opposite_reset = 0;
		    }
		}
	    }
	}
    }

    // show value of menu_set
    switch (menu_set) {
	case 0:
	    // function
	    if (!etm->is_trim)  lcd_chars("OFF");
	    else  lcd_chars(menu_et_function_name(etm->function));
	    break;
	case 1:
	    // buttons
	    lcd_char(LCHR1, 'B');
	    lcd_chars2(trim_buttons[etm->buttons]);
	    menu_blink &= (u8)~MCB_CHR1;
	    break;
	case 2:
	    // step
	    lcd_char_num3(steps_map[etm->step]);
	    lcd_segment(LS_SYM_VOLTS, LS_ON);
	    break;
	case 3:
	    // reverse
	    lcd_chars("RE");
	    lcd_char(LCHR3, (u8)(etm->reverse + '0'));
	    menu_blink &= (u8)~(MCB_CHR1 | MCB_CHR2);
	    break;
	case 4:
	    // opposite reset
	    lcd_chars("OR");
	    lcd_char(LCHR3, (u8)(etm->opposite_reset + '0'));
	    menu_blink &= (u8)~(MCB_CHR1 | MCB_CHR2);
	    break;
	case 5:
	    // previous val
	    lcd_chars("PV");
	    lcd_char(LCHR3, (u8)(etm->previous_val + '0'));
	    menu_blink &= (u8)~(MCB_CHR1 | MCB_CHR2);
	    break;
	case 6:
	    // rotate
	    lcd_chars("RO");
	    lcd_char(LCHR3, (u8)(etm->rotate + '0'));
	    menu_blink &= (u8)~(MCB_CHR1 | MCB_CHR2);
	    break;
    }
}
Esempio n. 26
0
File: lcd.c Progetto: Micha500/gt3b
// write 2 chars to chars 2+3
void lcd_chars2(u8 *chars) {
    lcd_char(LCHR2, *chars++);
    lcd_char(LCHR3, *chars++);
}
Esempio n. 27
0
// PURPOSE:  send a null terminated string to the LCD eg. char x[10]="hello!";
void HD44780::lcd_string(char *text)
{
    char c;
    while ( (c = *text++) )  lcd_char(c);
}
Esempio n. 28
0
//-----------------------------------------------------------------------------------------
// FUNCTION: lcd_string
// PURPOSE:  send a null terminated string to the LCD eg. char x[10]="hello!";
void lcd_string(char *text)
{
	char c;
    while ( (c = *text++) )  lcd_char(c);
}
Esempio n. 29
0
File: lcd.c Progetto: kates/lcd
void lcd_writeln(const char *str) {
    uint8_t i = lcd_write(str);
    while(i++ < LCD_COLUMNS) {
        lcd_char(' ');
    }
}
Esempio n. 30
0
File: lcd.c Progetto: Micha500/gt3b
// write 3 chars
void lcd_chars(u8 *chars) {
    lcd_char(LCHR1, *chars++);
    lcd_char(LCHR2, *chars++);
    if (*chars)  lcd_char(LCHR3, *chars);  // to allow 2 char strings
}