Beispiel #1
0
void LCDinit(void)//Initializes LCD
{
	_delay_ms(15);
	LDP=0x00;
	LCP=0x00;
	LDDR|=1<<LCD_D7|1<<LCD_D6|1<<LCD_D5|1<<LCD_D4;
	LCDR|=1<<LCD_E|1<<LCD_RW|1<<LCD_RS;
   //---------one------
	LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4; //4 bit mode
	LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;		
	_delay_ms(1);
	LCP&=~(1<<LCD_E);
	_delay_ms(1);
	//-----------two-----------
	LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4; //4 bit mode
	LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;		
	_delay_ms(1);
	LCP&=~(1<<LCD_E);
	_delay_ms(1);
	//-------three-------------
	LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|0<<LCD_D4; //4 bit mode
	LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;		
	_delay_ms(1);
	LCP&=~(1<<LCD_E);
	_delay_ms(1);
	//--------4 bit--dual line---------------
	LCDsendCommand(0b00101000);
   //-----increment address, cursor shift------
	LCDsendCommand(0b00001110);


}			
Beispiel #2
0
void LCDinit(void)	//Initializes LCD 
{
	_delay_ms(15);
		
	//zero to data pins
	LCDMix_4Bit(0b00000000);

	//zero to control pins
	LDPRS &= ~(1 << LCD_RS);
	LDPRW &= ~(1 << LCD_RW);
	LDPE &= ~(1 << LCD_E);
	
	//set data direction
	LDDD4 |= 1 << LCD_D4;
	LDDD5 |= 1 << LCD_D5;
	LDDD6 |= 1 << LCD_D6;
	LDDD7 |= 1 << LCD_D7;
		
	//control direction pins
	LDDRS |= 1 << LCD_RS;
	LDDRW |= 1 << LCD_RW;
	LDDE |= 1 << LCD_E;
	
	//---------one------
	LCDMix_4Bit(0b00110000);
	LDPE |= 1 << LCD_E;
	_delay_ms(1);
	
	LDPE &= ~(1 << LCD_E);
	_delay_ms(1);
		
	//-----------two-----------
	LCDMix_4Bit(0b00110000);
	LDPE |= 1 << LCD_E;
	_delay_ms(1);
	
	LDPE &= ~(1 << LCD_E);
	_delay_ms(1);
	
	//-------three-------------
	LCDMix_4Bit(0b00100000);
	LDPE |= 1 << LCD_E;		
	_delay_ms(1);
		
	LDPE &= ~(1 << LCD_E);
	_delay_ms(1);
		
	//--------4 bit--dual line---------------
	LCDsendCommand(0b00101000);
	
	//-----increment address, invisible cursor shift------
	LCDsendCommand(0b00001100);
}
//Moves cursor by n poisitions left
void LCDcursorRight(uint8_t n)
{
	for (uint8_t i=0;i<n;i++)
	{
		LCDsendCommand(0x14);
	}
}
Beispiel #4
0
void LCDcursorLeft(uint8_t n)	//Moves cursor by n positions left
{
	for(uint8_t i = 0; i < n; i++)
	{
		LCDsendCommand(0x10);
	}
}
Beispiel #5
0
void LCDGotoXY(uint8_t x, uint8_t y)	//Cursor to X Y position
{
    register uint8_t DDRAMAddr;
    // remap lines into proper order
    switch(y)
    {
    case 0:
        DDRAMAddr = LCD_LINE0_DDRAMADDR+x;
        break;
    case 1:
        DDRAMAddr = LCD_LINE1_DDRAMADDR+x;
        break;
    case 2:
        DDRAMAddr = LCD_LINE2_DDRAMADDR+x;
        break;
    case 3:
        DDRAMAddr = LCD_LINE3_DDRAMADDR+x;
        break;
    default:
        DDRAMAddr = LCD_LINE0_DDRAMADDR+x;
    }
    // set data address
    LCDsendCommand(1<<LCD_DDRAM | DDRAMAddr);

}
Beispiel #6
0
void LCDshiftRight(uint8_t n)	//Scrol n of characters Left
{
	for (uint8_t i=0;i<n;i++)
	{
		LCDsendCommand(0x18);
	}
}
Beispiel #7
0
void LCDcursorRight(uint8_t n)	//Moves cursor by n poisitions left
{
	for (uint8_t i=0;i<n;i++)
	{
		LCDsendCommand(0x14);
	}
}
//Moves cursor by n poisitions left
void LCDcursorLeft(uint8_t n)
{
	for (uint8_t i=0;i<n;i++)
	{
		LCDsendCommand(0x10);
	}
}
Beispiel #9
0
void LCDshiftLeft(uint8_t n)	//Scroll n of characters Right
{
	for(uint8_t i = 0; i < n; i++)
	{
		LCDsendCommand(0x1E);
	}
}
//Scrol n of characters Left
void LCDshiftRight(uint8_t n)
{
	uint8_t i;
	for (i=0;i<n;i++)
	{
		LCDsendCommand(0x18);
	}
}
//Scrol n of characters Right
void LCDshiftLeft(uint8_t n)
{
	uint8_t i;
	for (i=0;i<n;i++)
	{
		LCDsendCommand(0x1C);
	}
}
Beispiel #12
0
/*
const uint8_t backslash[] PROGMEM= 
{
0b00000000,//back slash
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
0b00000000,
0b00000000
};
LCDdefinechar(backslash,0);
*/
void LCDdefinechar(const uint8_t *pc,uint8_t char_code){
	uint8_t a, pcc;
	uint16_t i;
	a=(char_code<<3)|0x40;
	for (i=0; i<8; i++){
		pcc=pgm_read_byte(&pc[i]);
		LCDsendCommand(a++);
		LCDsendChar(pcc);
		}
}
//lcd init
void LCDinit()
{
	//setup lcd pin
	lcd_pin_setup();
	
	//init lcd
	_delay_ms(50);
	bit_clear(LCD_RS_PORT, BIT(LCD_RS_BIT));
	bit_clear(LCD_EN_PORT, BIT(LCD_EN_BIT));
	bit_set(LCD_D4_PORT, BIT(LCD_D4_BIT));
	bit_set(LCD_D5_PORT, BIT(LCD_D5_BIT));
	LCDtoggleEn();
	_delay_ms(10);
	
	//LCD_PORT=0x30;	//DB4 = DB5 = 1, RS = RW = 0
	LCDtoggleEn();
	_delay_ms(5);
	
	//LCD_PORT=0x30;	//DB4 = DB5 = 1, RS = RW = 0
	LCDtoggleEn();
	_delay_ms(5);
	
	//LCD_PORT=0x20;	//DB5 = 1, RS = RW = 0
	bit_clear(LCD_D4_PORT, BIT(LCD_D4_BIT));
	LCDtoggleEn();
	_delay_ms(5);
	
	//set setting
	LCDsendCommand(0x28);	//4bit 2line 5x7font	
	LCDsendCommand(0x0c);	//display on cursor off
	LCDsendCommand(0x06);	//auto inc display shift off
	LCDsendCommand(0x80);	//cursor home
	
	//init 8 custom chars
	//uint8_t ch=0, chn=0;
	//while(ch<64)
	//{
		//LCDdefinechar((LcdCustomChar+ch),chn++);
		//ch=ch+8;
	//}
	LCDDefineProgressBarChar();
}
//Clears LCD
void LCDclr()
{
	LCDsendCommand(1<<LCD_CLR);
}
Beispiel #15
0
void LCDvisible(void)		//Shows LCD
{
	LCDsendCommand(0x0C);
}
//displays LCD cursor
void LCDcursorOn()
{
	LCDsendCommand(0x0E);
}
Beispiel #17
0
void LCDcursorOFF(void)	//turns OFF cursor
{
	LCDsendCommand(0x0C);
}
Beispiel #18
0
void LCDblank(void)		//blanks LCD
{
	LCDsendCommand(0x08);
}
Beispiel #19
0
void LCDcursorOn(void) //displays LCD cursor
{
	LCDsendCommand(0x0E);
}
Beispiel #20
0
void LCDcursorOnBlink(void)	//displays LCD blinking cursor
{
	LCDsendCommand(0x0F);
}
//turns OFF cursor
void LCDcursorOFF()
{
	LCDsendCommand(0x0C);
}
//displays LCD blinking cursor
void LCDcursorOnBlink()
{
	LCDsendCommand(0x0F);
}
Beispiel #23
0
void LCDinit(void)//Initializes LCD
{
#ifdef LCD_4bit	
	//4 bit part
	_delay_ms(15);
	LDP=0x00;
	LCP=0x00;
	LDDR|=1<<LCD_D7|1<<LCD_D6|1<<LCD_D5|1<<LCD_D4;
	LCDR|=1<<LCD_E|1<<LCD_RW|1<<LCD_RS;
   //---------one------
	LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4; //4 bit mode
	LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;		
	_delay_ms(1);
	LCP&=~(1<<LCD_E);
	_delay_ms(1);
	//-----------two-----------
	LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4; //4 bit mode
	LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;		
	_delay_ms(1);
	LCP&=~(1<<LCD_E);
	_delay_ms(1);
	//-------three-------------
	LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|0<<LCD_D4; //4 bit mode
	LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;		
	_delay_ms(1);
	LCP&=~(1<<LCD_E);
	_delay_ms(1);
	//--------4 bit--dual line---------------
	LCDsendCommand(0b00101000);
   //-----increment address, invisible cursor shift------
	LCDsendCommand(0b00001100);
		//init 8 custom chars
	uint8_t ch=0, chn=0;
	while(ch<64)
	{
		LCDdefinechar((LcdCustomChar+ch),chn++);
		ch=ch+8;
	}


#else
	//8 bit part
	_delay_ms(15);
	LDP=0x00;
	LCP=0x00;
	LDDR|=1<<LCD_D7|1<<LCD_D6|1<<LCD_D5|1<<LCD_D4|1<<LCD_D3
			|1<<LCD_D2|1<<LCD_D1|1<<LCD_D0;
	LCDR|=1<<LCD_E|1<<LCD_RW|1<<LCD_RS;
   //---------one------
	LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4|0<<LCD_D3
			|0<<LCD_D2|0<<LCD_D1|0<<LCD_D0; //8 it mode
	LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;		
	_delay_ms(1);
	LCP&=~(1<<LCD_E);
	_delay_ms(1);
	//-----------two-----------
	LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4|0<<LCD_D3
			|0<<LCD_D2|0<<LCD_D1|0<<LCD_D0; //8 it mode
	LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;		
	_delay_ms(1);
	LCP&=~(1<<LCD_E);
	_delay_ms(1);
	//-------three-------------
	LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4|0<<LCD_D3
			|0<<LCD_D2|0<<LCD_D1|0<<LCD_D0; //8 it mode
	LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;		
	_delay_ms(1);
	LCP&=~(1<<LCD_E);
	_delay_ms(1);
	//--------8 bit dual line----------
	LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4|1<<LCD_D3
			|0<<LCD_D2|0<<LCD_D1|0<<LCD_D0; //8 it mode
	LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;		
	_delay_ms(1);
	LCP&=~(1<<LCD_E);
	_delay_ms(1);
   //-----increment address, invisible cursor shift------
	LDP=0<<LCD_D7|0<<LCD_D6|0<<LCD_D5|0<<LCD_D4|1<<LCD_D3
			|1<<LCD_D2|0<<LCD_D1|0<<LCD_D0; //8 it mode
	LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;		
	_delay_ms(1);
	LCP&=~(1<<LCD_E);
	_delay_ms(5);
		//init custom chars
	uint8_t ch=0, chn=0;
	while(ch<64)
	{
		LCDdefinechar((LcdCustomChar+ch),chn++);
		ch=ch+8;
	}

#endif
}			
//blanks LCD
void LCDblank()
{
	LCDsendCommand(0x08);
}
//LCD cursor home
void LCDhome()
{
	LCDsendCommand(1<<LCD_HOME);
}
//Shows LCD
void LCDvisible()
{
	LCDsendCommand(0x0C);
}
Beispiel #27
0
void LCDclr(void)				//Clears LCD
{
	LCDsendCommand(1<<LCD_CLR);
}
Beispiel #28
0
void LCDhome(void)			//LCD cursor home
{
	LCDsendCommand(1<<LCD_HOME);
}
Beispiel #29
0
void LCDinit(void)	//Initializes LCD
{

	//power on delay
	_delay_ms(POWER_ON_DELAY);

	//setup data and control registers
	LCD_DDR |= 1 << LCD_D7 | 1 << LCD_D6 | 1 << LCD_D5 | 1 << LCD_D4;
	LCD_CDR |= 1 << LCD_ENABLE | 1 << LCD_RW | 1 << LCD_RS;

	//Issue MSB(0b0011xxxx) command 3 times. use proper timing
	LCD_DATAPORT = 0x00;
	LCD_CONTROLPORT = 0x00;
	LCD_DATAPORT = 0 << LCD_D7 | 0 << LCD_D6 | 1 << LCD_D5 | 1 << LCD_D4; //4 bit mode
	LCD_CONTROLPORT |= 0 << LCD_ENABLE | 0 << LCD_RW | 0 << LCD_RS;

	//1st pulse
	LCDexecute();
	_delay_ms(4); //wait more then 4.1ms

	//2nd pulse
	LCDexecute();

	//3rd pulse
	LCDexecute();


#ifdef LCD_4bit
	//4 bit mode

	//Function Set: change to 4bit mode
	//same call but without D4 bit
	LCD_DATAPORT &= ~(1 << LCD_D4); //4 bit mode
	LCDexecute();

	//4bit mode operation starts here
	//Function Set: 4 bit,dual line,5x8
	LCDsendCommand(
			(1 << LCD_FUNCTION) | (0 << LCD_FUNCTION_8BIT)
					| (1 << LCD_FUNCTION_2LINES) | (0 << LCD_FUNCTION_10DOTS));


#else
	//8-bit mode

	//Function Set: 8 bit,dual line,5x8
	LCDsendCommand(
			(1 << LCD_FUNCTION) | (1 << LCD_FUNCTION_8BIT)
			| (1 << LCD_FUNCTION_2LINES) | (0 << LCD_FUNCTION_10DOTS));

#endif

	//Display Control: disp Off,cursor off,blinking off
	LCDsendCommand(
			(1 << LCD_DISPLAY) | (0 << LCD_DISPLAY_ON) | (0 << LCD_CURSOR_ON)
					| (0 << LCD_BLINK_ON));

	//Clear Display
	LCDsendCommand(1 << LCD_CLR);
	_delay_ms(3); //special more then 3ms case

	//Entry Mode Set: I/D: On S:Off
	LCDsendCommand(
			(1 << LCD_ENTRY_MODE) | (1 << LCD_ENTRY_MODE_INC)
					| (0 << LCD_ENTRY_MODE_SHIFT));

	//End of Initialization , clear display now and switch it ON.

	//Display Control: disp ON,cursor off,blinking off
	LCDsendCommand(
			(1 << LCD_DISPLAY) | (1 << LCD_DISPLAY_ON) | (0 << LCD_CURSOR_ON)
					| (0 << LCD_BLINK_ON));


	//user defined chars definitions come here

	 //defines backslash char symbol in CGRAM memory
	 //LCDdefinechar(backslash,0);

	 //init 8 custom chars
	 uint8_t ch=0, chn=0;
	 while(ch<64)
	 {
	 LCDdefinechar((LCDcustomChar+ch),chn++);
	 ch=ch+8;
	 }



}