@@ -346,8 +346,8 @@ class FourLineDisplayUsermod : public Usermod {
346346 (knownEffectIntensity != effectIntensity) ||
347347 (knownMode != strip.getMode ()) ||
348348 (knownPalette != strip.getSegment (0 ).palette )) {
349- knownHour = 99 ; // force time update
350- clear ();
349+ knownHour = 99 ; // force time update
350+ lastRedraw = now; // update lastRedraw marker
351351 } else if (sleepMode && !displayTurnedOff && ((now - lastRedraw)/1000 )%5 == 0 ) {
352352 // change line every 5s
353353 showName = !showName;
@@ -372,23 +372,20 @@ class FourLineDisplayUsermod : public Usermod {
372372 break ;
373373 }
374374 knownHour = 99 ; // force time update
375+ // do not update lastRedraw marker if just switching row contenet
375376 } else {
376377 // Nothing to change.
377378 // Turn off display after 3 minutes with no change.
378379 if (sleepMode && !displayTurnedOff && (millis () - lastRedraw > screenTimeout)) {
379380 // We will still check if there is a change in redraw()
380381 // and turn it back on if it changed.
381- clear (); // force screen clear
382382 sleepOrClock (true );
383383 } else if (displayTurnedOff && clockMode) {
384384 showTime ();
385385 }
386386 return ;
387387 }
388388
389- // do not update lastRedraw marker if just switching row contenet
390- if (((now - lastRedraw)/1000 )%5 != 0 ) lastRedraw = now;
391-
392389 // Turn the display back on
393390 if (displayTurnedOff) sleepOrClock (false );
394391
@@ -409,7 +406,7 @@ class FourLineDisplayUsermod : public Usermod {
409406 center (line, getCols ()-2 );
410407 drawString (1 , 0 , line.c_str ());
411408 // Print `~` char to indicate that SSID is longer, than our display
412- if (knownSsid.length () > getCols ()-1 ) {
409+ if (knownSsid.length () > ( int ) getCols ()-1 ) {
413410 drawString (getCols () - 1 , 0 , " ~" );
414411 }
415412
@@ -523,14 +520,23 @@ class FourLineDisplayUsermod : public Usermod {
523520 */
524521 void overlay (const char * line1, const char *line2, long showHowLong) {
525522 if (displayTurnedOff) {
526- // Turn the display back on
523+ // Turn the display back on (includes clear())
527524 sleepOrClock (false );
525+ } else {
526+ clear ();
528527 }
529528
530529 // Print the overlay
531- clear ();
532- if (line1) drawString (0 , 1 *lineHeight, line1);
533- if (line2) drawString (0 , 2 *lineHeight, line2);
530+ if (line1) {
531+ String buf = line1;
532+ center (buf, getCols ());
533+ drawString (0 , 1 *lineHeight, buf.c_str ());
534+ }
535+ if (line2) {
536+ String buf = line2;
537+ center (buf, getCols ());
538+ drawString (0 , 2 *lineHeight, buf.c_str ());
539+ }
534540 overlayUntil = millis () + showHowLong;
535541 }
536542
@@ -557,6 +563,7 @@ class FourLineDisplayUsermod : public Usermod {
557563 * Enable sleep (turn the display off) or clock mode.
558564 */
559565 void sleepOrClock (bool enabled) {
566+ clear ();
560567 if (enabled) {
561568 if (clockMode) showTime ();
562569 else setPowerSave (1 );
@@ -582,8 +589,6 @@ class FourLineDisplayUsermod : public Usermod {
582589 if (knownMinute == minuteCurrent && knownHour == hourCurrent) {
583590 // Time hasn't changed.
584591 if (!fullScreen) return ;
585- } else {
586- // if (fullScreen) clear();
587592 }
588593 knownMinute = minuteCurrent;
589594 knownHour = hourCurrent;
0 commit comments