how to delete line on lcd ? plz
As far as I know, there are only two ways.
- Use can clear the entire display: "Lcd.clear();
2
lcd.setcursor(0,0);
lcd.print(" ");
Those are only two ways I know. There could 10 other ways to do for all I know , or none.
Those are only two ways I know. There could 10 other ways to do for all I know , or none.
That about covers it except that it is a good idea to stay away from Lcd.clear();, expecially in loop(), making the second option the better one.
Don
I do not agree that : lcd.print(" "); is a good idea.
For simple and short programs it is a option... but it consumes a lot of free programming space.
yours,
Frans.
Is that all you can come up with in the four years since this was brought up?
Why don't you offer an alternative if this method is so bad?
If you are concerned about programming space there is an alternative, use of the 'F()' macro, but as far as the LCD is concerned the answer is the same.
Don
I was looking up this exact thing on Google and it brought me here.
On a 20x4 LCD screen, my gut told me 'lcd.clear (0,20)' would work but also, not cigar.
Have their been any updates on the matter, or is still a no go?
Arduphile:
Have their been any updates on the matter, or is still a no go?
Why would you expect an update - the hardware has not changed!
The problem is that lcd.clear() is very slow, and if inadvertently called repeatedly in loop() causes flicker which prevents proper display of the wanted information as it has no time to be perceived before the next clear.
Of course, this is only an indicator of ineptly clumsy programming. The base rules are:
- Only update the display if something changes.
- Only update the part of the display which has changed.
- Do not update any more than five times per second.
It is the second of these rules which most frequently precludes using lcd.clear() even if the others are followed.
Paul__B:
The problem is that lcd.clear() is very slow, ...
It takes the same time for the hardware to implement lcd.clear() for a 16x2 or a 20x4 screen. i.e. about 2ms whether by parallel or backpack. It also resets the cursor to 0, 0.
Yes, you can draw spaces individually. It will take much LONGER than 2ms to erase the whole screen.
From a cosmetic point of view. Speed does not matter. Overwriting the old text with your new message will look nicer. If the new message is smaller print enough spaces to rub out any letters that are left from the old message. e.g. when you replace "10" with "9"
Always use intelligence. There is no point in re-printing the same thing. Only print when something changes.
David.
I was looking for a solution for the same issue. I was using tft.
tft.clear() or tft.fillscreen() was slow and tft.println(" ") did not clear the previous txt.
I used tft.fillRect(x,y,dx,dy,bgColor) and the refresh was much better.
You do realise the previous discussion was regarding character displays and you are referring to graphics, do you not?
The concept of printing text is entirely different for these.
My simple solution:
// ----- you could call function from any void. Loop just as the example.
void loop(){
//your code to do something
...
clearLCDLine(2) // - integer in parentheses indicates line number (0, 1, 2, 4)
lcd.print("My string");
}
void clearLCDLine(int line){
for(int n = 0; n < 20; n++) { // 20 indicates symbols in line. For 2x16 LCD write - 16
lcd.setCursor(n,line);
lcd.print(" ");
}
lcd.setCursor(0,line); // set cursor in the beginning of deleted line
}
clearLCDLine() would clear the line twice as fast if you only did the setCursor() only once.
i.e.
void clearLCDLine(int line)
{
lcd.setCursor(0,line);
for(int n = 0; n < 20; n++) // 20 indicates symbols in line. For 2x16 LCD write - 16
{
lcd.print(" ");
}
}
--- bill
I hope, you got a solution to your problem by now.