From cb61436093238cd1a357dd248cd285e79e276542 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Sun, 7 Feb 2021 09:47:30 +0100 Subject: [PATCH] Add remaining time to change/pause/user interaction to LCD Info screen - Add parameter `C` to gcode `M73` - LCD Info screen switches to change time if last `M73` gcode contains `C` parameter - Examples: - `M73 P5 R120` will display on LCD ` SD 5% 02:00R ` if it is printing at 100% speed - `M73 P5 R120 C60` will display on LCD ` SD 5% 01:00C ` if it is printing at 100% speed Slicers can generate "Time to change/pause/user interaction" using `C` parameter to "overwrite" the remaining print time. To switch between time to change and remaining time just send in intervals `M73` with or without `C` parameter. --- Firmware/Marlin.h | 2 ++ Firmware/Marlin_main.cpp | 33 ++++++++++++++++++++++++++++----- Firmware/ultralcd.cpp | 32 ++++++++++++++++++++------------ 3 files changed, 50 insertions(+), 17 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index cbe03c0f..5ef7ca00 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -366,6 +366,7 @@ extern uint8_t print_percent_done_normal; extern uint16_t print_time_remaining_normal; extern uint8_t print_percent_done_silent; extern uint16_t print_time_remaining_silent; +extern uint16_t print_time_to_change; #define PRINT_TIME_REMAINING_INIT 0xffff @@ -438,6 +439,7 @@ extern void cancel_saved_printing(); //estimated time to end of the print extern uint16_t print_time_remaining(); +extern uint16_t print_time_to_change_remaining(); extern uint8_t calc_percent_done(); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 0c468189..b36dd16a 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -316,6 +316,7 @@ uint8_t print_percent_done_normal = PRINT_PERCENT_DONE_INIT; uint16_t print_time_remaining_normal = PRINT_TIME_REMAINING_INIT; //estimated remaining print time in minutes uint8_t print_percent_done_silent = PRINT_PERCENT_DONE_INIT; uint16_t print_time_remaining_silent = PRINT_TIME_REMAINING_INIT; //estimated remaining print time in minutes +uint16_t print_time_to_change = PRINT_TIME_REMAINING_INIT; //estimated remaining time to next change in minutes uint32_t IP_address = 0; @@ -6395,13 +6396,14 @@ Sigma_Exit: ### M73 - Set/get print progress M73: Set/Get build percentage #### Usage - M73 [ P | R | Q | S ] + M73 [ P | R | Q | S | C ] #### Parameters - `P` - Percent in normal mode - `R` - Time remaining in normal mode - `Q` - Percent in silent mode - `S` - Time in silent mode + - `C` - Time to change/pause/user interaction */ case 73: //M73 show percent done and time remaining if(code_seen('P')) print_percent_done_normal = code_value(); @@ -6414,6 +6416,14 @@ Sigma_Exit: printf_P(_msg_mode_done_remain, _N("NORMAL"), int(print_percent_done_normal), print_time_remaining_normal); printf_P(_msg_mode_done_remain, _N("SILENT"), int(print_percent_done_silent), print_time_remaining_silent); } + + print_time_to_change = PRINT_TIME_REMAINING_INIT; + if(code_seen('C')) + { + print_time_to_change = code_value(); + printf_P(_N("Time to next change in mins: %d\n"), print_time_to_change); + } + break; /*! @@ -11665,6 +11675,18 @@ uint16_t print_time_remaining() { return print_t; } +uint16_t print_time_to_change_remaining() { + uint16_t print_t = PRINT_TIME_REMAINING_INIT; +//#ifdef TMC2130 +// if (SilentModeMenu == SILENT_MODE_OFF) print_t = print_time_to_change; +// else print_t = print_time_to_change - (print_time_remaining_normal - print_time_remaining_silent); +//#else + print_t = print_time_to_change; +//#endif //TMC2130 + if ((print_t != PRINT_TIME_REMAINING_INIT) && (feedmultiply != 0)) print_t = 100ul * print_t / feedmultiply; + return print_t; +} + uint8_t calc_percent_done() { //in case that we have information from M73 gcode return percentage counted by slicer, else return percentage counted as byte_printed/filesize @@ -11689,10 +11711,11 @@ uint8_t calc_percent_done() static void print_time_remaining_init() { - print_time_remaining_normal = PRINT_TIME_REMAINING_INIT; - print_time_remaining_silent = PRINT_TIME_REMAINING_INIT; - print_percent_done_normal = PRINT_PERCENT_DONE_INIT; - print_percent_done_silent = PRINT_PERCENT_DONE_INIT; + print_time_remaining_normal = PRINT_TIME_REMAINING_INIT; + print_percent_done_normal = PRINT_PERCENT_DONE_INIT; + print_time_remaining_silent = PRINT_TIME_REMAINING_INIT; + print_percent_done_silent = PRINT_PERCENT_DONE_INIT; + print_time_to_change = PRINT_TIME_REMAINING_INIT; } void load_filament_final_feed() diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index f8b791b0..1854d846 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -673,22 +673,30 @@ void lcdui_print_time(void) { //if remaining print time estimation is available print it else print elapsed time uint16_t print_t = 0; - if (print_time_remaining_normal != PRINT_TIME_REMAINING_INIT) + int chars = 0; + char suff = ' '; + char suff_doubt = ' '; + + if(print_time_to_change != PRINT_TIME_REMAINING_INIT) + { + print_t = print_time_to_change_remaining(); + suff = 'C'; + if (feedmultiply != 100) + suff_doubt = '?'; + } + else if (print_time_remaining_normal != PRINT_TIME_REMAINING_INIT) + { print_t = print_time_remaining(); + suff = 'R'; + if (feedmultiply != 100) + suff_doubt = '?'; + } else if(starttime != 0) print_t = _millis() / 60000 - starttime / 60000; - int chars = 0; - if ((PRINTER_ACTIVE) && ((print_time_remaining_normal != PRINT_TIME_REMAINING_INIT) || (starttime != 0))) + + if ((PRINTER_ACTIVE) && ((print_time_remaining_normal != PRINT_TIME_REMAINING_INIT) || (print_time_to_change != PRINT_TIME_REMAINING_INIT) || (starttime != 0))) { - char suff = ' '; - char suff_doubt = ' '; - if (print_time_remaining_normal != PRINT_TIME_REMAINING_INIT) - { - suff = 'R'; - if (feedmultiply != 100) - suff_doubt = '?'; - } - if (print_t < 6000) //time<100h + if (print_t < 6000) //time<100h chars = lcd_printf_P(_N("%c%02u:%02u%c%c"), LCD_STR_CLOCK[0], print_t / 60, print_t % 60, suff, suff_doubt); else //time>=100h chars = lcd_printf_P(_N("%c%3uh %c%c"), LCD_STR_CLOCK[0], print_t / 60, suff, suff_doubt);