Thanks for this tip!
What is the name of the library used? there are several libs...
Which display did have this problem? type ?
I expect that the delay in clear() depends on the size of the display
Probably it is a start time + a fixed time per char
Assuming the start time is zero the time per char is about 30 µSec.
In code that might become something like :
void LiquidCrystal::clear()
{
command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero
delayMicroseconds( 100 + _numLines * _numColums * 30); // this command takes a long time!
}
Worth investigating if there is a relation between size and clear() time for different LCD's.
BTW same problems with Home command? it also waits 2000uSec
void LiquidCrystal::home()
{
command(LCD_RETURNHOME); // set cursor position to zero
delayMicroseconds(2000); // this command takes a long time!
}
A less blocking way to solve it is to make the blocking conditional.
The clear function remembers when it was called and becomes non-blocking!
The send function blocks only if it was not long enough ago.
If there is a lot of math/manipulation or sensor reading to be done before writing the blocking time might even be zero!
[code]void LiquidCrystal::clear()
{
command(LCD_CLEARDISPLAY);
lastTime = micros(); // remember
}
....
void LiquidCrystal::send(uint8_t value, uint8_t mode)
{
while (micros() - lastTime < 2500); // blocks for the remainder of the time (and yes the 2500 could be a function of the size of the display)
digitalWrite(_rs_pin, mode);
// if there is a RW pin indicated, set it low to Write
if (_rw_pin != 255) {
digitalWrite(_rw_pin, LOW);
}
if (_displayfunction & LCD_8BITMODE) {
write8bits(value);
} else {
write4bits(value>>4);
write4bits(value);
}
}
Note tested the above, just thinking out loud!
[/code]