Merge pull request #2334 from fieldOfView/feature_target_hotend_temperature

Show target hotend temperatures
This commit is contained in:
alekseisasin 2017-08-31 13:46:55 +02:00 committed by GitHub
commit 7c637029b6
2 changed files with 53 additions and 8 deletions

View file

@ -313,6 +313,18 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
self.targetBedTemperatureChanged.emit()
return True
## Updates the target hotend temperature from the printer, and emit a signal if it was changed.
#
# /param index The index of the hotend.
# /param temperature The new target temperature of the hotend.
# /return boolean, True if the temperature was changed, false if the new temperature has the same value as the already stored temperature
def _updateTargetHotendTemperature(self, index, temperature):
if self._target_hotend_temperatures[index] == temperature:
return False
self._target_hotend_temperatures[index] = temperature
self.targetHotendTemperaturesChanged.emit()
return True
def _stopCamera(self):
if self._camera_timer.isActive():
self._camera_timer.stop()
@ -535,8 +547,9 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
def _spliceJSONData(self):
# Check for hotend temperatures
for index in range(0, self._num_extruders):
temperature = self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["temperature"]["current"]
self._setHotendTemperature(index, temperature)
temperatures = self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["temperature"]
self._setHotendTemperature(index, temperatures["current"])
self._updateTargetHotendTemperature(index, temperatures["target"])
try:
material_id = self._json_printer_state["heads"][0]["extruders"][index]["active_material"]["guid"]
except KeyError:
@ -548,10 +561,9 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
hotend_id = ""
self._setHotendId(index, hotend_id)
bed_temperature = self._json_printer_state["bed"]["temperature"]["current"]
self._setBedTemperature(bed_temperature)
target_bed_temperature = self._json_printer_state["bed"]["temperature"]["target"]
self._updateTargetBedTemperature(target_bed_temperature)
bed_temperatures = self._json_printer_state["bed"]["temperature"]
self._setBedTemperature(bed_temperatures["current"])
self._updateTargetBedTemperature(bed_temperatures["target"])
head_x = self._json_printer_state["heads"][0]["position"]["x"]
head_y = self._json_printer_state["heads"][0]["position"]["y"]

View file

@ -94,13 +94,46 @@ Column
anchors.top: parent.top
anchors.margins: UM.Theme.getSize("default_margin").width
}
Text //Target temperature.
{
id: extruderTargetTemperature
text: (connectedPrinter != null && connectedPrinter.hotendIds[index] != null && connectedPrinter.targetHotendTemperatures[index] != null) ? Math.round(connectedPrinter.targetHotendTemperatures[index]) + "°C" : ""
font: UM.Theme.getFont("small")
color: UM.Theme.getColor("text_inactive")
anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("default_margin").width
anchors.bottom: extruderTemperature.bottom
MouseArea //For tooltip.
{
id: extruderTargetTemperatureTooltipArea
hoverEnabled: true
anchors.fill: parent
onHoveredChanged:
{
if (containsMouse)
{
base.showTooltip(
base,
{x: 0, y: extruderTargetTemperature.mapToItem(base, 0, -parent.height / 4).y},
catalog.i18nc("@tooltip", "The target temperature of the hotend. The hotend will heat up or cool down towards this temperature. If this is 0, the hotend heating is turned off.")
);
}
else
{
base.hideTooltip();
}
}
}
}
Text //Temperature indication.
{
id: extruderTemperature
text: (connectedPrinter != null && connectedPrinter.hotendIds[index] != null && connectedPrinter.hotendTemperatures[index] != null) ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : ""
color: UM.Theme.getColor("text")
font: UM.Theme.getFont("large")
anchors.right: parent.right
anchors.right: extruderTargetTemperature.left
anchors.top: parent.top
anchors.margins: UM.Theme.getSize("default_margin").width
@ -116,7 +149,7 @@ Column
base.showTooltip(
base,
{x: 0, y: parent.mapToItem(base, 0, -parent.height / 4).y},
catalog.i18nc("@tooltip", "The current temperature of this extruder.")
catalog.i18nc("@tooltip", "The current temperature of this hotend.")
);
}
else