From 2dd73d0431a2e6a0a88d5ebd95ffa870b1b45831 Mon Sep 17 00:00:00 2001 From: Ingo Donasch Date: Sat, 31 May 2025 19:06:44 +0200 Subject: print_stats: Fix for filament statistics bug in print_stats.py for toolchangers (#6946) added extruder:activate_extruder event hook to print_stats.py to update self.last_epos Signed-off-by: Ingo Donasch --- klippy/extras/print_stats.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'klippy') diff --git a/klippy/extras/print_stats.py b/klippy/extras/print_stats.py index 668cd7d0..2eb7a01e 100644 --- a/klippy/extras/print_stats.py +++ b/klippy/extras/print_stats.py @@ -15,6 +15,11 @@ class PrintStats: self.gcode.register_command( "SET_PRINT_STATS_INFO", self.cmd_SET_PRINT_STATS_INFO, desc=self.cmd_SET_PRINT_STATS_INFO_help) + printer.register_event_handler("extruder:activate_extruder", + self._handle_activate_extruder) + def _handle_activate_extruder(self): + gc_status = self.gcode_move.get_status() + self.last_epos = gc_status['position'].e def _update_filament_usage(self, eventtime): gc_status = self.gcode_move.get_status(eventtime) cur_epos = gc_status['position'].e -- cgit v1.2.3-70-g09d2