Skip to content

Commit 8481264

Browse files
EvilGremlinthinkyhead
andcommittedDec 16, 2022
♻️ Set Progress without LCD (MarlinFirmware#24767)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent b0f02b8 commit 8481264

34 files changed

+627
-488
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ vc-fileutils.settings
147147
imgui.ini
148148
eeprom.dat
149149
spi_flash.bin
150+
fs.img
150151

151152
#cmake
152153
CMakeLists.txt

‎Marlin/Configuration_adv.h

+29-32
Original file line numberDiff line numberDiff line change
@@ -1403,9 +1403,6 @@
14031403
// On the Info Screen, display XY with one decimal place when possible
14041404
//#define LCD_DECIMAL_SMALL_XY
14051405

1406-
// Add an 'M73' G-code to set the current percentage
1407-
//#define LCD_SET_PROGRESS_MANUALLY
1408-
14091406
// Show the E position (filament used) during printing
14101407
//#define LCD_SHOW_E_TOTAL
14111408

@@ -1426,37 +1423,43 @@
14261423
//#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup
14271424
#endif
14281425
#if ENABLED(NEO2_COLOR_PRESETS)
1429-
#define NEO2_USER_PRESET_RED 255 // User defined RED value
1430-
#define NEO2_USER_PRESET_GREEN 128 // User defined GREEN value
1431-
#define NEO2_USER_PRESET_BLUE 0 // User defined BLUE value
1432-
#define NEO2_USER_PRESET_WHITE 255 // User defined WHITE value
1433-
#define NEO2_USER_PRESET_BRIGHTNESS 255 // User defined intensity
1434-
//#define NEO2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip
1426+
#define NEO2_USER_PRESET_RED 255 // User defined RED value
1427+
#define NEO2_USER_PRESET_GREEN 128 // User defined GREEN value
1428+
#define NEO2_USER_PRESET_BLUE 0 // User defined BLUE value
1429+
#define NEO2_USER_PRESET_WHITE 255 // User defined WHITE value
1430+
#define NEO2_USER_PRESET_BRIGHTNESS 255 // User defined intensity
1431+
//#define NEO2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip
14351432
#endif
14361433
#endif
14371434

1438-
#endif
1435+
#endif // HAS_DISPLAY || DWIN_LCD_PROUI
14391436

1440-
// LCD Print Progress options
1441-
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
1442-
#if CAN_SHOW_REMAINING_TIME
1443-
//#define SHOW_REMAINING_TIME // Display estimated time to completion
1444-
#if ENABLED(SHOW_REMAINING_TIME)
1445-
//#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
1446-
//#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time
1447-
#endif
1437+
// Add the G-code 'M73' to set / report the current job progress
1438+
//#define SET_PROGRESS_MANUALLY
1439+
#if ENABLED(SET_PROGRESS_MANUALLY)
1440+
//#define SET_PROGRESS_PERCENT // Add 'P' parameter to set percentage done, otherwise use Marlin's estimate
1441+
//#define SET_REMAINING_TIME // Add 'R' parameter to set remaining time, otherwise use Marlin's estimate
1442+
//#define SET_INTERACTION_TIME // Add 'C' parameter to set time until next filament change or other user interaction
1443+
#if ENABLED(SET_INTERACTION_TIME)
1444+
#define SHOW_INTERACTION_TIME // Display time until next user interaction ('C' = filament change)
14481445
#endif
1446+
//#define M73_REPORT // Report progress to host with 'M73'
1447+
#endif
14491448

1450-
#if EITHER(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI)
1451-
//#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits
1452-
#endif
1449+
// LCD Print Progress options, multiple can be rotated depending on screen layout
1450+
#if HAS_DISPLAY && EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY)
1451+
#define SHOW_PROGRESS_PERCENT // Show print progress percentage (doesn't affect progress bar)
1452+
#define SHOW_ELAPSED_TIME // Display elapsed printing time (prefix 'E')
1453+
//#define SHOW_REMAINING_TIME // Display estimated time to completion (prefix 'R')
1454+
1455+
//#define PRINT_PROGRESS_SHOW_DECIMALS // Show/report progress with decimal digits, not all UIs support this
14531456

14541457
#if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
14551458
//#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing
14561459
#if ENABLED(LCD_PROGRESS_BAR)
14571460
#define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar
14581461
#define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message
1459-
#define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever)
1462+
#define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever)
14601463
//#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it
14611464
//#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar
14621465
#endif
@@ -1799,14 +1802,8 @@
17991802
#endif // HAS_MARLINUI_U8GLIB
18001803

18011804
#if HAS_MARLINUI_U8GLIB || IS_DWIN_MARLINUI
1802-
// Show SD percentage next to the progress bar
1803-
//#define SHOW_SD_PERCENT
1804-
1805-
// Enable to save many cycles by drawing a hollow frame on Menu Screens
1806-
#define MENU_HOLLOW_FRAME
1807-
1808-
// Swap the CW/CCW indicators in the graphics overlay
1809-
//#define OVERLAY_GFX_REVERSE
1805+
#define MENU_HOLLOW_FRAME // Enable to save many cycles by drawing a hollow frame on Menu Screens
1806+
//#define OVERLAY_GFX_REVERSE // Swap the CW/CCW indicators in the graphics overlay
18101807
#endif
18111808

18121809
//
@@ -2064,7 +2061,7 @@
20642061
*/
20652062
//#define LIN_ADVANCE
20662063
#if ENABLED(LIN_ADVANCE)
2067-
//#define EXTRA_LIN_ADVANCE_K // Add a second linear advance constant, configurable with M900.
2064+
//#define EXTRA_LIN_ADVANCE_K // Add a second linear advance constant, configurable with M900 L.
20682065
#define LIN_ADVANCE_K 0.22 // Unit: mm compression per 1mm/s extruder speed
20692066
//#define LA_DEBUG // Print debug information to serial during operation. Disable for production use.
20702067
//#define EXPERIMENTAL_SCURVE // Allow S-Curve Acceleration to be used with LA.
@@ -4058,7 +4055,7 @@
40584055

40594056
/**
40604057
* Mechanical Gantry Calibration
4061-
* Modern replacement for the Prusa TMC_Z_CALIBRATION.
4058+
* Modern replacement for the Průša TMC_Z_CALIBRATION.
40624059
* Adds capability to work with any adjustable current drivers.
40634060
* Implemented as G34 because M915 is deprecated.
40644061
* @section calibrate

‎Marlin/src/MarlinCore.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ void startOrResumeJob() {
347347
TERN_(GCODE_REPEAT_MARKERS, repeat.reset());
348348
TERN_(CANCEL_OBJECTS, cancelable.reset());
349349
TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator = 0);
350-
#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
350+
#if ENABLED(SET_REMAINING_TIME)
351351
ui.reset_remaining_time();
352352
#endif
353353
}

‎Marlin/src/gcode/gcode.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,8 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
561561
case 48: M48(); break; // M48: Z probe repeatability test
562562
#endif
563563

564-
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
565-
case 73: M73(); break; // M73: Set progress percentage (for display on LCD)
564+
#if ENABLED(SET_PROGRESS_MANUALLY)
565+
case 73: M73(); break; // M73: Set progress percentage
566566
#endif
567567

568568
case 75: M75(); break; // M75: Start print timer

‎Marlin/src/gcode/gcode.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
* M43 - Display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins (Requires PINS_DEBUGGING)
115115
* M48 - Measure Z Probe repeatability: M48 P<points> X<pos> Y<pos> V<level> E<engage> L<legs> S<chizoid>. (Requires Z_MIN_PROBE_REPEATABILITY_TEST)
116116
*
117-
* M73 - Set the progress percentage. (Requires LCD_SET_PROGRESS_MANUALLY)
117+
* M73 - Set the progress percentage. (Requires SET_PROGRESS_MANUALLY)
118118
* M75 - Start the print job timer.
119119
* M76 - Pause the print job timer.
120120
* M77 - Stop the print job timer.
@@ -677,7 +677,7 @@ class GcodeSuite {
677677
static void M48();
678678
#endif
679679

680-
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
680+
#if ENABLED(SET_PROGRESS_MANUALLY)
681681
static void M73();
682682
#endif
683683

‎Marlin/src/gcode/host/M115.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void GcodeSuite::M115() {
142142
cap_line(F("LEVELING_DATA"), ENABLED(HAS_LEVELING));
143143

144144
// BUILD_PERCENT (M73)
145-
cap_line(F("BUILD_PERCENT"), ENABLED(LCD_SET_PROGRESS_MANUALLY));
145+
cap_line(F("BUILD_PERCENT"), ENABLED(SET_PROGRESS_PERCENT));
146146

147147
// SOFTWARE_POWER (M80, M81)
148148
cap_line(F("SOFTWARE_POWER"), ENABLED(PSU_CONTROL));

‎Marlin/src/gcode/lcd/M73.cpp

+45-9
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,35 @@
2222

2323
#include "../../inc/MarlinConfig.h"
2424

25-
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
25+
#if ENABLED(SET_PROGRESS_MANUALLY)
2626

2727
#include "../gcode.h"
2828
#include "../../lcd/marlinui.h"
2929
#include "../../sd/cardreader.h"
30+
#include "../../libs/numtostr.h"
3031

3132
#if ENABLED(DWIN_LCD_PROUI)
3233
#include "../../lcd/e3v2/proui/dwin.h"
3334
#endif
3435

36+
#if ENABLED(M73_REPORT)
37+
#define M73_REPORT_PRUSA
38+
#endif
39+
3540
/**
3641
* M73: Set percentage complete (for display on LCD)
3742
*
3843
* Example:
39-
* M73 P25 ; Set progress to 25%
44+
* M73 P25.63 ; Set progress to 25.63%
45+
* M73 R456 ; Set remaining time to 456 minutes
46+
* M73 C12 ; Set next interaction countdown to 12 minutes
47+
* M73 ; Report current values
48+
*
49+
* Use a shorter-than-Průša report format:
50+
* M73 Percent done: ---%; Time left: -----m; Change: -----m;
51+
*
52+
* When PRINT_PROGRESS_SHOW_DECIMALS is enabled - reports percent with 100 / 23.4 / 3.45 format
53+
*
4054
*/
4155
void GcodeSuite::M73() {
4256

@@ -46,17 +60,39 @@ void GcodeSuite::M73() {
4660

4761
#else
4862

49-
if (parser.seenval('P'))
50-
ui.set_progress((PROGRESS_SCALE) > 1
51-
? parser.value_float() * (PROGRESS_SCALE)
52-
: parser.value_byte()
53-
);
63+
#if ENABLED(SET_PROGRESS_PERCENT)
64+
if (parser.seenval('P'))
65+
ui.set_progress((PROGRESS_SCALE) > 1
66+
? parser.value_float() * (PROGRESS_SCALE)
67+
: parser.value_byte()
68+
);
69+
#endif
5470

55-
#if ENABLED(USE_M73_REMAINING_TIME)
71+
#if ENABLED(SET_REMAINING_TIME)
5672
if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong());
5773
#endif
5874

75+
#if ENABLED(SET_INTERACTION_TIME)
76+
if (parser.seenval('C')) ui.set_interaction_time(60 * parser.value_ulong());
77+
#endif
78+
79+
#endif
80+
81+
#if ENABLED(M73_REPORT)
82+
{
83+
SERIAL_ECHO_MSG(
84+
TERN(M73_REPORT_PRUSA, "M73 Percent done: ", "Progress: ")
85+
, TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent())
86+
#if ENABLED(SET_REMAINING_TIME)
87+
, TERN(M73_REPORT_PRUSA, "; Print time remaining in mins: ", "%; Time left: "), ui.remaining_time / 60
88+
#endif
89+
#if ENABLED(SET_INTERACTION_TIME)
90+
, TERN(M73_REPORT_PRUSA, "; Change in mins: ", "m; Change: "), ui.interaction_time / 60
91+
#endif
92+
, TERN(M73_REPORT_PRUSA, ";", "m")
93+
);
94+
}
5995
#endif
6096
}
6197

