Bladeren bron

Allow Status Message without LCD (#20246)

Scott Lahteine 4 jaren geleden
bovenliggende
commit
6f272e13c5
No account linked to committer's email address
4 gewijzigde bestanden met toevoegingen van 143 en 123 verwijderingen
  1. 1
    1
      Marlin/src/gcode/temp/M303.cpp
  2. 4
    0
      Marlin/src/inc/Conditionals_LCD.h
  3. 114
    99
      Marlin/src/lcd/marlinui.cpp
  4. 24
    23
      Marlin/src/lcd/marlinui.h

+ 1
- 1
Marlin/src/gcode/temp/M303.cpp Bestand weergeven

77
     KEEPALIVE_STATE(NOT_BUSY);
77
     KEEPALIVE_STATE(NOT_BUSY);
78
   #endif
78
   #endif
79
 
79
 
80
-  ui.set_status_P(GET_TEXT(MSG_PID_AUTOTUNE));
80
+  LCD_MESSAGEPGM(MSG_PID_AUTOTUNE);
81
   thermalManager.PID_autotune(temp, e, c, u);
81
   thermalManager.PID_autotune(temp, e, c, u);
82
   ui.reset_status();
82
   ui.reset_status();
83
 }
83
 }

+ 4
- 0
Marlin/src/inc/Conditionals_LCD.h Bestand weergeven

472
   #endif
472
   #endif
473
 #endif
473
 #endif
474
 
474
 
475
+#if EITHER(HAS_DISPLAY, GLOBAL_STATUS_MESSAGE)
476
+  #define HAS_STATUS_MESSAGE 1
477
+#endif
478
+
475
 #if IS_ULTIPANEL && DISABLED(NO_LCD_MENUS)
479
 #if IS_ULTIPANEL && DISABLED(NO_LCD_MENUS)
476
   #define HAS_LCD_MENU 1
480
   #define HAS_LCD_MENU 1
477
 #endif
481
 #endif

+ 114
- 99
Marlin/src/lcd/marlinui.cpp Bestand weergeven

1332
 
1332
 
1333
 #endif // HAS_WIRED_LCD
1333
 #endif // HAS_WIRED_LCD
1334
 
1334
 
1335
-#if HAS_DISPLAY
1336
-
1337
-  #if ENABLED(EXTENSIBLE_UI)
1338
-    #include "extui/ui_api.h"
1339
-  #endif
1335
+#if HAS_STATUS_MESSAGE
1340
 
1336
 
1341
   ////////////////////////////////////////////
1337
   ////////////////////////////////////////////
1342
-  /////////////// Status Line ////////////////
1338
+  ////////////// Status Message //////////////
1343
   ////////////////////////////////////////////
1339
   ////////////////////////////////////////////
1344
 
1340
 
1345
-  #if ENABLED(STATUS_MESSAGE_SCROLLING)
1346
-    void MarlinUI::advance_status_scroll() {
1347
-      // Advance by one UTF8 code-word
1348
-      if (status_scroll_offset < utf8_strlen(status_message))
1349
-        while (!START_OF_UTF8_CHAR(status_message[++status_scroll_offset]));
1350
-      else
1351
-        status_scroll_offset = 0;
1352
-    }
1353
-    char* MarlinUI::status_and_len(uint8_t &len) {
1354
-      char *out = status_message + status_scroll_offset;
1355
-      len = utf8_strlen(out);
1356
-      return out;
1357
-    }
1341
+  #if ENABLED(EXTENSIBLE_UI)
1342
+    #include "extui/ui_api.h"
1358
   #endif
1343
   #endif
1359
 
1344
 
