Pages: 1 [2]   Go Down
Author Topic: How to fix all LCD problems - read this!  (Read 4645 times)
0 Members and 1 Guest are viewing this topic.
Western New York, USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 4384
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now I am really pissed off (not at you Bill).  I had a carefully thought out reply to the println topic completed, along with another possible topic, and the whole thing was lost with some sort of error with the forum server when I tried to post it.  I'll have to remember to save everything to a text file before I try to submit it in the future.

Don
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2735
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ironically, the exact same thing happened to me.
Normally, what I do is highlight all the text then do a right click copy to save it away just in case,
but my mouse went psycho on me and the web page went back in history rather than
copying the text, which means the text was lost.
I feel for you. Nothing is more frustrating to me than losing a response.

(Maybe the universe is trying to tell us something.... I'm just too dense to understand it)

--- bill
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 4384
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's my reconstructed reply.

I thought we totally agreed but I guess we don't.

I still maintain that there is no lcd.println() function.  The fact that you can include such an undocumented function in a sketch and not trigger an error message is due to the interaction between the various libraries.  The compiler does the best that it can with the information that it has, but the net result is not a 'new line'.  What you wind up with is the classic case of an undocumented function resulting in an undesired result.

I'm not sure how 'scrolling' got into the discussion but this does bring up another topic that we might want to address.  Your use of the term 'scroll', my interpretation of the term 'scroll', and the use of the term 'scroll lock' on most keyboards all refer to the vertical movement of characters on a display. 

The LiquidCrystal documentation, however, uses the term with respect to horizontal movement of the characters on the display which probably confuses at least some people.  I prefer to use the term 'shift' which coincidently is how the action is described in all of the LCD controller datasheets.

Even the 24 hour TV news people, the ones who manage to reduce our wide screen TV displays to the size of a 1950's 7" set, call this movement a 'crawl' rather than a 'scroll'.


Don
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2735
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's my reconstructed reply.

I still maintain that there is no lcd.println() function.  The fact that you can include such an undocumented function in a sketch and not trigger an error message is due to the interaction between the various libraries.  The compiler does the best that it can with the information that it has, but the net result is not a 'new line'.  What you wind up with is the classic case of an undocumented function resulting in an undesired result.
In reality there is no lcd.print() function either.
Both print() and println() are implemented in the Print class which is inherited by the LiquidCrystal class.
The LiquidCrystal class only implements a write() function that can display a single character which
is what the Print class calls.
The Print class is how things actually get printed on the lcd.

There is no compiler issue here. The compiler is doing exactly what it should and that is
honoring the LiquidCrystal class request to inherit the Print class.

The issue is that the LiquidCrystal class that is supplied with the IDE does not handle
<CR> and <LF> in a way that can allow println() to work as most people would expect.
But this is really a short coming of the LiquidCrystal class not the compiler or the Print class.
It can be made to work as expected and that is what the LiquidCrystalFast library
over on the Teensy site does.
While LiquidCrystalFast currently does not do vertical scrolling, it merely wraps back to the top,
the line wrapping and newline processing is more in line to what some people would expect.

Keep in mind println() is not the only way to send a new line.
A user might also do something like:
lcd.print("line1\nline2");
This would work with LiquidCrystalFast library but would not work with LiquidCrystal
shipped with the IDE because it does not do any newline processing.
Why would somebody do this? Perhaps they are tossing out a banner screen
and want store it in flash.
i..e
lcd.print(F("line1 xxxx\nline2 yyyy"));

It isn't just a println() issue, it is a newline processing issue.

Quote
I'm not sure how 'scrolling' got into the discussion but this does bring up another topic that we might want to address.  Your use of the term 'scroll', my interpretation of the term 'scroll', and the use of the term 'scroll lock' on most keyboards all refer to the vertical movement of characters on a display. 

The LiquidCrystal documentation, however, uses the term with respect to horizontal movement of the characters on the display which probably confuses at least some people.  I prefer to use the term 'shift' which coincidently is how the action is described in all of the LCD controller datasheets.

Even the 24 hour TV news people, the ones who manage to reduce our wide screen TV displays to the size of a 1950's 7" set, call this movement a 'crawl' rather than a 'scroll'.[/color]

I'm totally with you on the term "scroll".
It is very unfortunate the the LiquidCrystal library use the term "scroll" instead of "shift"
in the api.
The reason I brought up scrolling is that vertical scrolling often goes hand in hand with newline processing.
i.e. people often expect a display to scroll vertically when a new line is sent on the bottom line.

But this does probably indicate a need to add an item in the SW list to perhaps remind
people that autoscroll() does not turn on newline processing and vertical scrolling.

--- bill
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 4384
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
In reality there is no lcd.print() function either.

That function is real enough for the Arduino IDE.  We aren't talking about K&R, we are talking about the Arduino LiquidCrystal library and the functions associated with it.

(source:  http://arduino.cc/en/Reference/LiquidCrystal )
Function
    LiquidCrystal()
    begin()
    clear()
    home()
    setCursor()
    write()
    print()
    cursor()
    noCursor()
    blink()
    noBlink()
    display()
    noDisplay()
    scrollDisplayLeft()
    scrollDisplayRight()
    autoscroll()
    noAutoscroll()
    leftToRight()
    rightToLeft()
    createChar()

These are the documented functions that the LiquidCrystal library uses to control the HD74480U LCD controller and I feel that these are the functions that we should be supporting and explaining with respect to the use of that library.  The print() function most certainly appears in that list and the println() function does not.

Anyone who cannot inherently figure out where the funny characters come from when using lcd.println() probably doesn't know or care about classes and the fact that the print class is how things actually get displayed on the LCD.

It may be true that println() can be made to work as expected with other LCD libraries but the fact remains that at the present time it is not implemented in the LiquidCrystal library.  Therefore it's use in a sketch that incorporates the LiquidCrystal library is incorrect.


Don
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 4384
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It is very unfortunate the the LiquidCrystal library use the term "scroll" instead of "shift" in the api.

What they did when they implemented the begin() function is even more unfortunate.  If you forget to include that function, or if you use a sketch written for an older version of LiquidCrystal that didn't have such a function, the implementation is for a 'one line' display. 

The problem is that there are almost no true one line displays around.  Even most displays that have one row of sixteen characters and look like a 16x1 are internally set up as 8x2.  This means that the default configuration will work correctly with only some very rare displays while the commonly used ones will have poor contrast on the first row and no display on the other(s).

So, in my opinion, the default should be 16x2 since that setup will work correctly for almost all displays.  With 16x2 as default only the true 16x1s will be messed up and the 16x4s will look ok but they will have their third and fourth rows offset by 4 spaces - but the 16x4s do that anyway with the current library even if you invoke them as 16x4 in begin().


Don
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2735
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anyone who cannot inherently figure out where the funny characters come from when using lcd.println() probably doesn't know or care about classes and the fact that the print class is how things actually get displayed on the LCD.

It may be true that println() can be made to work as expected with other LCD libraries but the fact remains that at the present time it is not implemented in the LiquidCrystal library.  Therefore it's use in a sketch that incorporates the LiquidCrystal library is incorrect.

Don
I totally agree with the first part of this and about avoiding using println() when using
the LiquidCrystal library shipped with the IDE.

All I've been saying is that neither print() nor println() is implemented in the LiquidCrystal library
(print() and println() both exist and are both implemented in Print not LiquidCrystal)
and any issues in their support with respect to newline handling is in LiquidCrystal and not elsewhere.
This isn't just a println() issue. It goes beyond that. The LiquidCrystal library that
ships with the IDE does not have newline support.
This means that newlines in strings also won't work
even if print() is used which IS part of the documented API for LiquidCrystal.

While println() is not in the list of documented LiquidCrystal API functions
saying there is no println() or that println() is not implemented is factually incorrect.
It would more appropriate to say it isn't supported.

So I believe that with respect to this thread, the SW note to users should say something like
The current LiquidCrystal library that ships with the IDE
does not have newline support so println() should not be used and newlines should not
be used in strings sent to print().

This covers both attempting to use println() and newlines in strings to print().

---bill
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 4384
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
saying there is no println() or that println() is not implemented is factually incorrect.
I don't think I ever said that or at least I never meant to say that.  I keep on emphasizing that it is lcd.println() that is not supported.  Take another look at reply #17.

I think we finally agree.


Don
« Last Edit: April 23, 2012, 08:20:43 am by floresta » Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2735
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
saying there is no println() or that println() is not implemented is factually incorrect.
I don't think I ever said that or at least I never meant to say that.  I keep on emphasizing that it is lcd.println() that is not supported.  Take another look at reply #17.

I think we finally agree.


Don
I think we may have mostly always agreed.

I believe that you probably always meant "not supported" but you kept typing
"there is no" or "not implemented" even in responses #17 and #19.
The words "not supported" is never mentioned in any of your posts (other than #22)
but I kept using those words over and over again.
So it kept jumping out at me.

It is the specific language that was (and still a little bit)  bothering me.
There were some factual inaccuracies in references to "implemented", "supported", "exist",
that were bothering me.


In post #1:
Quote
S-2) Tried to use lcd.println. There is no such function so you will see two strange characters with your text

To which my original response in # 14 was:
Quote
S-2 is already there, but I'd change the language from:
"There is no such function" which is incorrect to
"It is not supported by most of the lcd libraries including the LiquidCrystal library that ships with the IDE".

but then in #17
I still maintain that there is no lcd.println() function. 

But there is a lcd.println() function. While there is no println() in the current LiquidCrystal API documentation
on the Arduino web site, which implies that it isnt' supported, it still does exist.
Currently if a person does call it, it does not work as would be expected.

And then in #19:

It may be true that println() can be made to work as expected with other LCD libraries but the fact remains that at the present time it is not implemented in the LiquidCrystal library.  Therefore it's use in a sketch that incorporates the LiquidCrystal library is incorrect.[/color]



This is where things get a bit tricky since technically neither print() nor println() are implemented
in LiquidCrystal since they are both implemented in Print.
But it is "implemented" since Print is inherited by LiquidCrystal.
I assume you really meant "not supported" rather than "implemented".



Things seemed to have gone south after my response in #14, not sure why.
It seemed quite simple to modify the language of "There is no such function" to "It is not supported".
Maybe it was latter part of that #14 post that referenced scrolling. I mentioned that because it
came up in another thread, where the user was using println() and was expecting that
the output would wrap and would scroll up and ended up getting 2 funky characters instead.

In #21 What I was trying to say was the print() and println() *always* do exist and are implemented
but they are both implemented in Print which LiquidCrystal uses so both will exist in LiquidCrystal
and that since the current LiquidCrystal code shipping with the IDE does not handle newlines,
not only is println() not supported but any use of newlines embedded in strings sent to print() will
not work either.

So it is beyond println() not working with LiquidCrystal, it is any use of newlines
that won't work with the LiquidCrystal that currently ships with the IDE.
This includes both println() and newlines embedded in strings sent to print().


--- bill
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 209
Posts: 13022
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


@liudr: Please add more whitespace...

1) Instead of having numbered lists
2) Close together like this which
3) Can be difficult to read

...

1) Add a blank line after each item

2) To make it easier to read and

3) Easier to find your place as your

4) Focus moves from the screen to

5) Your Arduino
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 4384
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

We need another entry between 3 and 4.  I'm not sure how to phrase this but here is a start:

When your LCD does not display the information that you think it should be displaying then tell us (a) what you were trying to display, (b) what actually was displayed, and (c) if the same incorrect information shows up in the same place every time or if the incorrect information is different each time.


Don
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 4384
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have another addition:

If you take the time to put your location information into your profile you may have a better chance of getting appropriate replies.


Don
Logged

Pages: 1 [2]   Go Up
Jump to: