LiquidCrystal library documentation

I have been trying to write some scrolling code to give a continuously repeating message. It appears that the scroll library functions maintain some internal buffer that is larger than the display size (40 characters I think) but this is not mentioned in the documentation. Also, when you use:

lcd.scrollDisplayLeft();
lcd.setCursor(15,0);

you don't get the character in the upper right slot. So I assume there is some interaction between the scroll functions and the cursor numbering.

The code doesn't do anything itself. As far as I can tell the scroll works by offsetting the memory address used by the display. Since the setCursor function points to a memory location then when you scroll, the memory location will alter. So the "coordinates" of the upper right slot will depend on any scrolling that has taken place. It should be possible to alter the library so that setCursor is mapped onto the characters being displayed.

Oh, and I have it working without the scroll functions based on a ring buffer.

The buffer is in the LCD controller, the library does nothing but relay your commands and parameters to the controller. If you want to write to a fixed location on screen after scrolling the display from Home then you need to either track how much it's scrolled and offset your cursor, or just maintain your own buffers and scrolling code and overwrite the entire display every refresh.

The buffer is in the LCD controller, the library does nothing but relay your commands and parameters to the controller. If you want to write to a fixed location on screen after scrolling the display from Home then you need to either track how much it's scrolled and offset your cursor, or just maintain your own buffers and scrolling code and overwrite the entire display every refresh.

Yes, that is what I meant by having it working with a ring buffer. I rewrite the display on each refresh and use an index to track the start point of the text.

My point is that the documentation does not mention this. In fact, the documentation/examples give the impression that (15,0) is always the upper right character slot. As you say, that changes once you scroll. It would be nice if this was discussed. Once I get it working using the scroll function I'll try and make write something to go in the reference section (assuming no-one else does it first).

I agree its unclear. I also came away with a wrong impression from going through the source in LiquidCrystal.cpp (without having looked at the API documentation online).

The home() method is also badly described in the online API documentation. It just says it positions the cursor in the upper left corner of the LCD, which it does, but it doesn't mention that it also clears any scrolling that is in effect. The description in the source is incomplete in the same way.

I'm attaching a patch again st LiquidCrystal.cpp, hopefully original poster will fix online API documentation.

comment_fixes_for_home_and_setCursor (934 Bytes)

I now have a version working using the scroll function. Every time you scroll left you have to increment the value of the leftmost cursor position by 1. There is a 40 character memory for each line and obviously the cursor position wraps back to 0 after it reaches the value 39.

I'll work on some updates for the documentation, not sure how to actually get it changed though...I tried clicking on the edit page link but my login does not work there.