From 43b1e8db21aed001e586980e209670c2cc7d5471 Mon Sep 17 00:00:00 2001 From: Neil McKechnie Date: Tue, 21 Feb 2023 11:00:27 +0000 Subject: [PATCH] Update LCD driver to make it more reliable Delay times at startup extended to make start-up configuration more reliable. --- LiquidCrystal_I2C.cpp | 8 ++++---- LiquidCrystal_I2C.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/LiquidCrystal_I2C.cpp b/LiquidCrystal_I2C.cpp index 3bf98ef..b8b8e97 100644 --- a/LiquidCrystal_I2C.cpp +++ b/LiquidCrystal_I2C.cpp @@ -80,15 +80,15 @@ bool LiquidCrystal_I2C::begin() { // we start in 8bit mode, try to set 4 bit mode write4bits(0x03); - delayMicroseconds(4500); // wait min 4.1ms + delayMicroseconds(5000); // wait min 4.1ms // second try write4bits(0x03); - delayMicroseconds(4500); // wait min 4.1ms + delayMicroseconds(5000); // wait min 4.1ms // third go! write4bits(0x03); - delayMicroseconds(150); + delayMicroseconds(5000); // finally, set to 4-bit interface write4bits(0x02); @@ -112,7 +112,7 @@ bool LiquidCrystal_I2C::begin() { /********** high level commands, for the user! */ void LiquidCrystal_I2C::clearNative() { command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero - delayMicroseconds(1600); // this command takes 1.52ms + delayMicroseconds(2000); // this command takes 1.52ms but allow plenty } void LiquidCrystal_I2C::setRowNative(byte row) { diff --git a/LiquidCrystal_I2C.h b/LiquidCrystal_I2C.h index daecd61..650ad15 100644 --- a/LiquidCrystal_I2C.h +++ b/LiquidCrystal_I2C.h @@ -90,7 +90,7 @@ private: uint8_t _displayfunction; uint8_t _displaycontrol; uint8_t _displaymode; - uint8_t _backlightval; + uint8_t _backlightval = 0; uint8_t outputBuffer[4]; I2CRB rb;