LiquidCrystal replace delayMicroseconds fails

I have tried to replace the delayMicroseconds calls in the clear and home methods with the following code:

unsigned long current, waitUntil = millis() + 2L;
do
{
    current = millis();
} while(current < waitUntil ) ;

But, it appears that the code never returns from the call to clear (I don’t use the home method).

Can anyone help?

-lilbuzz

You could do:

unsigned long start = millis();
while (millis() - start <= 2L)
   ;

But why not just:

delay(2);

When I try delay(2); I get the same behavior - the code does not return from the call to the clear() method.

-lilbuzz

I think I figured out what was happening. The clear method is being called in the constructor, and the interrupt that handles the millisecond updates is not enabled at that time.

So, I copied the old code from within the clear method (including call to delayMicroseconds()) into the constructor, and modified my clear and home methods to use the millisecond delay code above, and all is well. :D

-lilbuzz