Go Down

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

Retroplayer

Well, that's pretty simple isn't it? I will add that in.

I haven't finished the code yet. Well, actually finished it, but having some issues with timing and haven't had time to work on it again since last night.

I see another post like this in the forum, recently. I am really curious what the purpose would really be. I can't think of any use I would have for it. I was thinking maybe to support input by a user, but you have to white the character to be displayed for the input anyway, so you already know what it is.

This is very low priority for me.

bperrybap

Guys,
keep in mind that the LiquidCrystal library that ships with Arduino today is pretty much stateless.
It does not track any LCD state information like cursor position, memory addresses, scroll modes, etc...
i.e. when you set a cursor position using setCursor() it sends a command to the LCD
to set the memory address and that is it.
Yes it does a quick sanity check on the values, but
it does not keep track of the cursor position, nor any subsequent internal address changes
when future writes are done.

Keeping track of the cursor position inside the LCD is not terribly difficult but the code to do that currently
isn't there and isn't as easy as it would first seem.

To track things for line wrapping takes more than just knowing the geometry.
You also have to keep and track state information for things the left-to-right vs right-to-left addressing.
It also conflicts with the auto scroll modes, so that will potentially drag in the need for some other
new API calls to deal with that.

In my view, these libraries should be very small and simple and limited to unique
hardware functionality.
Any other functionality like reading strings or parsing strings should not be done
in a hardware library.
That type of functionality should be handled by an upper layer since that functionality
is not unique to the hardware.



With respect to using ifdefs, issues with the Arduino IDE
build methodology quickly arise. Library files are built separately from the sketch.
So that means that a sketch cannot set defines to control conditional compilation
of the library within the source code of the sketch.
Also the way the IDE works, the IDE does not have a mechanism to set defines for a sketch.
A library can have a separate configuration header file down its source directory which works
for controlling conditional compilation options but
then the defines, and hence conditional compilation, is global since
it will set the conditional values for all sketches.

--- bill

Retroplayer

I was aware of all those things up to the conditional compiling part. I did not know that. That sucks.

But, yeah, I knew that there would have to be other methods for reading the address counter to get the position, etc.. If the user wants to translate that into row and column, that would have to be left up to him. The easiest way to do this independent of the geometry is to just treat it like 0x00 to 0x80 memory addresses.

I'm certainly not planning to spend a great deal of time on it when I really don't see much of a purpose to it anyway. If someone wants to chime in (the OP perhaps) with a great reason to have this capability, I might move it up on my list of priorities. I just cannot think of a single use I would have for this.

pdorcas

A full implementation of the HD44780 is not necessary for 99.9% of the users.  Reading the LCD would only be necessary for those who want to copy the display to another device (PC, for example) or who need to test the LCD programatically in a production environment. 

rabu

Hello Retroplayer,

do you have finished your code? If so, please publish it here, or mail it to me. I am looking for such a code for my "Textsystem" to write, edit, read text strings to/from a 2 x 16 or 2 x 20 or 4 x 16 or 4 x 20 LCD, and store the text, in case of error edited text, in arduinos- or external eeprom. I create and edit the text strings with a german ps/2 keyboard.

PS/2 keyboard functionality of writing  and editing text, including cursor control for the LCD, are ok so far. Because all displayed charcters are stored within the lcd, the easiest way to store the displayed text in external eeprom ist to read the text from the lcd RAM, and move it to the eeprom. So your code would help me very much.

Thanks.

Go Up