From 7feb2fb8a307cf3c8669ab2c1158ea3682a0fc5c Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Tue, 23 May 2023 12:57:00 +0100 Subject: [PATCH 1/3] fixed bug if in PAUSE state user used CANCEL, will be reset offset from wcs0. --- stereotech_config/filament_control_2.cfg | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/stereotech_config/filament_control_2.cfg b/stereotech_config/filament_control_2.cfg index c4c573239422..86a065e5c77c 100644 --- a/stereotech_config/filament_control_2.cfg +++ b/stereotech_config/filament_control_2.cfg @@ -89,17 +89,11 @@ gcode: {% if params.RESET %} {% set reset_value = printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_value * printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made %} SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_OFFSET VARIABLE=checks_made VALUE=0 - {% if printer.gcode_move.current_wcs == 0 %} - SET_GCODE_OFFSET Z_ADJUST=-{reset_value} MOVE=1 - {% else %} - G10 L2 P0 R1 Z-{reset_value} - {% endif %} + ; G10 L2 P0 R1 Z-{reset_value} + SET_GCODE_OFFSET Z_ADJUST=-{reset_value} MOVE=1 {% else %} - {% if printer.gcode_move.current_wcs == 0 %} - SET_GCODE_OFFSET Z_ADJUST={printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_value} MOVE=1 - {% else %} - G10 L2 P0 R1 Z{printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_value} - {% endif %} + SET_GCODE_OFFSET Z_ADJUST={printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_value} MOVE=1 + ; G10 L2 P0 R1 Z{printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_value} SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_OFFSET VARIABLE=checks_made VALUE={printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made + 1} {% endif %} From 7f482f7eaa462a8d7eacf6a872b9a356037383e9 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Tue, 23 May 2023 13:35:18 +0100 Subject: [PATCH 2/3] STEAPP-490: added condition for do offset, execute offset only for first layer. Added code from STEAPP-489 for suport changed. --- klippy/extras/print_stats.py | 19 ++++++++++++++++++- klippy/extras/virtual_sdcard.py | 11 +++++++++++ stereotech_config/filament_control_2.cfg | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/klippy/extras/print_stats.py b/klippy/extras/print_stats.py index 668cd7d0c860..58568a76fb6c 100644 --- a/klippy/extras/print_stats.py +++ b/klippy/extras/print_stats.py @@ -3,6 +3,8 @@ # Copyright (C) 2020 Eric Callahan # # This file may be distributed under the terms of the GNU GPLv3 license. +import logging + class PrintStats: def __init__(self, config): @@ -77,11 +79,26 @@ def cmd_SET_PRINT_STATS_INFO(self, gcmd): elif total_layer != self.info_total_layer: self.info_total_layer = total_layer self.info_current_layer = 0 - if self.info_total_layer is not None and \ current_layer is not None and \ current_layer != self.info_current_layer: self.info_current_layer = min(current_layer, self.info_total_layer) + + def set_layer(self, total_layer=None, current_layer=None): + if total_layer: + try: + total_layer = int(total_layer) + self.info_total_layer = total_layer + except Exception as e: + logging.warning('Do not get total_layer\n %s' % e) + self.info_total_layer = 0 + if current_layer: + try: + current_layer = int(current_layer) + self.info_current_layer = current_layer + except Exception as e: + logging.warning('Do not get current_layer\n %s' % e) + def reset(self): self.filename = self.error_message = "" self.state = "standby" diff --git a/klippy/extras/virtual_sdcard.py b/klippy/extras/virtual_sdcard.py index 8f56dfbb4a6e..499846592a86 100644 --- a/klippy/extras/virtual_sdcard.py +++ b/klippy/extras/virtual_sdcard.py @@ -19,6 +19,8 @@ def __init__(self, config): self.file_position = self.file_size = 0 # Print Stat Tracking self.print_stats = self.printer.load_object(config, 'print_stats') + # variable + self.get_layer_count = True # Work timer self.reactor = self.printer.get_reactor() self.must_pause_work = self.cmd_from_sd = False @@ -264,6 +266,13 @@ def work_handler(self, eventtime): next_file_position = self.file_position + len(line) + 1 self.next_file_position = next_file_position try: + if self.get_layer_count and line.find(';LAYER_COUNT:') >= 0: + self.get_layer_count = False + caunt = line[13:] + self.print_stats.set_layer(total_layer=caunt) + if line.find(';LAYER:') >= 0: + caunt = line[7:] + self.print_stats.set_layer(current_layer=caunt) self.gcode.run_script(line) except self.gcode.error as e: error_message = str(e) @@ -291,10 +300,12 @@ def work_handler(self, eventtime): self.work_timer = None self.cmd_from_sd = False if error_message is not None: + self.get_layer_count = True self.print_stats.note_error(error_message) elif self.current_file is not None: self.print_stats.note_pause() else: + self.get_layer_count = True self.print_stats.note_complete() return self.reactor.NEVER diff --git a/stereotech_config/filament_control_2.cfg b/stereotech_config/filament_control_2.cfg index 86a065e5c77c..096325692539 100644 --- a/stereotech_config/filament_control_2.cfg +++ b/stereotech_config/filament_control_2.cfg @@ -43,7 +43,7 @@ gcode: SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_prime VALUE=1 SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_second_extruder VALUE=0 {% else %} - {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_offset and printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made < printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_count %} + {% if printer.print_stats.info.current_layer == 0 and printer["gcode_macro RECOVER_EXTRUSION"].enable_offset and printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made < printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_count %} RECOVER_EXTRUSION_BY_OFFSET {% else %} {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_offset %} From 38658f4db76ebc6dd5cd4c455a5f9f6340cb4b39 Mon Sep 17 00:00:00 2001 From: Ilya Gushchin Date: Fri, 23 Jun 2023 17:51:25 +0300 Subject: [PATCH 3/3] Update filament_control_2.cfg --- stereotech_config/filament_control_2.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stereotech_config/filament_control_2.cfg b/stereotech_config/filament_control_2.cfg index 27cb779b6ad5..78ea2fd22d88 100644 --- a/stereotech_config/filament_control_2.cfg +++ b/stereotech_config/filament_control_2.cfg @@ -47,7 +47,7 @@ gcode: SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=count_trigered_sensor VALUE=0 {% else %} SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=count_trigered_sensor VALUE={printer["gcode_macro RECOVER_EXTRUSION"].count_trigered_sensor + 1} - {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_offset and printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made < printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_count %} + {% if printer.print_stats.info.current_layer == 0 and printer["gcode_macro RECOVER_EXTRUSION"].enable_offset and printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made < printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_count %} {action_respond_warning('Recover extrusion by offset %s' % printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made)} RECOVER_EXTRUSION_BY_OFFSET {% else %}