def OnHeatRun(self): self.heatButton.Enable(False) self.extrudeButton.Enable(False) self.comm = machineCom.MachineCom() if not self.comm.isOpen(): wx.MessageBox( "Error: Failed to open serial port to machine\nIf this keeps happening, try disconnecting and reconnecting the USB cable", 'Printer error', wx.OK | wx.ICON_INFORMATION) self.heatButton.Enable(True) self.extrudeButton.Enable(True) return while True: line = self.comm.readline() if line == '': self.heatButton.Enable(True) self.extrudeButton.Enable(True) return if 'start' in line: break #Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found. time.sleep(3) self.sendGCommand( 'M104 S200' ) #Set the temperature to 200C, should be enough to get PLA and ABS out. wx.MessageBox( 'Wait till you can remove the filament from the machine, and press OK.\n(Temperature is set to 200C)', 'Machine heatup', wx.OK | wx.ICON_INFORMATION) self.sendGCommand('M104 S0') time.sleep(1) self.comm.close() self.heatButton.Enable(True) self.extrudeButton.Enable(True)
def OnExtrudeRun(self): self.heatButton.Enable(False) self.extrudeButton.Enable(False) currentEValue = float(self.stepsPerEInput.GetValue()) self.comm = machineCom.MachineCom() if not self.comm.isOpen(): wx.MessageBox( "Error: Failed to open serial port to machine\nIf this keeps happening, try disconnecting and reconnecting the USB cable", 'Printer error', wx.OK | wx.ICON_INFORMATION) self.heatButton.Enable(True) self.extrudeButton.Enable(True) return while True: line = self.comm.readline() if line == '': return if 'start' in line: break #Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found. time.sleep(3) self.sendGCommand('M302') #Disable cold extrusion protection self.sendGCommand("M92 E%f" % (currentEValue)) self.sendGCommand("G92 E0") self.sendGCommand("G1 E100 F600") time.sleep(15) self.comm.close() self.extrudeButton.Enable() self.heatButton.Enable()
def OnCheckClick(self, e): if self.comm != None: self.comm.close() del self.comm self.infoBox.SetInfo('Connecting to machine.') self.infoBox.SetBusyIndicator() self.commState.SetBitmap(self.unknownBitmap) self.tempState.SetBitmap(self.unknownBitmap) self.stopState.SetBitmap(self.unknownBitmap) self.checkupState = 0 self.comm = machineCom.MachineCom(callbackObject=self)
def OnConnect(self, e): if self.machineCom != None: self.machineCom.close() self.machineCom = machineCom.MachineCom(callbackObject=self) self.UpdateButtonStates()
def OnRun(self): wx.CallAfter(self.AddProgressText, "Connecting to machine...") self.comm = machineCom.MachineCom() if not self.comm.isOpen(): wx.CallAfter(self.AddProgressText, "Error: Failed to open serial port to machine") wx.CallAfter( self.AddProgressText, "If this keeps happening, try disconnecting and reconnecting the USB cable" ) return wx.CallAfter(self.AddProgressText, "Checking start message...") if self.DoCommCommandWithTimeout(None, 'start') == False: wx.CallAfter(self.AddProgressText, "Error: Missing start message.") self.comm.close() return #Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found. time.sleep(3) wx.CallAfter(self.AddProgressText, "Disabling step motors...") if self.DoCommCommandWithTimeout('M84') == False: wx.CallAfter(self.AddProgressText, "Error: Missing reply to Deactivate steppers (M84).") self.comm.close() return if self.DoCommCommandWithTimeout("M104 S0") == False: wx.CallAfter(self.AddProgressText, "Failed to set temperature") self.comm.close() return wx.MessageBox( 'Please move the printer head to the center of the machine\nalso move the platform so it is not at the highest or lowest position,\nand make sure the machine is powered on.', 'Machine check', wx.OK | wx.ICON_INFORMATION) idleTemp = self.readTemp() if idleTemp > 40: wx.CallAfter( self.AddProgressText, "Waiting for head to cool down before temperature test...") while idleTemp > 40: idleTemp = self.readTemp() time.sleep(1) wx.CallAfter(self.AddProgressText, "Checking heater and temperature sensor...") wx.CallAfter(self.AddProgressText, "(This takes about 30 seconds)") if self.DoCommCommandWithTimeout("M104 S100") == False: wx.CallAfter(self.AddProgressText, "Failed to set temperature") self.comm.close() return time.sleep(25) tempInc = self.readTemp() - idleTemp if self.DoCommCommandWithTimeout("M104 S0") == False: wx.CallAfter(self.AddProgressText, "Failed to set temperature") self.comm.close() return if tempInc < 15: wx.CallAfter(self.AddProgressText, "Your temperature sensor or heater is not working!") self.comm.close() return wx.CallAfter( self.AddProgressText, "Heater and temperature sensor working\nWarning: head might still be hot!" ) wx.CallAfter(self.AddProgressText, "Checking endstops") if self.DoCommCommandWithTimeout( 'M119', 'x_min') != "x_min:L x_max:L y_min:L y_max:L z_min:L z_max:L": wx.CallAfter( self.AddProgressText, "Error: There is a problem in your endstops!\nOne of them seems to be pressed while it shouldn't\ncheck the cable connections and the switches themselfs." ) self.comm.close() return wx.CallAfter( self.AddProgressText, "Please press the X end switch in the front left corner.") if not self.DoCommCommandAndWaitForReply( 'M119', 'x_min', "x_min:H x_max:L y_min:L y_max:L z_min:L z_max:L"): wx.CallAfter(self.AddProgressText, "Failed to check the x_min endstop!") self.comm.close() return wx.CallAfter( self.AddProgressText, "Please press the X end switch in the front right corner.") if not self.DoCommCommandAndWaitForReply( 'M119', 'x_min', "x_min:L x_max:H y_min:L y_max:L z_min:L z_max:L"): wx.CallAfter(self.AddProgressText, "Failed to check the x_max endstop!") self.comm.close() return wx.CallAfter( self.AddProgressText, "Please press the Y end switch in the front left corner.") if not self.DoCommCommandAndWaitForReply( 'M119', 'x_min', "x_min:L x_max:L y_min:H y_max:L z_min:L z_max:L"): wx.CallAfter(self.AddProgressText, "Failed to check the x_max endstop!") self.comm.close() return wx.CallAfter(self.AddProgressText, "Please press the Y end switch in the back left corner.") if not self.DoCommCommandAndWaitForReply( 'M119', 'x_min', "x_min:L x_max:L y_min:L y_max:H z_min:L z_max:L"): wx.CallAfter(self.AddProgressText, "Failed to check the x_max endstop!") self.comm.close() return wx.CallAfter(self.AddProgressText, "Please press the Z end switch in the top.") if not self.DoCommCommandAndWaitForReply( 'M119', 'x_min', "x_min:L x_max:L y_min:L y_max:L z_min:H z_max:L"): wx.CallAfter(self.AddProgressText, "Failed to check the x_max endstop!") self.comm.close() return wx.CallAfter(self.AddProgressText, "Please press the Z end switch in the bottom.") if not self.DoCommCommandAndWaitForReply( 'M119', 'x_min', "x_min:L x_max:L y_min:L y_max:L z_min:L z_max:H"): wx.CallAfter(self.AddProgressText, "Failed to check the x_max endstop!") self.comm.close() return wx.CallAfter(self.AddProgressText, "End stops are working.") wx.CallAfter(self.AddProgressText, "Done!") wx.CallAfter(self.GetParent().FindWindowById(wx.ID_FORWARD).Enable) self.comm.close()