@@ -346,8 +346,8 @@ class FourLineDisplayUsermod : public Usermod {
346
346
(knownEffectIntensity != effectIntensity) ||
347
347
(knownMode != strip.getMode ()) ||
348
348
(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
351
351
} else if (sleepMode && !displayTurnedOff && ((now - lastRedraw)/1000 )%5 == 0 ) {
352
352
// change line every 5s
353
353
showName = !showName;
@@ -372,23 +372,20 @@ class FourLineDisplayUsermod : public Usermod {
372
372
break ;
373
373
}
374
374
knownHour = 99 ; // force time update
375
+ // do not update lastRedraw marker if just switching row contenet
375
376
} else {
376
377
// Nothing to change.
377
378
// Turn off display after 3 minutes with no change.
378
379
if (sleepMode && !displayTurnedOff && (millis () - lastRedraw > screenTimeout)) {
379
380
// We will still check if there is a change in redraw()
380
381
// and turn it back on if it changed.
381
- clear (); // force screen clear
382
382
sleepOrClock (true );
383
383
} else if (displayTurnedOff && clockMode) {
384
384
showTime ();
385
385
}
386
386
return ;
387
387
}
388
388
389
- // do not update lastRedraw marker if just switching row contenet
390
- if (((now - lastRedraw)/1000 )%5 != 0 ) lastRedraw = now;
391
-
392
389
// Turn the display back on
393
390
if (displayTurnedOff) sleepOrClock (false );
394
391
@@ -409,7 +406,7 @@ class FourLineDisplayUsermod : public Usermod {
409
406
center (line, getCols ()-2 );
410
407
drawString (1 , 0 , line.c_str ());
411
408
// Print `~` char to indicate that SSID is longer, than our display
412
- if (knownSsid.length () > getCols ()-1 ) {
409
+ if (knownSsid.length () > ( int ) getCols ()-1 ) {
413
410
drawString (getCols () - 1 , 0 , " ~" );
414
411
}
415
412
@@ -523,14 +520,23 @@ class FourLineDisplayUsermod : public Usermod {
523
520
*/
524
521
void overlay (const char * line1, const char *line2, long showHowLong) {
525
522
if (displayTurnedOff) {
526
- // Turn the display back on
523
+ // Turn the display back on (includes clear())
527
524
sleepOrClock (false );
525
+ } else {
526
+ clear ();
528
527
}
529
528
530
529
// 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
+ }
534
540
overlayUntil = millis () + showHowLong;
535
541
}
536
542
@@ -557,6 +563,7 @@ class FourLineDisplayUsermod : public Usermod {
557
563
* Enable sleep (turn the display off) or clock mode.
558
564
*/
559
565
void sleepOrClock (bool enabled) {
566
+ clear ();
560
567
if (enabled) {
561
568
if (clockMode) showTime ();
562
569
else setPowerSave (1 );
@@ -582,8 +589,6 @@ class FourLineDisplayUsermod : public Usermod {
582
589
if (knownMinute == minuteCurrent && knownHour == hourCurrent) {
583
590
// Time hasn't changed.
584
591
if (!fullScreen) return ;
585
- } else {
586
- // if (fullScreen) clear();
587
592
}
588
593
knownMinute = minuteCurrent;
589
594
knownHour = hourCurrent;
0 commit comments