コード例 #1
0
void LiquidCrystal_I2C::pulseEnable(uint8_t _data){
	expanderWrite(_data | En);	// En high
	delayMicroseconds(1);		// enable pulse must be >450ns
	
	expanderWrite(_data & ~En);	// En low
	delayMicroseconds(50);		// commands need > 37us to settle
} 
コード例 #2
0
uint8_t LiquidCrystal_I2C::pulseEnable(uint8_t _data){
	uint8_t ret;
	
	ret = expanderWrite(_data | En);	// En high
	if (ret != 0) return (ret);
	    
	delayMicroseconds(1);		// enable pulse must be >450ns
	
	ret = expanderWrite(_data & ~En);	// En low
	delayMicroseconds(50);		// commands need > 37us to settle
	
	return ret;
} 
コード例 #3
0
ファイル: LiquidCrystal_I2C.cpp プロジェクト: alfo/door-sign
void LiquidCrystal_I2C::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
        if (lines > 1) {
                _displayfunction |= LCD_2LINE;
        }
        _numlines = lines;

        // for some 1 line displays you can select a 10 pixel high font
        if ((dotsize != 0) && (lines == 1)) {
                _displayfunction |= LCD_5x10DOTS;
        }

        // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
        // according to datasheet, we need at least 40ms after power rises above 2.7V
        // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
        delay(50);

        // Now we pull both RS and R/W low to begin commands
        expanderWrite(_backlightval);   // reset expanderand turn backlight off (Bit 8 =1)
        delay(1000);

        //put the LCD into 4 bit mode
        // this is according to the hitachi HD44780 datasheet
        // figure 24, pg 46

          // we start in 8bit mode, try to set 4 bit mode
   write4bits(0x03 << 4);
   delayMicroseconds(4500); // wait min 4.1ms

   // second try
   write4bits(0x03 << 4);
   delayMicroseconds(4500); // wait min 4.1ms

   // third go!
   write4bits(0x03 << 4);
   delayMicroseconds(150);

   // finally, set to 4-bit interface
   write4bits(0x02 << 4);



        // 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 roman languages)
        _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;

        // set the entry mode
        command(LCD_ENTRYMODESET | _displaymode);

        home();

}
コード例 #4
0
uint8_t LiquidCrystal_I2C::write4bits(uint8_t value) {
	uint8_t ret;
	
	ret = expanderWrite(value);
	if (ret != 0) return (ret);
	    
	return pulseEnable(value);
}
コード例 #5
0
void LiquidCrystal_I2C::write4bits(uint8_t value) {
	expanderWrite(value);
	pulseEnable(value);
}
コード例 #6
0
void LiquidCrystal_I2C::backlight(void) {
	_backlightval=LCD_BACKLIGHT;
	expanderWrite(0);
}
コード例 #7
0
ファイル: LCD_I2C.cpp プロジェクト: RitterRBC/Arduino
void LCD_I2C::backlight(void) {
	_backlightval=LCD_BACKLIGHT;
	expanderWrite(0);
}
コード例 #8
0
ファイル: IicLcd.cpp プロジェクト: thorrak/brewpi-esp8266
void IIClcd::write4bits(uint8_t value) {
	expanderWrite(value);
	pulseEnable(value);
}
コード例 #9
0
ファイル: IicLcd.cpp プロジェクト: thorrak/brewpi-esp8266
void IIClcd::backlight(void) {
	_backlightval = LCD_BACKLIGHT;
	expanderWrite(0);
}
コード例 #10
0
void PCF8574_HD44780_I2C::write4bits(uint8_t value) {
	expanderWrite(value);
	pulseEnable(value);
}
コード例 #11
0
void PCF8574_HD44780_I2C::backlight(void) {
	_backlightval=LCD_BACKLIGHT;
	expanderWrite(0);
}
コード例 #12
0
// Turn the (optional) backlight off/on
void TinyLiquidCrystal_I2C::noBacklight(void) {
	_backlightval=LCD_NOBACKLIGHT;
	expanderWrite(0);
}
コード例 #13
0
void LiquidCrystal::begin() {
#if defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega1284__)
    if (_type == LCD_I2C) {
        _displayfunction = LCD_4BITMODE | LCD_2LINE | LCD_5x8DOTS;

        // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
        // according to datasheet, we need at least 40ms after power rises above 2.7V
        // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
        delay(50);

        // Now we pull both RS and R/W low to begin commands
        expanderWrite(_backlightval);	// reset expanderand turn backlight off (Bit 8 =1)
        delay(1000);

        //put the LCD into 4 bit mode
        // this is according to the hitachi HD44780 datasheet
        // figure 24, pg 46

        // we start in 8bit mode, try to set 4 bit mode
        write4bits(0x03 << 4);
        delayMicroseconds(4500); // wait min 4.1ms

        // second try
        write4bits(0x03 << 4);
        delayMicroseconds(4500); // wait min 4.1ms

        // third go!
        write4bits(0x03 << 4);
        delayMicroseconds(150);

        // finally, set to 4-bit interface
        write4bits(0x02 << 4);

        // 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 roman languages)
        _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;

        // set the entry mode
        command(LCD_ENTRYMODESET | _displaymode);

        home();
    }
#endif

    if (_type == LCD_STD) {
        _displayfunction |= LCD_2LINE;
        _numlines = 2;
        _currline = 0;

        // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
        // according to datasheet, we need at least 40ms after power rises above 2.7V
        // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
        delayMicroseconds(50000);
        // Now we pull both RS and R/W low to begin commands
        digitalWrite(_rs_pin, LOW);
        digitalWrite(_enable_pin, LOW);
        if (_rw_pin != 255) {
            digitalWrite(_rw_pin, LOW);
        }

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

            // we start in 8bit mode, try to set 4 bit mode
            write4bits(0x03);
            delayMicroseconds(4500); // wait min 4.1ms

            // second try
            write4bits(0x03);
            delayMicroseconds(4500); // wait min 4.1ms

            // third go!
            write4bits(0x03);
            delayMicroseconds(150);

            // finally, set to 4-bit interface
            write4bits(0x02);
        } else {
            // this is according to the hitachi HD44780 datasheet
            // page 45 figure 23

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

            // second try
            command(LCD_FUNCTIONSET | _displayfunction);
            delayMicroseconds(150);

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

        // 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);
    }
}