diff --git a/docs/Command_Templates.md b/docs/Command_Templates.md index 14decf24..07026093 100644 --- a/docs/Command_Templates.md +++ b/docs/Command_Templates.md @@ -142,8 +142,9 @@ The following are common printer attributes: - `printer["gcode_macro "].`: The current value of a gcode_macro variable. - `printer..temperature`: The last reported temperature (in - Celsius as a float) for the given heater. Available heaters are: - `heater_bed` and `heater_generic `. + Celsius as a float) for the given heater. Example heaters are: + `extruder`, `extruder1`, `heater_bed`, `heater_generic + `. - `printer..target`: The current target temperature (in Celsius as a float) for the given heater. - `printer.pause_resume.is_paused`: Returns true if a PAUSE command @@ -152,6 +153,10 @@ The following are common printer attributes: toolhead relative to the coordinate system specified in the config file. It is possible to access the x, y, z, and e components of this position (eg, `printer.toolhead.position.x`). +- `printer.toolhead.extruder`: The name of the currently active + extruder. For example, one could use + `printer[printer.toolhead.extruder].target` to get the target + temperature of the current extruder. The above list is subject to change - if using an attribute be sure to review the [Config Changes document](Config_Changes.md) when upgrading diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py index 611e99ad..e5883df2 100644 --- a/klippy/kinematics/extruder.py +++ b/klippy/kinematics/extruder.py @@ -93,6 +93,8 @@ class PrinterExtruder: return dict(self.get_heater().get_status(eventtime), pressure_advance=self.pressure_advance, smooth_time=self.pressure_advance_smooth_time) + def get_name(self): + return self.name def get_heater(self): return self.heater def set_active(self, print_time, is_active): @@ -181,6 +183,8 @@ class DummyExtruder: move.end_pos, "Extrude when no extruder present") def calc_junction(self, prev_move, move): return move.max_cruise_v2 + def get_name(self): + return "" def get_heater(self): raise homing.CommandError("Extruder not configured") diff --git a/klippy/toolhead.py b/klippy/toolhead.py index 7f1731f9..55f1bb36 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -484,6 +484,7 @@ class ToolHead: status = "Ready" return { 'status': status, 'print_time': print_time, 'estimated_print_time': estimated_print_time, + 'extruder': self.extruder.get_name(), 'position': homing.Coord(*self.commanded_pos), 'printing_time': print_time - last_print_start_time } def _handle_shutdown(self):