1360
-  void MarlinUI::finish_status(const bool persist) {
1361
-
1362
-    #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE) > 0)
1363
-      UNUSED(persist);
1364
-    #endif
1365
-
1366
-    #if ENABLED(LCD_PROGRESS_BAR) || BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
1367
-      const millis_t ms = millis();
1368
-    #endif
1369
-
1370
-    #if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL
1371
-      progress_bar_ms = ms;
1372
-      #if PROGRESS_MSG_EXPIRE > 0
1373
-        expire_status_ms = persist ? 0 : ms + PROGRESS_MSG_EXPIRE;
1374
-      #endif
1375
-    #endif
1376
-
1377
-    #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
1378
-      next_filament_display = ms + 5000UL; // Show status message for 5s
1379
-    #endif
1380
-
1381
-    #if BOTH(HAS_WIRED_LCD, STATUS_MESSAGE_SCROLLING)
1382
-      status_scroll_offset = 0;
1383
-    #endif
1384
-
1385
-    TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(status_message));
1386
-  }
1387
-
1388
   bool MarlinUI::has_status() { return (status_message[0] != '\0'); }
1345
   bool MarlinUI::has_status() { return (status_message[0] != '\0'); }
1389
 
1346
 
1390
   void MarlinUI::set_status(const char * const message, const bool persist) {
1347
   void MarlinUI::set_status(const char * const message, const bool persist) {
1414
     finish_status(persist);
1371
     finish_status(persist);
1415
   }
1372
   }
1416
 
1373
 
1417
-  #include <stdarg.h>
1374
+  /**
1375
+   * Reset the status message
1376
+   */
1377
+  void MarlinUI::reset_status(const bool no_welcome) {
1378
+    #if SERVICE_INTERVAL_1 > 0
1379
+      static PGMSTR(service1, "> " SERVICE_NAME_1 "!");
1380
+    #endif
1381
+    #if SERVICE_INTERVAL_2 > 0
1382
+      static PGMSTR(service2, "> " SERVICE_NAME_2 "!");
1383
+    #endif
1384
+    #if SERVICE_INTERVAL_3 > 0
1385
+      static PGMSTR(service3, "> " SERVICE_NAME_3 "!");
1386
+    #endif
1387
+    PGM_P msg;
1388
+    if (printingIsPaused())
1389
+      msg = GET_TEXT(MSG_PRINT_PAUSED);
1390
+    #if ENABLED(SDSUPPORT)
1391
+      else if (IS_SD_PRINTING())
1392
+        return set_status(card.longest_filename(), true);
1393
+    #endif
1394
+    else if (print_job_timer.isRunning())
1395
+      msg = GET_TEXT(MSG_PRINTING);
1418
 
1396
 
1419
-  void MarlinUI::status_printf_P(const uint8_t level, PGM_P const fmt, ...) {
1420
-    if (level < alert_level) return;
1421
-    alert_level = level;
1422
-    va_list args;
1423
-    va_start(args, fmt);
1424
-    vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, fmt, args);
1425
-    va_end(args);
1426
-    finish_status(level > 0);
1397
+    #if SERVICE_INTERVAL_1 > 0
1398
+      else if (print_job_timer.needsService(1)) msg = service1;
1399
+    #endif
1400
+    #if SERVICE_INTERVAL_2 > 0
1401
+      else if (print_job_timer.needsService(2)) msg = service2;
1402
+    #endif
1403
+    #if SERVICE_INTERVAL_3 > 0
1404
+      else if (print_job_timer.needsService(3)) msg = service3;
1405
+    #endif
1406
+
1407
+    else if (!no_welcome)
1408
+      msg = GET_TEXT(WELCOME_MSG);
1409
+    else
1410
+      return;
1411
+
1412
+    set_status_P(msg, -1);
1427
   }
1413
   }
1428
 
1414
 
1429
   void MarlinUI::set_status_P(PGM_P const message, int8_t level) {
1415
   void MarlinUI::set_status_P(PGM_P const message, int8_t level) {
1459
     TERN_(HAS_LCD_MENU, return_to_status());
1445
     TERN_(HAS_LCD_MENU, return_to_status());
1460
   }
1446
   }
1461
 
1447
 
1462
-  PGM_P print_paused = GET_TEXT(MSG_PRINT_PAUSED);
1448
+  #include <stdarg.h>
1463
 
1449
 