62-
#endif // LCD_SET_PROGRESS_MANUALLY
98+
#endif // SET_PROGRESS_MANUALLY

‎Marlin/src/gcode/sd/M1001.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "../queue.h"
3535
#endif
3636

37-
#if EITHER(LCD_SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE)
37+
#if EITHER(SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE)
3838
#include "../../lcd/marlinui.h"
3939
#endif
4040

@@ -84,7 +84,7 @@ void GcodeSuite::M1001() {
8484
process_subcommands_now(F("M77"));
8585

8686
// Set the progress bar "done" state
87-
TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress_done());
87+
TERN_(SET_PROGRESS_PERCENT, ui.set_progress_done());
8888

8989
// Announce SD file completion
9090
{

‎Marlin/src/gcode/sd/M23.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void GcodeSuite::M23() {
3838
for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0';
3939
card.openFileRead(parser.string_arg);
4040

41-
TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0));
41+
TERN_(SET_PROGRESS_PERCENT, ui.set_progress(0));
4242
}
4343

4444
#endif // SDSUPPORT

‎Marlin/src/inc/Conditionals_LCD.h

-4
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,6 @@
529529
#define HAS_MANUAL_MOVE_MENU 1
530530
#endif
531531

532-
#if ANY(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL, IS_DWIN_MARLINUI, DWIN_CREALITY_LCD_JYERSUI)
533-
#define CAN_SHOW_REMAINING_TIME 1
534-
#endif
535-
536532
#if HAS_MARLINUI_U8GLIB
537533
#ifndef LCD_PIXEL_WIDTH
538534
#define LCD_PIXEL_WIDTH 128

