LCD_I2C lcd.print has stopped working

Hi Folks, I re-visited an old project today, which uses the LCD_I2C library. I previously compiled this using version 1.6.5.

I have since updated to 1.6.10 (I also have the stand alone version 1.8.2). If I use either of the two newer versions of the IDE 1.6.10 or 1.8.2, the project compiles and loads OK but only the first character of the string sent lcd.print("A string"); will be shown on the LCD display. All the other commands including lcd.write() are working OK.

If I go back to 1.6.5 then the lcd.print() works as expected.

Does anyone know what's going on or what the fix is?

Many Thanks,

Dave.

Here's an explanation of the cause and an example of how libraries broken by the change can be fixed: https://github.com/marcoschwartz/LiquidCrystal_I2C/pull/5

You should try updating your LCD_I2C library to the most recent version to see if it's already been fixed.

Any ideas where I can find an LCD_I2C library? I read your link and this looks a know problem but I don’t know how to use this info to fix it, unless it’s just a matter of finding an updated LCD_I2C library.

Dave.

OK so I couldn't find an updated library so had a look in the .cpp of library file. found the lcd::write(... )method, and changed the return parameter from return (0); to return(1); . This seems to work, but i thought the standard required functions that completed succesfully to return (0), and any non-zero value is an error code?

It maybe that there is a good reason to require this change, but I can't think of one, perhaps someone can help?

Dave.

I think the idea is that write() should return the number of bytes written. In this case 0 would indicate no data was written. I'm not familiar with any standard such as you refer. If you had a boolean return value on a function then 0 would be false and any non-zero number would be true so typically 0 would indicate a failure. I've used negative numbers to indicate error codes in my functions before when zero and positive return values were the standard return values for the function and thus could not be used for error codes. There is some related discussion here that may help you understand the reasoning for the change: https://github.com/arduino/Arduino/issues/4170

I think the Arduino IDE developers considered that the behavior of the marcoschwartz/LiquidCrystal_I2C library was always incorrect but it just happened to still work correctly with the old core.

OK fair enough. I have now fixed the write issue in LVD_I2C and turned to the DS1302 library in order to get rid of the "predicated conversion ...." warning caused by initialising char* array with a fixed string contstant e.g. "xxxxxxx". the fix is to add a cast for (char*) to the string contant definition. Finally I fixed the day name string error. the orginal library code initialised char* to the long day names and then if SHORT_FORMAT was defined set the 3rd character of the arrray to [0]. This had no effect using the lcd.print(...) to print day name string. So I re-wrote it to set up the strings to LONG or SHORT format depending on the setting of the flag.

I now have an LCD clock display using the LCD_IC2 and DS1302 libraries that works and compiles without warnings!