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
of a gcode_macro variable.
- `printer.<heater>.temperature`: The last reported temperature (in
Celsius as a float) for the given heater. Available heaters are:
`heater_bed` and `heater_generic <config_name>`.
Celsius as a float) for the given heater. Example heaters are:
`extruder`, `extruder1`, `heater_bed`, `heater_generic
<config_name>`.
- `printer.<heater>.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

View File

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

View File

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