‎Marlin/src/inc/Conditionals_adv.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -599,10 +599,16 @@
599599
#undef MENU_ADDAUTOSTART
600600
#endif
601601

602-
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
602+
#if EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY)
603603
#define HAS_PRINT_PROGRESS 1
604604
#endif
605605

606+
#if DISABLED(SET_PROGRESS_MANUALLY)
607+
#undef SET_REMAINING_TIME
608+
#undef SET_INTERACTION_TIME
609+
#undef M73_REPORT
610+
#endif
611+
606612
#if ANY(HAS_MARLINUI_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL)
607613
#define HAS_ENCODER_ACTION 1
608614
#endif

‎Marlin/src/inc/SanityCheck.h

+15-11
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@
587587
#elif defined(MKS_LCD12864)
588588
#error "MKS_LCD12864 is now MKS_LCD12864A or MKS_LCD12864B."
589589
#elif defined(DOGM_SD_PERCENT)
590-
#error "DOGM_SD_PERCENT is now SHOW_SD_PERCENT."
590+
#error "DOGM_SD_PERCENT is now SHOW_PROGRESS_PERCENT."
591591
#elif defined(NEOPIXEL_BKGD_LED_INDEX)
592592
#error "NEOPIXEL_BKGD_LED_INDEX is now NEOPIXEL_BKGD_INDEX_FIRST."
593593
#elif defined(TEMP_SENSOR_1_AS_REDUNDANT)
@@ -646,6 +646,12 @@
646646
#error "TOUCH_IDLE_SLEEP (seconds) is now TOUCH_IDLE_SLEEP_MINS (minutes)."
647647
#elif defined(LCD_BACKLIGHT_TIMEOUT)
648648
#error "LCD_BACKLIGHT_TIMEOUT (seconds) is now LCD_BACKLIGHT_TIMEOUT_MINS (minutes)."
649+
#elif defined(LCD_SET_PROGRESS_MANUALLY)
650+
#error "LCD_SET_PROGRESS_MANUALLY is now SET_PROGRESS_MANUALLY."
651+
#elif defined(USE_M73_REMAINING_TIME)
652+
#error "USE_M73_REMAINING_TIME is now SET_REMAINING_TIME."
653+
#elif defined(SHOW_SD_PERCENT)
654+
#error "SHOW_SD_PERCENT is now SHOW_PROGRESS_PERCENT."
649655
#endif
650656

