Пример #1
0
/**
 * Initialize the LCD driver.
 * 
 * @param cur Cursor ON/OFF.
 * @param blk Blinking cursor ON/OFF.
 */
void lcd_init(bool cur, bool blk) {
	// Setup the pins and wait for the driver to stabilize.
	lcd_setup();
	delay_ms(45);

	// Initialization. For more information about this madness check page
	// 46 of the datasheet.
	lcd_init_function_set();
	delay_us(4500);
	lcd_init_function_set();
	delay_us(150);
	lcd_init_function_set();
	lcd_function_set();  // The last madness.

	lcd_display_control(TRUE, cur, blk);
	_lcd_clear();
	lcd_entry_mode();
}
Пример #2
0
int _lcd_enable()
// function to enable the 6wire lcd interface
{



//  intialize with three 'Function Set' commands
    wait(100);
    _lcd_control( 0x30, 5 );
    _lcd_control( 0x30, 1 );
    _lcd_control( 0x30, 1 );
    
    _lcd_control( 0x20, 1 );                            // Put it into 4bit mode
    _lcd_control( 0x20, 1 ); _lcd_control( 0x80, 1 );   // N=1(2lines), F=0(5x7) , 0,0
    
    _lcd_control( 0x00, 1 ); _lcd_control( 0x80, 1 );   // Enable Disp,Curs :  1, D=0(disp off), C=0(Crs off), B=0(Blnk off)  
    _lcd_control( 0x00, 1 ); _lcd_control( 0xC0, 1 );   // Enable Disp,Curs :  1, D=0(disp off), C=0(Crs off), B=0(Blnk off)  
    _lcd_control( 0x00, 1 ); _lcd_control( 0x60, 1 );   // 'Entry Mode Set' :  0, 1, ID=1(inc curs), S=0(shift dsp off)
    
    _lcd_clear();
  
}
Пример #3
0
/** Initial Display settings! */
void _lcd_begin(u8 lines, u8 dotsize)
{
	if (lines > 1)
		_displayfunction |= LCD_2LINE;

	_numlines = lines;
	_currline = 0;

	// Some one line displays can select 10 pixel high font
	if ((dotsize != 0) && (lines == 1))
		_displayfunction |= LCD_5x10DOTS;

	Delayms(15); //Pinguino needs it? long delay on startup time!

	// Now we pull both RS and R/W low to begin commands
	digitalwrite(_rs_pin, LOW);
	digitalwrite(_enable_pin, LOW);

	//put the LCD into 4 bit mode
	if (! (_displayfunction & LCD_8BITMODE) )
	{
		// this is according to the hitachi HD44780 datasheet p46, figure 24

		// we start in 8bit mode, try to set 4 bit mode
		_lcd_write4bits(0x03);
		Delayms(5); // wait min 4.1ms
		// second try
		_lcd_write4bits(0x03);
		Delayus(150); // wait min 4.1ms
		// third go!
		_lcd_write4bits(0x03); 
		Delayus(150);
		// finally, set to 8-bit interface
		_lcd_write4bits(0x02); 
	}
	//put the LCD into 8 bit mode
	else
	{
		// this is according to the hitachi HD44780 datasheet p45, figure 23

		// Send function set command sequence
		_lcd_command(LCD_FUNCTIONSET | _displayfunction);
		Delayus(4500);  // wait more than 4.1ms

		// second try
		_lcd_command(LCD_FUNCTIONSET | _displayfunction);
		Delayus(150);

		// third go
		_lcd_command(LCD_FUNCTIONSET | _displayfunction);
	}

	// finally, set # lines, font size, etc.
	_lcd_command(LCD_FUNCTIONSET | _displayfunction);  

	// turn the display on with no cursor or blinking default
	_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;  
	_lcd_display();

	// clear it off
	_lcd_clear();

	// Initialize to default text direction (for romance languages)
	_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
	// set the entry mode
	_lcd_command(LCD_ENTRYMODESET | _displaymode);
}
Пример #4
0
/**
 * Clears the LCD with the correct delay.
 */
void lcd_clear() {
	_lcd_clear();
	delay_ms(1);
}