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;
    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?


You could do:

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

But why not just:


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


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