From 80fc9e8a686293cc8c2009755efc73fe44d34e66 Mon Sep 17 00:00:00 2001 From: Neil McKechnie Date: Wed, 25 Aug 2021 00:29:57 +0100 Subject: [PATCH] Make LCD Display I2C calls synchronous. --- LiquidCrystal_I2C.cpp | 6 +++--- LiquidCrystal_I2C.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/LiquidCrystal_I2C.cpp b/LiquidCrystal_I2C.cpp index 865868a..d7953f7 100644 --- a/LiquidCrystal_I2C.cpp +++ b/LiquidCrystal_I2C.cpp @@ -200,7 +200,7 @@ void LiquidCrystal_I2C::send(uint8_t value, uint8_t mode) { outputBuffer[len++] = highnib; outputBuffer[len++] = lownib|En; outputBuffer[len++] = lownib; - I2CManager.write(_Addr, outputBuffer, len); + I2CManager.write(_Addr, outputBuffer, len); // Write command synchronously } // write 4 data bits to the HD44780 LCD controller. @@ -214,7 +214,7 @@ void LiquidCrystal_I2C::write4bits(uint8_t value) { uint8_t len = 0; outputBuffer[len++] = _data|En; outputBuffer[len++] = _data; - I2CManager.write(_Addr, outputBuffer, len); + I2CManager.write(_Addr, outputBuffer, len); // Write command synchronously } // write a byte to the PCF8574 I2C interface. We don't need to set @@ -223,5 +223,5 @@ void LiquidCrystal_I2C::expanderWrite(uint8_t value) { // Wait for previous request to complete before writing to outputbuffer. requestBlock.wait(); outputBuffer[0] = value | _backlightval; - I2CManager.write(_Addr, outputBuffer, 1); + I2CManager.write(_Addr, outputBuffer, 1); // Write command synchronously } \ No newline at end of file diff --git a/LiquidCrystal_I2C.h b/LiquidCrystal_I2C.h index 6d65541..6cd4384 100644 --- a/LiquidCrystal_I2C.h +++ b/LiquidCrystal_I2C.h @@ -90,7 +90,8 @@ private: I2CRB requestBlock; uint8_t outputBuffer[4]; - bool isBusy() { return requestBlock.isBusy(); } + // I/O is synchronous, so if this is called we're not busy! + bool isBusy() { return false; } }; #endif