Go Down

Topic: LCD Library (Read 3 times) previous topic - next topic

crimony

It looks like the original LCD library author misread the Serial Library's "println()" (print line) method as "printIn" (print in), and duplicated it (erroneously) in the LCD lib for consistency. The method name is repeated in the LCD4Bit library too, with the following acknowleged by the author (neillzero) in LCD4Bit.cpp:

Code: [Select]
//print the given string to the LCD at the current cursor position.  overwrites, doesn't insert.
//While I don't understand why this was named printIn (PRINT IN?) in the original LiquidCrystal library,
//I've preserved it here to maintain the interchangeability of the two libraries.
void LCD4Bit::printIn(char msg[]) {


IMHO it should be updated, as it is neither intuitive nor consistent in its current state.

Is there too much momentum to change it now?

mem

#1
Apr 23, 2008, 10:06 am Last Edit: Apr 23, 2008, 10:06 am by mem Reason: 1
I share your view that it should be changed.

Why not add  [font=Courier]void LCD4Bit::println(char *msg)[/font]  as a new method but keep the old one so it will still work with legacy sketches. The example sketches should be changed to use the new method and this would produce errors if used with old libraries but that is a worthwhile price to pay for a more consistent and intuitive interface for new people to the LCD libraries.

If the old method was still supported and the change was clearly documented in the code and wiki then I don't think it would be a great inconvenience to existing users.

Oracle

Quote
If the old method was still supported and the change was clearly documented in the code and wiki then I don't think it would be a great inconvenience to existing users.


Is there a way to delcare library functions as depricated?  So for now printIn will raise a comple-time warning to change your code.  Then 1-2 years from now, take it out completely and let is raise an error.

gradbert

I agree too that it should be changed, but not to println().  the Serial.println() function sends a line break after the text, so that the next thing sent will show up on the next line.  This is not the way the LCD.printIn() function works.  It leaves the cursor on the same line.  It works the same way as Serial.print().  So lets change it instead to LCD.print()

mem

Hi gradbert, I was thinking that both could be supported.

print would display text from the current cursor and leave the cursor one character beyond the end of that text, as per yr suggestion.

println would display text from the current cursor and leave the cursor at the start of the next line.

Go Up