1464
-  /**
1465
-   * Reset the status message
1466
-   */
1467
-  void MarlinUI::reset_status(const bool no_welcome) {
1468
-    PGM_P printing = GET_TEXT(MSG_PRINTING);
1469
-    PGM_P welcome  = GET_TEXT(WELCOME_MSG);
1470
-    #if SERVICE_INTERVAL_1 > 0
1471
-      static PGMSTR(service1, "> " SERVICE_NAME_1 "!");
1472
-    #endif
1473
-    #if SERVICE_INTERVAL_2 > 0
1474
-      static PGMSTR(service2, "> " SERVICE_NAME_2 "!");
1475
-    #endif
1476
-    #if SERVICE_INTERVAL_3 > 0
1477
-      static PGMSTR(service3, "> " SERVICE_NAME_3 "!");
1478
-    #endif
1479
-    PGM_P msg;
1480
-    if (printingIsPaused())
1481
-      msg = print_paused;
1482
-    #if ENABLED(SDSUPPORT)
1483
-      else if (IS_SD_PRINTING())
1484
-        return set_status(card.longest_filename(), true);
1485
-    #endif
1486
-    else if (print_job_timer.isRunning())
1487
-      msg = printing;
1450
+  void MarlinUI::status_printf_P(const uint8_t level, PGM_P const fmt, ...) {
1451
+    if (level < alert_level) return;
1452
+    alert_level = level;
1453
+    va_list args;
1454
+    va_start(args, fmt);
1455
+    vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, fmt, args);
1456
+    va_end(args);
1457
+    finish_status(level > 0);
1458
+  }
1488
 
1459
 
1489
-    #if SERVICE_INTERVAL_1 > 0
1490
-      else if (print_job_timer.needsService(1)) msg = service1;
1491
-    #endif
1492
-    #if SERVICE_INTERVAL_2 > 0
1493
-      else if (print_job_timer.needsService(2)) msg = service2;
1494
-    #endif
1495
-    #if SERVICE_INTERVAL_3 > 0
1496
-      else if (print_job_timer.needsService(3)) msg = service3;
1497
-    #endif
1460
+  void MarlinUI::finish_status(const bool persist) {
1498
 
1461
 
1499
-    else if (!no_welcome)
1500
-      msg = welcome;
1501
-    else
1502
-      return;
1462
+    #if HAS_SPI_LCD
1503
 
1463
 
1504
-    set_status_P(msg, -1);
1464
+      #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE) > 0)
1465
+        UNUSED(persist);
1466
+      #endif
1467
+
1468
+      #if ENABLED(LCD_PROGRESS_BAR) || BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
1469
+        const millis_t ms = millis();
1470
+      #endif
1471
+
1472
+      #if ENABLED(LCD_PROGRESS_BAR)
1473
+        progress_bar_ms = ms;
1474
+        #if PROGRESS_MSG_EXPIRE > 0
1475
+          expire_status_ms = persist ? 0 : ms + PROGRESS_MSG_EXPIRE;
1476
+        #endif
1477
+      #endif
1478
+
1479
+      #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
1480
+        next_filament_display = ms + 5000UL; // Show status message for 5s
1481
+      #endif
1482
+
1483
+      #if ENABLED(STATUS_MESSAGE_SCROLLING)
1484
+        status_scroll_offset = 0;
1485
+      #endif
1486
+
1487
+    #endif
1488
+
1489
+    TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(status_message));
1505
   }
1490
   }
1506
 
1491
 
1492
+  #if ENABLED(STATUS_MESSAGE_SCROLLING)
1493
+
1494
+    void MarlinUI::advance_status_scroll() {
1495
+      // Advance by one UTF8 code-word
1496
+      if (status_scroll_offset < utf8_strlen(status_message))
1497
+        while (!START_OF_UTF8_CHAR(status_message[++status_scroll_offset]));
1498
+      else
1499
+        status_scroll_offset = 0;
1500
+    }
1501
+
1502
+    char* MarlinUI::status_and_len(uint8_t &len) {
1503
+      char *out = status_message + status_scroll_offset;
1504
+      len = utf8_strlen(out);
1505
+      return out;
1506
+    }
1507
+
1508
+  #endif
1509
+
1510
+#endif
1511
+
1512
+#if HAS_DISPLAY
1513
+
1514
+  #if ENABLED(SDSUPPORT)
1515
+    extern bool wait_for_user, wait_for_heatup;
1516
+  #endif
1517
+
1507
   void MarlinUI::abort_print() {
1518
   void MarlinUI::abort_print() {
1508
     #if ENABLED(SDSUPPORT)
1519
     #if ENABLED(SDSUPPORT)
1509
       wait_for_heatup = wait_for_user = false;
1520
       wait_for_heatup = wait_for_user = false;
1514
     #endif
1525
     #endif
1515
     TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("UI Aborted"), DISMISS_STR));
