Added heater check

This commit is contained in:
Jaime van Kessel 2015-08-19 11:18:58 +02:00
parent d683a6b77b
commit f0a358d175
2 changed files with 56 additions and 9 deletions

View file

@ -341,6 +341,14 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
def isConnected(self): def isConnected(self):
return self._is_connected return self._is_connected
@pyqtSlot(int)
def heatupNozzle(self, temperature):
self._sendCommand("M104 S%s" % temperature)
@pyqtSlot(int)
def heatupBed(self, temperature):
self._sendCommand("M109 S%s" % temperature)
## Directly send the command, withouth checking connection state (eg; printing). ## Directly send the command, withouth checking connection state (eg; printing).
# \param cmd string with g-code # \param cmd string with g-code
def _sendCommand(self, cmd): def _sendCommand(self, cmd):
@ -458,6 +466,14 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
if line is None: if line is None:
break # None is only returned when something went wrong. Stop listening break # None is only returned when something went wrong. Stop listening
if time.time() > temperature_request_timeout:
if self._extruder_count > 0:
self._temperature_requested_extruder_index = (self._temperature_requested_extruder_index + 1) % self._extruder_count
self.sendCommand("M105 T%d" % (self._temperature_requested_extruder_index))
else:
self.sendCommand("M105")
temperature_request_timeout = time.time() + 5
if line.startswith(b"Error:"): if line.startswith(b"Error:"):
# Oh YEAH, consistency. # Oh YEAH, consistency.
# Marlin reports an MIN/MAX temp error as "Error:x\n: Extruder switched off. MAXTEMP triggered !\n" # Marlin reports an MIN/MAX temp error as "Error:x\n: Extruder switched off. MAXTEMP triggered !\n"
@ -487,14 +503,6 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
self._setEndstopState(tag,(b'H' in value or b'TRIGGERED' in value)) self._setEndstopState(tag,(b'H' in value or b'TRIGGERED' in value))
if self._is_printing: if self._is_printing:
if time.time() > temperature_request_timeout: # When printing, request temperature every 5 seconds.
if self._extruder_count > 0:
self._temperature_requested_extruder_index = (self._temperature_requested_extruder_index + 1) % self._extruder_count
self.sendCommand("M105 T%d" % (self._temperature_requested_extruder_index))
else:
self.sendCommand("M105")
temperature_request_timeout = time.time() + 5
if line == b"" and time.time() > ok_timeout: if line == b"" and time.time() > ok_timeout:
line = b"ok" # Force a timeout (basicly, send next command) line = b"ok" # Force a timeout (basicly, send next command)

View file

@ -16,6 +16,8 @@ Column
property bool x_min_pressed: false property bool x_min_pressed: false
property bool y_min_pressed: false property bool y_min_pressed: false
property bool z_min_pressed: false property bool z_min_pressed: false
property bool heater_works: false
property int extruder_target_temp: 0
Component.onCompleted: UM.USBPrinterManager.connectedPrinterList.getItem(0).printer.startPollEndstop() Component.onCompleted: UM.USBPrinterManager.connectedPrinterList.getItem(0).printer.startPollEndstop()
@ -64,6 +66,7 @@ Column
text: y_min_pressed ? qsTr("Works") : qsTr("Not checked") text: y_min_pressed ? qsTr("Works") : qsTr("Not checked")
} }
} }
Row Row
{ {
Label Label
@ -76,6 +79,34 @@ Column
} }
} }
Row
{
Label
{
text: qsTr("Nozzle temperature check: ")
}
Label
{
text: UM.USBPrinterManager.connectedPrinterList.getItem(0).printer.extruderTemperature
}
Button
{
text: "Start heating"
onClicked:
{
heater_status_label.text = qsTr("Checking")
UM.USBPrinterManager.connectedPrinterList.getItem(0).printer.heatupNozzle(190)
wizardPage.extruder_target_temp = 190
console.log((UM.USBPrinterManager.connectedPrinterList.getItem(0).printer.extruderTemperature < wizardPage.extruder_target_temp + 10))
}
}
Label
{
id: heater_status_label
text: qsTr("Not checked")
}
}
Connections Connections
{ {
@ -95,6 +126,14 @@ Column
z_min_pressed = true z_min_pressed = true
} }
} }
onExtruderTemperatureChanged:
{
if(UM.USBPrinterManager.connectedPrinterList.getItem(0).printer.extruderTemperature > wizardPage.extruder_target_temp - 10 && UM.USBPrinterManager.connectedPrinterList.getItem(0).printer.extruderTemperature < wizardPage.extruder_target_temp + 10)
{
heater_status_label.text = qsTr("Works")
UM.USBPrinterManager.connectedPrinterList.getItem(0).printer.heatupNozzle(0)
}
}
} }
ExclusiveGroup ExclusiveGroup