Przeglądaj źródła

✨ STATUS_MESSAGE_TIMEOUT_SEC (#23135)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Robby Candra 2 lat temu
rodzic
commit
b7ffcd6941
No account linked to committer's email address

+ 3
- 0
Marlin/Configuration_adv.h Wyświetl plik

@@ -1352,6 +1352,9 @@
1352 1352
   // Scroll a longer status message into view
1353 1353
   //#define STATUS_MESSAGE_SCROLLING
1354 1354
 
1355
+  // Apply a timeout to low-priority status messages
1356
+  //#define STATUS_MESSAGE_TIMEOUT_SEC 30 // (seconds)
1357
+
1355 1358
   // On the Info Screen, display XY with one decimal place when possible
1356 1359
   //#define LCD_DECIMAL_SMALL_XY
1357 1360
 

+ 4
- 0
Marlin/src/inc/Conditionals_adv.h Wyświetl plik

@@ -587,6 +587,10 @@
587 587
   #define HAS_PRINT_PROGRESS 1
588 588
 #endif
589 589
 
590
+#if STATUS_MESSAGE_TIMEOUT_SEC > 0
591
+  #define HAS_STATUS_MESSAGE_TIMEOUT 1
592
+#endif
593
+
590 594
 #if ENABLED(SDSUPPORT) && SD_PROCEDURE_DEPTH
591 595
   #define HAS_MEDIA_SUBCALLS 1
592 596
 #endif

+ 4
- 0
Marlin/src/inc/Warnings.cpp Wyświetl plik

@@ -574,6 +574,10 @@
574 574
   #warning "Contrast cannot be changed when LCD_CONTRAST_MIN >= LCD_CONTRAST_MAX."
575 575
 #endif
576 576
 
577
+#if PROGRESS_MSG_EXPIRE > 0 && HAS_STATUS_MESSAGE_TIMEOUT
578
+  #warning "It is recommended not to combine PROGRESS_MSG_EXPIRE with STATUS_MESSAGE_TIMEOUT_SEC."
579
+#endif
580
+
577 581
 /**
578 582
  * FYSETC backlighting
579 583
  */

+ 16
- 2
Marlin/src/lcd/marlinui.cpp Wyświetl plik

@@ -73,6 +73,9 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
73 73
   #endif
74 74
   char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1];
75 75
   uint8_t MarlinUI::alert_level; // = 0
76
+  #if HAS_STATUS_MESSAGE_TIMEOUT
77
+    millis_t MarlinUI::status_message_expire_ms; // = 0
78
+  #endif
76 79
   statusResetFunc_t MarlinUI::status_reset_callback; // = nullptr
77 80
 #endif
78 81
 
@@ -628,8 +631,17 @@ void MarlinUI::init() {
628 631
 
629 632
     #endif // BASIC_PROGRESS_BAR
630 633
 
631
-    if (status_reset_callback && (*status_reset_callback)())
632
-      reset_status();
634
+    bool did_expire = status_reset_callback && (*status_reset_callback)();
635
+
636
+    #if HAS_STATUS_MESSAGE_TIMEOUT
637
+      #ifndef GOT_MS
638
+        #define GOT_MS
639
+        const millis_t ms = millis();
640
+      #endif
641
+      did_expire |= status_message_expire_ms && ELAPSED(ms, status_message_expire_ms);
642
+    #endif
643
+
644
+    if (did_expire) reset_status();
633 645
 
634 646
     #if HAS_MARLINUI_MENU
635 647
       if (use_click()) {
@@ -1521,6 +1533,8 @@ void MarlinUI::init() {
1521 1533
 
1522 1534
     set_status_reset_fn();
1523 1535
 
1536
+    TERN_(HAS_STATUS_MESSAGE_TIMEOUT, status_message_expire_ms = persist ? 0 : millis() + (STATUS_MESSAGE_TIMEOUT_SEC) * 1000UL);
1537
+
1524 1538
     #if HAS_WIRED_LCD
1525 1539
 
1526 1540
       #if BASIC_PROGRESS_BAR || BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)

+ 4
- 0
Marlin/src/lcd/marlinui.h Wyświetl plik

@@ -344,6 +344,10 @@ public:
344 344
     static char status_message[];
345 345
     static uint8_t alert_level; // Higher levels block lower levels
346 346
 
347
+    #if HAS_STATUS_MESSAGE_TIMEOUT
348
+      static millis_t status_message_expire_ms; // Reset some status messages after a timeout
349
+    #endif
350
+
347 351
     #if ENABLED(STATUS_MESSAGE_SCROLLING)
348 352
       static uint8_t status_scroll_offset;
349 353
       static void advance_status_scroll();

Ładowanie…
Anuluj
Zapisz