1526
     TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("UI Aborted"), DISMISS_STR));
1516
     print_job_timer.stop();
1527
     print_job_timer.stop();
1517
-    set_status_P(GET_TEXT(MSG_PRINT_ABORTED));
1528
+    LCD_MESSAGEPGM(MSG_PRINT_ABORTED);
1518
     TERN_(HAS_LCD_MENU, return_to_status());
1529
     TERN_(HAS_LCD_MENU, return_to_status());
1519
   }
1530
   }
1520
 
1531
 
1530
 
1541
 
1531
     TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume")));
1542
     TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume")));
1532
 
1543
 
1533
-    set_status_P(print_paused);
1544
+    LCD_MESSAGEPGM(MSG_PRINT_PAUSED);
1534
 
1545
 
1535
     #if ENABLED(PARK_HEAD_ON_PAUSE)
1546
     #if ENABLED(PARK_HEAD_ON_PAUSE)
1536
       TERN_(HAS_WIRED_LCD, lcd_pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT)); // Show message immediately to let user know about pause in progress
1547
       TERN_(HAS_WIRED_LCD, lcd_pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT)); // Show message immediately to let user know about pause in progress
1615
 
1626
 
1616
 #if ENABLED(SDSUPPORT)
1627
 #if ENABLED(SDSUPPORT)
1617
 
1628
 
1629
+  #if ENABLED(EXTENSIBLE_UI)
1630
+    #include "extui/ui_api.h"
1631
+  #endif
1632
+
1618
   void MarlinUI::media_changed(const uint8_t old_status, const uint8_t status) {
1633
   void MarlinUI::media_changed(const uint8_t old_status, const uint8_t status) {
1619
     if (old_status == status) {
1634
     if (old_status == status) {
1620
       TERN_(EXTENSIBLE_UI, ExtUI::onMediaError()); // Failed to mount/unmount
1635
       TERN_(EXTENSIBLE_UI, ExtUI::onMediaError()); // Failed to mount/unmount
1629
           quick_feedback();
1644
           quick_feedback();
1630
           goto_screen(MEDIA_MENU_GATEWAY);
1645
           goto_screen(MEDIA_MENU_GATEWAY);
1631
         #else
1646
         #else
1632
-          set_status_P(GET_TEXT(MSG_MEDIA_INSERTED));
1647
+          LCD_MESSAGEPGM(MSG_MEDIA_INSERTED);
1633
         #endif
1648
         #endif
1634
       }
1649
       }
1635
     }
1650
     }
