LCD library for HD44780 with read and write functions.

4-bit LCD library for HD44780 with read and write functions.

I could not find any LCD library with read functions, so I wrote one myself. The library is based on the Arduino LCD library, but all 8-bit options have been removed for easier legibility. The display is not cleared in setup, so data can be read back after a reset of the Arduino.

The RW pin must be connected for reading operations.
Connect the RS, RW and Enable pins and the d4, d5, d6, d7 pins to Arduino digital pins and enter the Arduino pin numbers in the program (LiquidCrystal lcd(RS,RW,E,d4,d5,d6,d7);

Written on 1/11/2011
Thomas Schultz

LiquidCrystal_rw.zip (5.87 KB)

The display is not cleared in setup, so data can be read back after a reset of the Arduino.

So you have deliberately chosen to vary from the manufacturer's recommendations for initializing the LCD controller. This is not a wise decision in my estimation.

As far as I have determined the current LiquidCrystal library only deviates from the manufacturer's recommendations in one respect and now you are adding another. This is a recipe for disaster.

Don

This is a recipe for disaster.

might be true....

you don't know how long you have been "in reset mode" so

  • can you guarantee the content is still valid? (due to time)
  • can you guarantee the content is not altered otherwise?

To floresta:
You may be right about the dangers to diverge from the recommendations, but is this really such a big deal? A reset is performed after reading the display content, so in the worst case the read operation fails. So the read-back operation is only useful after the display was in a well-defined state, as it should have been if we want to recover useful data.

To robtillaart:
In my case, I don't care about long-term memory, the latter is easily resolved by writing to EEPROM after some period of inactivity. EEPROM, however, is unsuited to store rapidly changing content (in my case, encoder positions) and here the LCD memory offers a simple fix for data recovery.

If there are alternative / better options to deal with data loss upon externally initiated resets, I'd be interested to learn about them.

but is this really such a big deal?

Yes it is.

Don

Insert Quote
Quote
but is this really such a big deal?

Yes it is.

IN the end it depends on what is controlled by the LCD readback, is it a toy or a heartmonitor to name some extremes...

robtillaart:

Insert Quote
Quote
but is this really such a big deal?

Yes it is.

IN the end it depends on what is controlled by the LCD readback, is it a toy or a heartmonitor to name some extremes...

My concern is not about the validity of the data read back from the LCD. I previously expressed my concerns in reply #15 of this thread 16x1 LCD BUG - #16 by floresta - Displays - Arduino Forum which I will repost here.

Dealing with these LCDs is really very interesting.  Like so many other things they are really quite straightforward once you understand them but they seem really complex when you don't.  What makes them more challenging is that in some respects they require you to meticulously follow the data sheet and in other respects they are quite tolerant of deviations. 

What really messes people up is that the various clones of the original Hitachi design seem to be tolerant of different deviations.  So experimenter 'A' comes up with some not exactly correct code that works with his LCD and passes on this 'working' code.  Experimenter 'B', with a different brand LCD, tries it and when it doesn't work for him he comes up with another version of not exactly correct code that works with his LCD and passes that code on.... 

Sticking to the original Hitachi recommendations is the best bet, but those recommendations are sometimes hard to decipher due to translation and/or editorial errors.

Don