♻️ Set Progress without LCD (#24767)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
EvilGremlin
2022-10-09 18:30:47 +03:00
committed by Scott Lahteine
parent 0d8a695ea9
commit f595e40ceb
34 changed files with 626 additions and 487 deletions

View File

@@ -561,8 +561,8 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 48: M48(); break; // M48: Z probe repeatability test
#endif
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
case 73: M73(); break; // M73: Set progress percentage (for display on LCD)
#if ENABLED(SET_PROGRESS_MANUALLY)
case 73: M73(); break; // M73: Set progress percentage
#endif
case 75: M75(); break; // M75: Start print timer

View File

@@ -114,7 +114,7 @@
* M43 - Display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins (Requires PINS_DEBUGGING)
* 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)
*
* M73 - Set the progress percentage. (Requires LCD_SET_PROGRESS_MANUALLY)
* M73 - Set the progress percentage. (Requires SET_PROGRESS_MANUALLY)
* M75 - Start the print job timer.
* M76 - Pause the print job timer.
* M77 - Stop the print job timer.
@@ -677,7 +677,7 @@ private:
static void M48();
#endif
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
#if ENABLED(SET_PROGRESS_MANUALLY)
static void M73();
#endif

View File

@@ -142,7 +142,7 @@ void GcodeSuite::M115() {
cap_line(F("LEVELING_DATA"), ENABLED(HAS_LEVELING));
// BUILD_PERCENT (M73)
cap_line(F("BUILD_PERCENT"), ENABLED(LCD_SET_PROGRESS_MANUALLY));
cap_line(F("BUILD_PERCENT"), ENABLED(SET_PROGRESS_PERCENT));
// SOFTWARE_POWER (M80, M81)
cap_line(F("SOFTWARE_POWER"), ENABLED(PSU_CONTROL));

View File

@@ -22,21 +22,35 @@
#include "../../inc/MarlinConfig.h"
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
#if ENABLED(SET_PROGRESS_MANUALLY)
#include "../gcode.h"
#include "../../lcd/marlinui.h"
#include "../../sd/cardreader.h"
#include "../../libs/numtostr.h"
#if ENABLED(DWIN_LCD_PROUI)
#include "../../lcd/e3v2/proui/dwin.h"
#endif
#if ENABLED(M73_REPORT)
#define M73_REPORT_PRUSA
#endif
/**
* M73: Set percentage complete (for display on LCD)
*
* Example:
* M73 P25 ; Set progress to 25%
* M73 P25.63 ; Set progress to 25.63%
* M73 R456 ; Set remaining time to 456 minutes
* M73 C12 ; Set next interaction countdown to 12 minutes
* M73 ; Report current values
*
* Use a shorter-than-Průša report format:
* M73 Percent done: ---%; Time left: -----m; Change: -----m;
*
* When PRINT_PROGRESS_SHOW_DECIMALS is enabled - reports percent with 100 / 23.4 / 3.45 format
*
*/
void GcodeSuite::M73() {
@@ -46,17 +60,39 @@ void GcodeSuite::M73() {
#else
if (parser.seenval('P'))
ui.set_progress((PROGRESS_SCALE) > 1
? parser.value_float() * (PROGRESS_SCALE)
: parser.value_byte()
);
#if ENABLED(SET_PROGRESS_PERCENT)
if (parser.seenval('P'))
ui.set_progress((PROGRESS_SCALE) > 1
? parser.value_float() * (PROGRESS_SCALE)
: parser.value_byte()
);
#endif
#if ENABLED(USE_M73_REMAINING_TIME)
#if ENABLED(SET_REMAINING_TIME)
if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong());
#endif
#if ENABLED(SET_INTERACTION_TIME)
if (parser.seenval('C')) ui.set_interaction_time(60 * parser.value_ulong());
#endif
#endif
#if ENABLED(M73_REPORT)
{
SERIAL_ECHO_MSG(
TERN(M73_REPORT_PRUSA, "M73 Percent done: ", "Progress: ")
, TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent())
#if ENABLED(SET_REMAINING_TIME)
, TERN(M73_REPORT_PRUSA, "; Print time remaining in mins: ", "%; Time left: "), ui.remaining_time / 60
#endif
#if ENABLED(SET_INTERACTION_TIME)
, TERN(M73_REPORT_PRUSA, "; Change in mins: ", "m; Change: "), ui.interaction_time / 60
#endif
, TERN(M73_REPORT_PRUSA, ";", "m")
);
}
#endif
}
#endif // LCD_SET_PROGRESS_MANUALLY
#endif // SET_PROGRESS_MANUALLY

View File

@@ -34,7 +34,7 @@
#include "../queue.h"
#endif
#if EITHER(LCD_SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE)
#if EITHER(SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE)
#include "../../lcd/marlinui.h"
#endif
@@ -84,7 +84,7 @@ void GcodeSuite::M1001() {
process_subcommands_now(F("M77"));
// Set the progress bar "done" state
TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress_done());
TERN_(SET_PROGRESS_PERCENT, ui.set_progress_done());
// Announce SD file completion
{

View File

@@ -38,7 +38,7 @@ void GcodeSuite::M23() {
for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0';
card.openFileRead(parser.string_arg);
TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0));
TERN_(SET_PROGRESS_PERCENT, ui.set_progress(0));
}
#endif // SDSUPPORT