toolhead: Report the current extruder from the get_status() method

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-11-24 19:02:49 -05:00
parent 982567a69a
commit 282af0220e
3 changed files with 12 additions and 2 deletions

View File

@ -142,8 +142,9 @@ The following are common printer attributes:
- `printer["gcode_macro <macro_name>"].<variable>`: The current value - `printer["gcode_macro <macro_name>"].<variable>`: The current value
of a gcode_macro variable. of a gcode_macro variable.
- `printer.<heater>.temperature`: The last reported temperature (in - `printer.<heater>.temperature`: The last reported temperature (in
Celsius as a float) for the given heater. Available heaters are: Celsius as a float) for the given heater. Example heaters are:
`heater_bed` and `heater_generic <config_name>`. `extruder`, `extruder1`, `heater_bed`, `heater_generic
<config_name>`.
- `printer.<heater>.target`: The current target temperature (in - `printer.<heater>.target`: The current target temperature (in
Celsius as a float) for the given heater. Celsius as a float) for the given heater.
- `printer.pause_resume.is_paused`: Returns true if a PAUSE command - `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 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 file. It is possible to access the x, y, z, and e components of this
position (eg, `printer.toolhead.position.x`). 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 The above list is subject to change - if using an attribute be sure to
review the [Config Changes document](Config_Changes.md) when upgrading review the [Config Changes document](Config_Changes.md) when upgrading

View File

@ -93,6 +93,8 @@ class PrinterExtruder:
return dict(self.get_heater().get_status(eventtime), return dict(self.get_heater().get_status(eventtime),
pressure_advance=self.pressure_advance, pressure_advance=self.pressure_advance,
smooth_time=self.pressure_advance_smooth_time) smooth_time=self.pressure_advance_smooth_time)
def get_name(self):
return self.name
def get_heater(self): def get_heater(self):
return self.heater return self.heater
def set_active(self, print_time, is_active): def set_active(self, print_time, is_active):
@ -181,6 +183,8 @@ class DummyExtruder:
move.end_pos, "Extrude when no extruder present") move.end_pos, "Extrude when no extruder present")
def calc_junction(self, prev_move, move): def calc_junction(self, prev_move, move):
return move.max_cruise_v2 return move.max_cruise_v2
def get_name(self):
return ""
def get_heater(self): def get_heater(self):
raise homing.CommandError("Extruder not configured") raise homing.CommandError("Extruder not configured")

View File

@ -484,6 +484,7 @@ class ToolHead:
status = "Ready" status = "Ready"
return { 'status': status, 'print_time': print_time, return { 'status': status, 'print_time': print_time,
'estimated_print_time': estimated_print_time, 'estimated_print_time': estimated_print_time,
'extruder': self.extruder.get_name(),
'position': homing.Coord(*self.commanded_pos), 'position': homing.Coord(*self.commanded_pos),
'printing_time': print_time - last_print_start_time } 'printing_time': print_time - last_print_start_time }
def _handle_shutdown(self): def _handle_shutdown(self):