Exemplo n.º 1
0
//dung tre 100us thay kiem tra co ban
void lcd_init(){

	lcd_setupout(0);
//Function set------------------------------------------------------------------------------
	BIT_DDR_EN_LCD=huongra;
	BIT_OUT_EN_LCD=1;		//
	BIT_DDR_RW_LCD=huongra;
	BIT_OUT_RW_LCD=0;		//ghi
	BIT_DDR_RS_LCD=huongra;	
	BIT_OUT_RS_LCD=0;		//chon thanh ghi lenh  
	delay_ms(500);
	//Cai dat mode 4 bit bang cach gui 0x20 theo mode 8 bit
	// moi khoi dong mac dinh la 8 bit nen
    lcd_write_nibble(0x3);//LA 0X3 LA CHE DO 8 BIT
	delay_ms(1);				//bat buoc
	lcd_write_nibble(0x3);	//lenh gui van theo mode 8 bit
	//toi day chac chan la 8 bit
	//toi day chac chan la 8 bit
	delay_ms(1);// bat buoc	  
	//toi day da chac chan dang la mode 8 bit
	lcd_write_nibble(0x2);//lenh gui 8 bit nhung chi quan tam may bit dau nen 
//	delay_ms(5);// bat buoc					   
	//Function set------------------------------------------------------------------------------
    lcd_writecmd(0x28);//4 bit mode, 2 line, 5x8 font  // toi day da ok  2c fong 5x10
	//Display control------------------------------------------------------------------------- 
    lcd_writecmd(0x0C);//hien thi man hinh, con tro ko nhap nhay      0eco tro nhay
	//Entry mode set------------------------------------------------------------------------
    lcd_writecmd(0x06);//ko dich man hinh, con tro tang moi lan doc hoac ghi (VIET TU TRAI QUA FAI)
	lcd_writecmd(0x01);
}
Exemplo n.º 2
0
Arquivo: lcd.c Projeto: gitpan/i2c
/* Schreibt ein Char auf das Display */
int lcd_wchar(int data)
{
 int ret,temp;
 ret=0;
 if(!lcd_busy()) {
  temp = data >> 4;
  ret = lcd_write_nibble(LCD_DR,temp);
  temp = data & 0xf;
  ret = lcd_write_nibble(LCD_DR,temp);
 }
Exemplo n.º 3
0
// viet du lieu (lenh) toi lcd neu lenh xao man thi tre 2ms (lenh nay thuc hien `1.64ms)
void lcd_writecmd(unsigned char chr){	    
	lcd_wait();			//RS=0; RW=0
	BIT_DDR_RS_LCD=huongra;
	BIT_OUT_RS_LCD=0;	//GHI LENH
	lcd_write_nibble(chr>>4);
	lcd_write_nibble(chr);
//	if((chr==1)||(chr==3))delay_ms(3);
}
Exemplo n.º 4
0
// viet du lieu (ky tu) toi lcd, ham nay da su ly xuong dong tu dong
void lcd_write_byte(char chr){
	unsigned char x,FlagGanCuoiDong=0,ToaDoChuyenDong;  
	x=lcd_wait();	 //WDR
	#if(lines==4)
		switch (x){
			case cuoidong0: ToaDoChuyenDong=daudong1,FlagGanCuoiDong=1;
				break;
			case cuoidong1: ToaDoChuyenDong=daudong2,FlagGanCuoiDong=1;
				break;
			case cuoidong2: ToaDoChuyenDong=daudong3,FlagGanCuoiDong=1;
				break;
			case cuoidong3: ToaDoChuyenDong=daudong0,FlagGanCuoiDong=1;
				break;
			default:break;
	}

	#elif (lines==2)

		switch (x){
			case cuoidong0: ToaDoChuyenDong=daudong1;FlagGanCuoiDong=1;
				break;
			case cuoidong1: ToaDoChuyenDong=daudong0;FlagGanCuoiDong=1;
				break;
			default:break;
		}

	#elif (lines==1)
		switch (x){
			case cuoidong0: ToaDoChuyenDong=daudong0;FlagGanCuoiDong=1;
				break;
			default: break;
		}
	#endif
	   if(chr=='\n'){
			#if lines==2
				if(x>=daudong1)x=daudong0; 
				else if(x>=daudong0)x=daudong1;		
			#elif lines==4
				if     ((x>=daudong3))x=daudong0;
				else if((x>=daudong1))x=daudong2; 
				else if((x>=daudong2))x=daudong3; 
				else if((x>=daudong0))x=daudong1; 	
			#elif lines==1
				x=daudong0;
			#endif
			    lcd_writecmd(0x80|x); 
			return;
	   }else{
			BIT_DDR_RS_LCD=huongra;
			BIT_OUT_RS_LCD=1;	//GHI DU LIEU
			lcd_write_nibble(chr>>4);
			lcd_write_nibble(chr);	    
			if((FlagGanCuoiDong)){lcd_writecmd(0x80+ToaDoChuyenDong);}
	}
} 
Exemplo n.º 5
0
Arquivo: lcd.c Projeto: jcmvbkbc/stove
void lcd_init(void)
{
	LCD_CTRL_PORT &= ~LCD_CTRL_MASK;
	LCD_CTRL_DDR |= LCD_CTRL_MASK;

	_delay_ms(20);
	lcd_prepare_write(0);
	lcd_write_nibble(0x3);
	_delay_us(40);
	lcd_write_nibble(0x3);
	_delay_us(40);
	lcd_write_nibble(0x3);
	_delay_us(40);
	lcd_write_nibble(0x2);
	_delay_us(40);
	lcd_write(0, 0x28);
	_delay_us(40);
	lcd_on(0);
	lcd_clear();
	lcd_set_entry_mode(LCD_MODE_ID);
	lcd_on(LCD_ON_DISPLAY | LCD_ON_BLINK);
	lcd_init_hints();
}
Exemplo n.º 6
0
Arquivo: lcd.c Projeto: gitpan/i2c
/* Initialisierung des Display's 4-BIT , 2 Zeilen */
int lcd_init(void)
{
 int ret;
 ret = iic_tx_pcf8574(8,PCF_ADRESS); // BL EIN RS/RW 0
 usleep(15000);
 ret=lcd_write_nibble(LCD_IR,0x03);
 usleep(5000);
 ret=lcd_write_nibble(LCD_IR,0x03);
 usleep(200);
 ret=lcd_write_nibble(LCD_IR,0x03);
 usleep(50);
 ret=lcd_write_nibble(LCD_IR,0x02);
 ret=lcd_instr(0x28); 		// 4 BIT-Mode , 2 Zeilen
 ret=lcd_instr(LCD_OFF);	// LCD_Off
 ret=lcd_instr(LCD_CLR);	// LCD_Clear
 ret=lcd_instr(0x02);		// Cursor an 1. Stelle
 ret=lcd_instr(0x06);		// Cursor Richtung +1 
 ret=lcd_instr(0x0E);		// Display an , Cursor klein , kein Blinken
 lcd_ADRESS=0; 			// Aktuelle Adresse = 0
 lcd_BACKLIGHT=1;		// Licht ein	
 lcadr=0;
 return ret;
}
Exemplo n.º 7
0
Arquivo: lcd.c Projeto: jcmvbkbc/stove
static void lcd_write(uint8_t addr, uint8_t v)
{
	lcd_prepare_write(addr);
	lcd_write_nibble(v >> 4);
	lcd_write_nibble(v);
}