From a2923bc0c02d6bee6a3711b4da2e60622075f38e Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Wed, 10 Jul 2013 01:28:02 +0200 Subject: [PATCH] Retransmit in case of NACK --- src/tinyLCD_I2C/tinyLCD_I2C.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/tinyLCD_I2C/tinyLCD_I2C.cpp b/src/tinyLCD_I2C/tinyLCD_I2C.cpp index f9b2584..110740c 100644 --- a/src/tinyLCD_I2C/tinyLCD_I2C.cpp +++ b/src/tinyLCD_I2C/tinyLCD_I2C.cpp @@ -173,12 +173,16 @@ inline size_t tinyLCD_I2C::write(uint8_t value) { // write either command or data void tinyLCD_I2C::send(uint8_t value, uint8_t mode) { - Wire.beginTransmission(_Addr); - if ( mode == 0 ) { - Wire.write(mode); - } - Wire.write((int)(value)); - Wire.endTransmission(); + int ret = 0; + uint8_t repeat = 4; + do { + Wire.beginTransmission(_Addr); + if ( mode == 0 ) { + Wire.write(mode); + } + Wire.write((int)(value)); + ret = Wire.endTransmission(); + } while (ret && repeat--); }