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 <ingo@donasch.net>
This commit is contained in:
Ingo Donasch 2025-05-31 19:06:44 +02:00 committed by GitHub
parent d25602e88d
commit 2dd73d0431
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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