Pages: [1]   Go Down
Author Topic: LiquidCrystal library documentation  (Read 582 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
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.
« Last Edit: February 04, 2012, 06:20:00 am by keithb1 » Logged

Keith

Offline Offline
Full Member
***
Karma: 0
Posts: 167
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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).
« Last Edit: February 05, 2012, 08:34:33 am by keithb1 » Logged

Keith

Offline Offline
Newbie
*
Karma: 1
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 (0.91 KB - downloaded 7 times.)
Logged

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Keith

Pages: [1]   Go Up
Jump to: