Go Down

Topic: How to read HD44780 LCD programmatically (Read 4 times) previous topic - next topic

Retroplayer

Reading from the LCD is pretty much the same as writing to it. When you write to it, you are simply putting a byte into the DDRAM. So, you just read it instead... You do need control of the R/W line, though.

So you set the RS pin high, the R/W line high, then toggle the E line. Each time you toggle the E line, it will increment (or decrement depending on how you set it up) and give you the byte in the next address.

So the only difference is that you are setting the read/write line high instead of low and listening on the data lines instead of writing something to it. Modifying a library wouldn't be much more than copying the functions and changing them to set the read write line and return a byte ( or array of bytes) instead of sending one.

pdorcas

That sounds easy enough.  Thank you!  I'll look at the LiquidCrystal library, and make the recommended changes.  Thank you very much for your help!

Retroplayer

You got me looking at it, actually. There actually already is support for a RW pin if you define one. I've made several little changes already to support reading. If I were to modify the library, what functions would be useful? I would think a read function where you give it an address and length would be useful. What else?

floresta

#13
Mar 07, 2013, 10:08 pm Last Edit: Mar 07, 2013, 10:10 pm by floresta Reason: 1
Quote
So you set the RS pin high, the R/W line high, then toggle the E line. Each time you toggle the E line, it will increment (or decrement depending on how you set it up) and give you the byte in the next address.

It's not quite that simple in the 4-bit mode since you have to read twice for each byte and reassemble the nibbles.  Also, don't forget that you do the actual reading while E is high, not after it goes low.

Quote
You got me looking at it, actually. There actually already is support for a RW pin if you define one.

Look again.  If you define the pin then all they do is drive it low...PERIOD.

I am not trying to discourage you, I am just pointing out some of the problems.  John went through all of this when he was writing the LiquidCrystal440 library a few years ago and I provided him with some code for starters.  All he was doing is reading the busy flag, but the added work to get the other seven bits should be trivial*.  Why don't you see if you can find anything here --> http://code.google.com/p/liquidcrystal440/ (follow the Downloads link to get to the latest version) before you try to reinvent the wheel.

Don

Edit: * Famous last words....

robtillaart

Quote
I would think a read function where you give it an address and length would be useful. What else?


primary functions would be

char lcd.readChar(row, col)        // reads 1 char
char * lcd.readStr(row, col, len)   // reads len chars - should it wrap around end of line?

some ideas:

char lcd.readChar(); // reads form last known (internal) row/col  e.g. gotoxy(r,c); x = lcd.readchar()

char lcd.readNext(); // reads a char and moves to next position?

maybe some function to read self made chars / font back into an array?

readback backlight status?
bool lcd.getBackLight()
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up