1637
       if (old_status < 2) {
1652
       if (old_status < 2) {
1638
         TERN_(EXTENSIBLE_UI, ExtUI::onMediaRemoved()); // ExtUI response
1653
         TERN_(EXTENSIBLE_UI, ExtUI::onMediaRemoved()); // ExtUI response
1639
         #if PIN_EXISTS(SD_DETECT)
1654
         #if PIN_EXISTS(SD_DETECT)
1640
-          set_status_P(GET_TEXT(MSG_MEDIA_REMOVED));
1655
+          LCD_MESSAGEPGM(MSG_MEDIA_REMOVED);
1641
           #if HAS_LCD_MENU
1656
           #if HAS_LCD_MENU
1642
             if (!defer_return_to_status) return_to_status();
1657
             if (!defer_return_to_status) return_to_status();
1643
           #endif
1658
           #endif

+ 24
- 23
Marlin/src/lcd/marlinui.h Bestand weergeven

373
     static constexpr uint8_t get_progress_percent() { return 0; }
373
     static constexpr uint8_t get_progress_percent() { return 0; }
374
   #endif
374
   #endif
375
 
375
 
376
-  #if HAS_DISPLAY
377
-
378
-    static void init();
379
-    static void update();
380
-    static void set_alert_status_P(PGM_P const message);
381
-
376
+  #if HAS_STATUS_MESSAGE
382
     static char status_message[];
377
     static char status_message[];
383
-    static bool has_status();
384
-
385
     static uint8_t alert_level; // Higher levels block lower levels
378
     static uint8_t alert_level; // Higher levels block lower levels
386
-    static inline void reset_alert_level() { alert_level = 0; }
387
 
379
 
388
     #if ENABLED(STATUS_MESSAGE_SCROLLING)
380
     #if ENABLED(STATUS_MESSAGE_SCROLLING)
389
       static uint8_t status_scroll_offset;
381
       static uint8_t status_scroll_offset;
391
       static char* status_and_len(uint8_t &len);
383
       static char* status_and_len(uint8_t &len);
392
     #endif
384
     #endif
393
 
385
 
386
+    static bool has_status();
387
+    static void reset_status(const bool no_welcome=false);
388
+    static void set_status(const char* const message, const bool persist=false);
389
+    static void set_status_P(PGM_P const message, const int8_t level=0);
390
+    static void status_printf_P(const uint8_t level, PGM_P const fmt, ...);
391
+    static void set_alert_status_P(PGM_P const message);
392
+    static inline void reset_alert_level() { alert_level = 0; }
393
+  #else
394
+    static constexpr bool has_status() { return false; }
395
+    static inline void reset_status(const bool=false) {}
396
+    static void set_status(const char* message, const bool=false);
397
+    static void set_status_P(PGM_P message, const int8_t=0);
398
+    static void status_printf_P(const uint8_t, PGM_P message, ...);
399
+    static inline void set_alert_status_P(PGM_P const) {}
400
+    static inline void reset_alert_level() {}
401
+  #endif
402
+
403
+  #if HAS_DISPLAY
404
+
405
+    static void init();
406
+    static void update();
407
+
394
     static void abort_print();
408
     static void abort_print();
395
     static void pause_print();
409
     static void pause_print();
396
     static void resume_print();
410
     static void resume_print();
481
     static bool get_blink();
495
     static bool get_blink();
482
     static void kill_screen(PGM_P const lcd_error, PGM_P const lcd_component);
496
     static void kill_screen(PGM_P const lcd_error, PGM_P const lcd_component);
483
     static void draw_kill_screen();
497
     static void draw_kill_screen();
484
-    static void set_status(const char* const message, const bool persist=false);
485
-    static void set_status_P(PGM_P const message, const int8_t level=0);
486
-    static void status_printf_P(const uint8_t level, PGM_P const fmt, ...);
487
-    static void reset_status(const bool no_welcome=false);
488
 
498
 
489
   #else // No LCD
499
   #else // No LCD
490
 
500
 
491
-    // Send status to host as a notification
492
-    static void set_status(const char* message, const bool=false);
493
-    static void set_status_P(PGM_P message, const int8_t=0);
494
-    static void status_printf_P(const uint8_t, PGM_P message, ...);
495
-
496
     static inline void init() {}
501
     static inline void init() {}
497
     static inline void update() {}
502
     static inline void update() {}
498
     static inline void return_to_status() {}
503
     static inline void return_to_status() {}
499
-    static inline void set_alert_status_P(PGM_P const) {}
500
-    static inline void reset_status(const bool=false) {}
501
-    static inline void reset_alert_level() {}
502
-    static constexpr bool has_status() { return false; }
503
 
504
 
504
   #endif
505
   #endif
505
 
506
 
702
 
703
 
703
 private:
704
 private:
704
 
705
 
705
-  #if HAS_DISPLAY
706
+  #if HAS_STATUS_MESSAGE
706
     static void finish_status(const bool persist);
707
     static void finish_status(const bool persist);
707
   #endif
708
   #endif
708
 
709
 

Laden…
Annuleren
Opslaan