Esempio n. 1
0
void GoTo(unsigned char x, unsigned char y){
	switch (y) {
		case 0: 

		lcd_cmd_write(SET_DRAM_ADDR+x);
		lcd_wait(WAIT_15m);  
		break;

		case 1: 

		lcd_cmd_write(SET_DRAM_ADDR+line_1+x);
		lcd_wait(WAIT_15m);  
		break;

		case 2:
		lcd_cmd_write(SET_DRAM_ADDR+line_2+x);
		lcd_wait(WAIT_15m);  
		break;

		case 3:
		lcd_cmd_write(SET_DRAM_ADDR+line_3+x);
		lcd_wait(WAIT_15m);  
		break;
		
		default:
		break;
	}

}
Esempio n. 2
0
//ghi font luu trong chuoi *str vao vung cgram co dia chi 0-7
void lcd_make_font(char  code *str,sttchar){	// sao chep font toi cgram, sttchar la stt ma ascii (ty 0 den 7)
	unsigned char i;
	if(sttchar>7)i=0x40;else i=sttchar*8+0x40; // tinh toa do bat dau tu 0
	lcd_wait();
	lcd_writecmd(i);// di chuyen con tro toi vung cgram
	for (i=0; i<7; i++){	//khong ghi dlieu 8 vi dlieu nay la lua chon con tro
		lcd_wait(); 
		lcd_write_byte(str[i]); //ghi tung dlieu vao cgram
	}
}
Esempio n. 3
0
unsigned int getkeyab(unsigned int dmin,unsigned int dmax,unsigned char display){   //bien x dung xac nhan dat timeout, nhap va0 so >=a <=b
	//unsigned char arrbuff[33];//so toi da 65536 la 5 chu + 1 null cua chuoi =6
	unsigned char i,strmax,strmin,sobam;
	unsigned long digi=0,temp,toadotruyen=lcd_wait();
	while(getbell()!=offbell);
	strmax=digi2text(lcd_buff,10,dmax)-1;//so chu so cua dmax, bi loi truyen tham so sai
	strmin=digi2text(lcd_buff,10,dmin)-1;
	if(display&minmax_){
		sprintf(lcd_buff,"%u->%u",dmin,dmax);
		lcd_putsxy(lcd_buff,0,lines-1);
		lcd_goto(toadotruyen);
	}
	
	if(display&PAXX_)for(i=0;i<strmax+1;i++){lcd_putchar('X');}
	lcd_goto(toadotruyen);
	
	for(i=(strmax);i!=0xFF;i--){
		//while(ir_in());
		thulaichuso:
		delay_ms(100);
		while((temp=ir_getkeytimeout(offbell&(~diir_),0))>9);//tranh tran so ma thoi
		sobam=(unsigned char)temp+0x30;
		temp=digi+temp*xpowy(10,i);
		if(strmin<i){if(temp>dmax)goto thulaichuso;}
		else {if((temp<dmin)||(temp>dmax)) goto thulaichuso;}
		
		if(display&phimtm_)lcd_putchar(sobam);
		//xongthem1chuso:
		digi=temp;
		setbell(binhthuong);
	}
	setbell(bellsucsesful);//da nhap thanh cong	
	while(getbell()!=offbell);
	return digi;
}
void lcd_inst_write(uint8_t data) {
    lcd_wait();
    write(); inst();
    LCD_DATA_PORT = data;
    send();

}
Esempio n. 5
0
void lcd_init()    // Works like a constructor
   
   {

   // Power on delay
	lcd_direction |= 0xfc;							//	set port a as output
   lcd_wait( 20000 );                                   // Power on wait 
   lcd_wait( 20000 );
	lcd_port &= ~((1<<lcd_E) | (1<<lcd_RS)); // EN=0, RS=0
//	lcd_port &= ~(1<<lcd_RW);               // Set RW = 0 in case it is connected
 
   lcd_nibble_transfer(SET_FUNCTION+IN8_BIT);
   //lcd_wait(longdelay );  						 // wait 24 ms
   _delay_ms(24);
   lcd_nibble_transfer(SET_FUNCTION+IN8_BIT);
   //lcd_wait(longdelay);
    _delay_ms(24);
	lcd_nibble_transfer(SET_FUNCTION+IN8_BIT);
   //lcd_wait(longdelay);
    _delay_ms(24);
	lcd_nibble_transfer(SET_FUNCTION);
  // lcd_wait(longdelay);
   _delay_ms(24);
   lcd_cmd_write(SET_FUNCTION+LN2_BIT);                 // Function set: 0x28  2 lines
  // lcd_wait(WAIT_15m);                              // Wait 39 uS
 _delay_ms(2);
    lcd_cmd_write(SET_DISPLAY);						//display off
 //lcd_wait(WAIT_15m);
_delay_ms(2);	
	lcd_cmd_write(CLR_DISPLAY);       // Display clear: 0x01 clear data                 	 
	
  // lcd_wait(WAIT_15m);                // 1.53 mS  
     _delay_ms(2);                  
                               

   lcd_cmd_write(SET_ENTRY_MODE+INC_BIT);          //  +INC_BIT  // Entry mode set: shift cursor 1 position to right
  //   lcd_wait(WAIT_15m);      
  _delay_ms(2);
    lcd_cmd_write(SET_DISPLAY+ON_BIT+CUR_BIT+BLK_BIT); //+CUR_BIT+BLK_BIT);   Display ON/OFF control: 0x0f
  //   lcd_wait(WAIT_15m);                               // Wait 39 uS                      // 1.53 mS     

  //lcd_wait(WAIT_15m);                            // 1.53 mS  
_delay_ms(2);
  createCustomFont();
 _delay_ms(2);
 lcd_cmd_write(RTN_HOME);
   } // end lcd_init()