651657
// L64xx stepper drivers have been removed
@@ -894,8 +900,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
894900
* Progress Bar
895901
*/
896902
#if ENABLED(LCD_PROGRESS_BAR)
897-
#if NONE(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
898-
#error "LCD_PROGRESS_BAR requires SDSUPPORT or LCD_SET_PROGRESS_MANUALLY."
903+
#if NONE(SDSUPPORT, SET_PROGRESS_MANUALLY)
904+
#error "LCD_PROGRESS_BAR requires SDSUPPORT or SET_PROGRESS_MANUALLY."
899905
#elif NONE(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
900906
#error "LCD_PROGRESS_BAR only applies to HD44780 character LCD and TFTGLCD_PANEL_(SPI|I2C)."
901907
#elif HAS_MARLINUI_U8GLIB || IS_DWIN_MARLINUI
@@ -905,12 +911,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
905911
#elif PROGRESS_MSG_EXPIRE < 0
906912
#error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0."
907913
#endif
908-
#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI, HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
909-
#error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI."
910914
#endif
911915

912-
#if ENABLED(USE_M73_REMAINING_TIME) && DISABLED(LCD_SET_PROGRESS_MANUALLY)
913-
#error "USE_M73_REMAINING_TIME requires LCD_SET_PROGRESS_MANUALLY"
916+
#if ENABLED(SET_PROGRESS_MANUALLY) && NONE(SET_PROGRESS_PERCENT, SET_REMAINING_TIME, SET_INTERACTION_TIME)
917+
#error "SET_PROGRESS_MANUALLY requires at least one of SET_PROGRESS_PERCENT, SET_REMAINING_TIME, SET_INTERACTION_TIME to be enabled."
918+
#endif
919+
920+
#if HAS_LCDPRINT && LCD_HEIGHT < 4 && ANY(SHOW_PROGRESS_PERCENT, SHOW_ELAPSED_TIME, SHOW_REMAINING_TIME, SHOW_INTERACTION_TIME)
921+
#error "Displays with fewer than 4 rows of text can't show progress values."
914922
#endif
915923

916924
#if !HAS_MARLINUI_MENU && ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
@@ -4038,10 +4046,6 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
40384046
#error "COOLANT_FLOOD requires COOLANT_FLOOD_PIN to be defined."
40394047
#endif
40404048

4041-
#if NONE(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, IS_DWIN_MARLINUI) && ENABLED(PRINT_PROGRESS_SHOW_DECIMALS)
4042-
#error "PRINT_PROGRESS_SHOW_DECIMALS currently requires a Graphical LCD."
4043-
#endif
4044-
40454049
#if HAS_ADC_BUTTONS && defined(ADC_BUTTON_DEBOUNCE_DELAY) && ADC_BUTTON_DEBOUNCE_DELAY < 16
40464050
#error "ADC_BUTTON_DEBOUNCE_DELAY must be greater than 16."
40474051
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.