Esempio n. 1
0
void SpiLcd::begin(uint8_t cols, uint8_t lines) {
	_numlines = lines;
	_currline = 0;
	_currpos = 0;
  
	// Set all outputs of shift register to low, this turns the backlight ON.
	_spiByte = 0x00;
	spiOut();
	
	// The following initialization sequence should be compatible with: 
	// - Newhaven OLED displays
	// - Standard HD44780 or S6A0069 LCD displays
	delayMicroseconds(50000); // wait 50 ms just to be sure that the lcd is initialized

	write4bits(0x03); //set to 8-bit
	delayMicroseconds(50000); // wait > 4.1ms
	write4bits(0x03); //set to 8-bit
	delayMicroseconds(1000); // wait > 100us
	write4bits(0x03); //set to 8-bit
	delayMicroseconds(50000); // wait for execution
	write4bits(0x02); //set to 4-bit
	delayMicroseconds(50000); // wait for execution
	command(0x28); // set to 4-bit, 2-line
		
	clear();	// display clear
	// Entry Mode Set:
	leftToRight();
	noAutoscroll();
	
	home();
	
	//noCursor();
	display();
}
void LiquidCrystalNew_T3TWI::initChip(uint8_t dotsize, byte witchEnablePin) {  
	byte	displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
	byte i;
	if (_lcd_lines > 1) displayfunction |= LCD_2LINE;
	// for some 1 line displays you can select a 10 pixel high font
	if ((dotsize != 0) && (_lcd_lines == 1)) displayfunction |= LCD_5x10DOTS;

	for (i=0;i<18;i++) {
		delayMicroseconds(LCD_STARTUP_DLY);
	}

	setDataMode(0);//COMMAND MODE
	writeGpio(_theData & ~witchEnablePin);  // En LOW---------------------------------------*/
	write4bits(0x03);
	delayMicroseconds(5000); // I have one LCD for which 4500 here was not long enough.
	// second try
	write4bits(0x03);      
	delayMicroseconds(150); // wait 
	// third go!
	write4bits(0x03); 
	delayMicroseconds(150);
	// finally, set to 4-bit interface
	write4bits(0x02); 
	delayMicroseconds(150);
	// finally, set # lines, font size, etc.
	command(LCD_FUNCTIONSET | displayfunction);  
	// turn the display on with no cursor or blinking default
	_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;  
	display();
	// clear it off
	clear();
	// Initialize to default text direction (for romance languages)
	_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
	// set the entry mode
	command(LCD_ENTRYMODESET | _displaymode);	
	noAutoscroll();
}