void lcd_data_write(uint8_t data) {
    lcd_wait();

    write(); data();
    LCD_DATA_PORT = data;
    send();

}
Esempio n. 7
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);
}
Esempio n. 8
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);}
	}
} 
Esempio n. 9
0
static inline void lcd_command(unsigned char c)
{
	/*
	 * "Clear Display" and "Return Home" commands
	 * take more time to complete than others.
	 */
	int i = ((c == HD44780_CLR_DISPLAY || c == HD44780_RET_HOME) ? 30 : 1);

	writew(c | HD44780_INSTR, base_addr);
	do lcd_wait(); while(--i);
}
Esempio n. 10
0
void mips_display_message(const char *str)
{
	static unsigned int __iomem *display;
	char ch;
	int i;

	if (unlikely(display == NULL))
		display = ioremap_nocache(LCD_DISPLAY_POS_BASE,
			(8 * sizeof(int)));

	for (i = 0; i < 16; i++) {
		if (*str)
			ch = *str++;
		else
			ch = ' ';
		lcd_wait(display);
		__raw_writel((LCD_SETDDRAM | i),
			(display + DISPLAY_LCDINSTRUCTION));
		lcd_wait(display);
		__raw_writel(ch, display + DISPLAY_LCDDATA);
	}
}
Esempio n. 11
0
//! write a zero-terminated ASCII string to the display
void LCDPutString(char *str) {
   char c,index=0;
	for (; (c = *str) != 0; str++){
	
		if((c=='\r') || c=='\n');
		else
		lcd_data_write(c);

		index++;

		if (index>=20) {
			lcd_cmd_write(SET_DRAM_ADDR+line_3);
			lcd_wait(WAIT_15m);
			index=0;
		}

	}
}
Esempio n. 12
0
void lcd_data(char datas)
{
/******************
*    LCD写数据函数
*
*    参数:数据(字符格式的数字、字符等)
*    返回:空
*
*    描述:
*        EA=0 ==> RS=EN=0,RW=1 ==> 输出  ==>EN=0,EA=1
*******************/
	EA=0;
	lcd_wait();
	LCD_RS=1;
	LCD_RW=0;
	LCD_EN=1;
	LCD_DATA=datas;
	LCD_EN=0;
	EA=1;
	return;
}
Esempio n. 13
0
void lcd_cmd(char cmd)
{
/******************
*    LCD写指令函数
*
*    参数:指令代码
*    返回:空
*
*    描述:
*        EA=0 ==> RS=RW=0,EN=1 ==> 输出  ==>EN=0,EA=1
*******************/
	EA=0;
	lcd_wait();
	LCD_RS=0;
	LCD_RW=0;
	LCD_EN=1;
	LCD_DATA=cmd;
	LCD_EN=0;
	EA=1;
	return;
}
Esempio n. 14
0
static inline void lcd_writechar(unsigned char c)
{
	writew(c | HD44780_WR_DATA, base_addr);
	lcd_wait();
}
Esempio n. 15
0
//clear the display
void lcdClear(void) {
	lcd_cmd_write(CLR_DISPLAY);
	lcd_wait(WAIT_15m);
	lcd_cmd_write(CLR_DISPLAY+RTN_HOME);
	lcd_wait(WAIT_15m);
}