From ad680951248e166e007301bd4c36fe8c0b583a3a Mon Sep 17 00:00:00 2001 From: Kurt Haenen Date: Tue, 26 Mar 2024 21:13:53 +0100 Subject: [PATCH] Differentiated between printed and elapsed time (#75) Co-authored-by: Kurt Haenen --- CYD-Klipper/src/core/data_setup.cpp | 7 ++++--- CYD-Klipper/src/core/data_setup.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CYD-Klipper/src/core/data_setup.cpp b/CYD-Klipper/src/core/data_setup.cpp index 28ff021..f1ea7e4 100644 --- a/CYD-Klipper/src/core/data_setup.cpp +++ b/CYD-Klipper/src/core/data_setup.cpp @@ -214,7 +214,8 @@ void fetch_printer_data() const char *filename = status["print_stats"]["filename"]; strcpy(filename_buff, filename); printer.print_filename = filename_buff; - printer.elapsed_time_s = status["print_stats"]["print_duration"]; + printer.elapsed_time_s = status["print_stats"]["total_duration"]; + printer.printed_time_s = status["print_stats"]["print_duration"]; printer.filament_used_mm = status["print_stats"]["filament_used"]; printer.total_layers = status["print_stats"]["info"]["total_layer"]; printer.current_layer = status["print_stats"]["info"]["current_layer"]; @@ -248,12 +249,12 @@ void fetch_printer_data() if (printer.state == PRINTER_STATE_PRINTING && printer.print_progress > 0) { - float remaining_time_s_percentage = (printer.elapsed_time_s / printer.print_progress) - printer.elapsed_time_s; + float remaining_time_s_percentage = (printer.printed_time_s / printer.print_progress) - printer.printed_time_s; float remaining_time_s_slicer = 0; if (printer.slicer_estimated_print_time_s > 0) { - remaining_time_s_slicer = printer.slicer_estimated_print_time_s - printer.elapsed_time_s; + remaining_time_s_slicer = printer.slicer_estimated_print_time_s - printer.printed_time_s; } if (remaining_time_s_slicer <= 0 || config->remaining_time_calc_mode == REMAINING_TIME_CALC_PERCENTAGE) diff --git a/CYD-Klipper/src/core/data_setup.h b/CYD-Klipper/src/core/data_setup.h index cb447ca..6e9f7b5 100644 --- a/CYD-Klipper/src/core/data_setup.h +++ b/CYD-Klipper/src/core/data_setup.h @@ -20,6 +20,7 @@ typedef struct _Printer { unsigned char homed_axis; unsigned char absolute_coords; float elapsed_time_s; + float printed_time_s; float remaining_time_s; float filament_used_mm; char* print_filename;