diff --git a/Changelog b/Changelog index 9921e8e..263bf29 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,13 @@ Changelog: +V0.30 March 16, 2016 + + * Fixed compatibility with OctoPrint V1.2.10 + * Fixes issue with dialog system + * Made pausing/resuming/canceling a print more reliable when line numbers above 65535 are being sent + * Prevents unhandled firmware and communication errors from being displayed + * Fixed issue where printer would hang when a command with a line number greater than 65535 isn't sucessfully sent to the printer + V0.29 March 11, 2016 * Added raft/brim to model editor diff --git a/installers/Linux/install.zip b/installers/Linux/install.zip index 8f97c5f..c287b1e 100644 Binary files a/installers/Linux/install.zip and b/installers/Linux/install.zip differ diff --git a/installers/OS X/install.sh b/installers/OS X/install.sh index 9cefeb9..39ae430 100644 --- a/installers/OS X/install.sh +++ b/installers/OS X/install.sh @@ -116,7 +116,7 @@ else # Get OctoPrint parameter octoPrintVersion="$(/Users/$SUDO_USER/Library/Python/2.7/bin/octoprint --version | cut -d' ' -f3)" - if [ $octoPrintVersion = "1.2.8" ] || [ $octoPrintVersion = "1.2.9" ]; then + if [ $octoPrintVersion = "1.2.8" ] || [ $octoPrintVersion = "1.2.9" ] || [ $octoPrintVersion = "1.2.10" ] || [ $octoPrintVersion = "1.2.11" ]; then octoPrintParameter="" else octoPrintParameter="serve<\/string>" diff --git a/installers/Windows/install.zip b/installers/Windows/install.zip index 71785ff..1cf7959 100644 Binary files a/installers/Windows/install.zip and b/installers/Windows/install.zip differ diff --git a/octoprint_m3dfio/__init__.py b/octoprint_m3dfio/__init__.py old mode 100644 new mode 100755 index a2ca533..21649ed --- a/octoprint_m3dfio/__init__.py +++ b/octoprint_m3dfio/__init__.py @@ -46,23 +46,8 @@ from .gcode import Gcode from .vector import Vector -# Check if using OS X -if platform.uname()[0].startswith("Darwin") : - - # Import OS X frameworks - try : - import CoreFoundation - import objc - from AppKit import * - from PyObjCTools import AppHelper - from Quartz import * - import QTKit - - except ImportError : - pass - -# Otherwise -else : +# Check if using Windows or Linux +if platform.uname()[0].startswith("Windows") or platform.uname()[0].startswith("Linux") : # Import webcam libraries try : @@ -72,17 +57,32 @@ except ImportError : pass + + # Check if using Linux + if platform.uname()[0].startswith("Linux") : -# Check if using Linux -if platform.uname()[0].startswith("Linux") : + # Import DBus + try : + import dbus + + except ImportError : + pass + +# Otherwise check if using OS X +elif platform.uname()[0].startswith("Darwin") : - # Import DBus + # Import OS X frameworks try : - import dbus + import CoreFoundation + import objc + from AppKit import * + from PyObjCTools import AppHelper + from Quartz import * + import QTKit except ImportError : pass - + # Command class class Command(object) : @@ -115,7 +115,7 @@ def __init__(self) : self.originalWrite = None self.originalRead = None self.invalidPrinter = True - self.waiting = False + self.waitingUntilCommandsSent = False self.processingSlice = False self.heatbedConnection = None self.heatbedConnected = False @@ -1188,7 +1188,7 @@ def get_settings_defaults(self) : GpioPin = None, GpioLayer = None, HeatbedTemperature = 70, - HeatbedHeight = 10.0, + ExternalBedHeight = 0, HostCamera = False, CameraPort = None, CameraWidth = 640, @@ -1300,9 +1300,9 @@ def on_api_command(self, command, data) : else : noLineNumber = False - # Set waiting if last command is to wait + # Set waiting until commands sent if last command is to wait if data["value"][-1] == "M65536;wait" : - self.waiting = True + self.waitingUntilCommandsSent = True # Check if not using line numbers or printing if noLineNumber or self._printer.is_printing() : @@ -1550,7 +1550,7 @@ def on_api_command(self, command, data) : if self._settings.get_int(["GpioLayer"]) is not None : self.sharedLibrary.setGpioLayer(ctypes.c_ushort(self._settings.get_int(["GpioLayer"]))) self.sharedLibrary.setHeatbedTemperature(ctypes.c_ushort(self._settings.get_int(["HeatbedTemperature"]))) - self.sharedLibrary.setHeatbedHeight(ctypes.c_double(self._settings.get_float(["HeatbedHeight"]))) + self.sharedLibrary.setExternalBedHeight(ctypes.c_double(self._settings.get_float(["ExternalBedHeight"]))) self.sharedLibrary.setMidPrintFilamentChangeLayers(ctypes.c_char_p(' '.join(re.findall("\\d+", str(self._settings.get(["MidPrintFilamentChangeLayers"])))))) # Collect print information @@ -1606,11 +1606,19 @@ def on_api_command(self, command, data) : if platform.uname()[0].startswith("Windows") : destination = destination.replace('/', '\\') + # Empty command queue + self.emptyCommandQueue() + # Set first line number to zero and clear history if self._printer._comm is not None : self._printer._comm._gcode_M110_sending("N0") self._printer._comm._long_running_command = True + # Clear sent commands + self.sentCommands = {} + self.resetLineNumberCommandSent = False + self.numberWrapCounter = 0 + # Print test border self._printer.select_file(destination, False, True) @@ -1872,7 +1880,8 @@ def on_api_command(self, command, data) : SpeedLimitY = self._settings.get_float(["SpeedLimitY"]), SpeedLimitZ = self._settings.get_float(["SpeedLimitZ"]), SpeedLimitEPositive = self._settings.get_float(["SpeedLimitEPositive"]), - SpeedLimitENegative = self._settings.get_float(["SpeedLimitENegative"]) + SpeedLimitENegative = self._settings.get_float(["SpeedLimitENegative"]), + ExternalBedHeight = self._settings.get_float(["ExternalBedHeight"]) ) # Set file's destination @@ -2003,6 +2012,9 @@ def on_api_command(self, command, data) : if "SpeedLimitENegative" in printerSettings : self._settings.set_float(["SpeedLimitENegative"], float(printerSettings["SpeedLimitENegative"])) + if "ExternalBedHeight" in printerSettings : + self._settings.set_float(["ExternalBedHeight"], float(printerSettings["ExternalBedHeight"])) + # Check if a Micro 3D is connected and not printing if not self.invalidPrinter and not self._printer.is_printing() : @@ -2230,17 +2242,28 @@ def on_api_command(self, command, data) : # Otherwise check if parameter is emergency stop elif data["value"] == "Emergency Stop" : - # Empty command queue - self.emptyCommandQueue() - # Check if printing or paused if self._printer.is_printing() or self._printer.is_paused() : # Stop printing self._printer.cancel_print() + # Empty command queue + self.emptyCommandQueue() + + # Set first line number to zero and clear history + if self._printer._comm is not None : + self._printer._comm._gcode_M110_sending("N0") + self._printer._comm._long_running_command = True + + # Clear sent commands + self.sentCommands = {} + self.resetLineNumberCommandSent = False + self.numberWrapCounter = 0 + # Send emergency stop immediately to the printer - self._printer.get_transport().write("M0") + if isinstance(self._printer.get_transport(), serial.Serial) : + self._printer.get_transport().write("M0") # Otherwise check if parameter is ping elif data["value"] == "Ping" : @@ -2300,10 +2323,18 @@ def on_api_command(self, command, data) : # Otherwise check if parameter is starting print elif data["value"] == "Starting Print" : + # Empty command queue + self.emptyCommandQueue() + # Set first line number to zero and clear history if self._printer._comm is not None : self._printer._comm._gcode_M110_sending("N0") self._printer._comm._long_running_command = True + + # Clear sent commands + self.sentCommands = {} + self.resetLineNumberCommandSent = False + self.numberWrapCounter = 0 # Otherwise check if command is a file elif command == "file" : @@ -2881,16 +2912,35 @@ def sendCommands(self, commands) : command = self._printer._comm._send_queue.get() commands += [(command[0], command[2])] - while not self._printer._comm._commandQueue.empty() : - command = self._printer._comm._commandQueue.get() - commands += [(command[0], command[1])] + # Check if deprecated queue name is valid + if hasattr(self._printer._comm, "_commandQueue") : - # Insert list into queue - for command in commands : - if isinstance(command, tuple) : - self._printer._comm._commandQueue.put(command) - else : - self._printer._comm._commandQueue.put((command, None)) + # Append all currently queued commands to list + while not self._printer._comm._commandQueue.empty() : + command = self._printer._comm._commandQueue.get() + commands += [(command[0], command[1])] + + # Insert list into queue + for command in commands : + if isinstance(command, tuple) : + self._printer._comm._commandQueue.put(command) + else : + self._printer._comm._commandQueue.put((command, None)) + + # Otherwise + else : + + # Append all currently queued commands to list + while not self._printer._comm._command_queue.empty() : + command = self._printer._comm._command_queue.get() + commands += [(command[0], command[1])] + + # Insert list into queue + for command in commands : + if isinstance(command, tuple) : + self._printer._comm._command_queue.put(command) + else : + self._printer._comm._command_queue.put((command, None)) # Otherwise else : @@ -2932,9 +2982,20 @@ def emptyCommandQueue(self) : # Empty command queues while not self._printer._comm._send_queue.empty() : self._printer._comm._send_queue.get() - - while not self._printer._comm._commandQueue.empty() : - self._printer._comm._commandQueue.get() + + # Check if deprecated queue name is valid + if hasattr(self._printer._comm, "_commandQueue") : + + # Empty command queues + while not self._printer._comm._commandQueue.empty() : + self._printer._comm._commandQueue.get() + + # Otherwise + else : + + # Empty command queues + while not self._printer._comm._command_queue.empty() : + self._printer._comm._command_queue.get() # Process write def processWrite(self, data) : @@ -2966,18 +3027,25 @@ def processWrite(self, data) : # Check if request is hard emergency stop if "M0" in data : - - # Empty command queue - self.emptyCommandQueue() - - # Clear sent commands - self.sentCommands = {} # Check if printing or paused if self._printer.is_printing() or self._printer.is_paused() : # Stop printing self._printer.cancel_print() + + # Empty command queue + self.emptyCommandQueue() + + # Set first line number to zero and clear history + if self._printer._comm is not None : + self._printer._comm._gcode_M110_sending("N0") + self._printer._comm._long_running_command = True + + # Clear sent commands + self.sentCommands = {} + self.resetLineNumberCommandSent = False + self.numberWrapCounter = 0 # Otherwise check if request is soft emergency stop elif "M65537" in data : @@ -3002,13 +3070,26 @@ def processWrite(self, data) : # Stop printing self._printer.cancel_print() + + # Empty command queue + self.emptyCommandQueue() + + # Set first line number to zero and clear history + if self._printer._comm is not None : + self._printer._comm._gcode_M110_sending("N0") + self._printer._comm._long_running_command = True + + # Clear sent commands + self.sentCommands = {} + self.resetLineNumberCommandSent = False + self.numberWrapCounter = 0 - # Check if request ends waiting + # Check if request ends waiting for commands sent if "M65536" in data : # Set to wait for a wait response - if self.waiting : - self.waiting = None + if self.waitingUntilCommandsSent : + self.waitingUntilCommandsSent = None # Send fake acknowledgment self._printer.fake_ack() @@ -3138,7 +3219,7 @@ def processWrite(self, data) : command = "T:0.0 B:" + heatbedTemperature self._printer._comm._processTemperatures(command) - self._printer._comm._callback.on_comm_temperature_update(self._printer._comm._temp, self._printer._comm._bedTemp) + self._printer._comm._callback.on_comm_temperature_update(self._printer._comm.getTemp(), self._printer._comm.getBedTemp()) self._printer._addLog("Recv: " + command) # Update communication timeout to prevent other commands from being sent @@ -3199,6 +3280,19 @@ def processWrite(self, data) : # Pause print if self._printer._comm is not None : self._printer._comm.setPause(True) + + # Empty command queue + self.emptyCommandQueue() + + # Set first line number to zero and clear history + if self._printer._comm is not None : + self._printer._comm._gcode_M110_sending("N0") + self._printer._comm._long_running_command = True + + # Clear sent commands + self.sentCommands = {} + self.resetLineNumberCommandSent = False + self.numberWrapCounter = 0 # Set command to nothing gcode.removeParameter('M') @@ -3210,6 +3304,19 @@ def processWrite(self, data) : # Check if paused if self._printer.is_paused() : + # Empty command queue + self.emptyCommandQueue() + + # Set first line number to zero and clear history + if self._printer._comm is not None : + self._printer._comm._gcode_M110_sending("N0") + self._printer._comm._long_running_command = True + + # Clear sent commands + self.sentCommands = {} + self.resetLineNumberCommandSent = False + self.numberWrapCounter = 0 + # Resume print if self._printer._comm is not None : self._printer._comm.setPause(False) @@ -3218,6 +3325,7 @@ def processWrite(self, data) : self.sendCommands(["N0 M110", "G90"]) if self._printer._comm is not None : self._printer._comm._gcode_M110_sending("N1") + self._printer._comm._long_running_command = True # Set command to nothing gcode.removeParameter('M') @@ -3331,16 +3439,16 @@ def processRead(self) : self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Duplicate Wait")) # Check if waiting for a wait response - if self.waiting is None : + if self.waitingUntilCommandsSent is None : - # Clear waiting - self.waiting = False + # Clear waiting until commands sent + self.waitingUntilCommandsSent = False # Send message self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Done Waiting")) # Check if waiting for a command to be processed - if self.lastLineNumberSent in self.sentCommands : + if self.lastLineNumberSent is not None and self.lastLineNumberSent % 0x10000 in self.sentCommands : # Set response to resending command response = "rs " + str(self.lastLineNumberSent) + '\n' @@ -3635,8 +3743,8 @@ def on_event(self, event, payload) : # Hide shared library options self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Not Using Shared Library")) - # Check if EEPROM was read - if self.eeprom is not None : + # Check if EEPROM was read and connection to the printer has been established + if self.eeprom is not None and isinstance(self._printer.get_transport(), serial.Serial) : # Send eeprom self._plugin_manager.send_plugin_message(self._identifier, dict(value = "EEPROM", eeprom = self.eeprom.encode("hex").upper())) @@ -3824,7 +3932,7 @@ def on_event(self, event, payload) : if self._settings.get_int(["GpioLayer"]) is not None : self.sharedLibrary.setGpioLayer(ctypes.c_ushort(self._settings.get_int(["GpioLayer"]))) self.sharedLibrary.setHeatbedTemperature(ctypes.c_ushort(self._settings.get_int(["HeatbedTemperature"]))) - self.sharedLibrary.setHeatbedHeight(ctypes.c_double(self._settings.get_float(["HeatbedHeight"]))) + self.sharedLibrary.setExternalBedHeight(ctypes.c_double(self._settings.get_float(["ExternalBedHeight"]))) self.sharedLibrary.setMidPrintFilamentChangeLayers(ctypes.c_char_p(' '.join(re.findall("\\d+", str(self._settings.get(["MidPrintFilamentChangeLayers"])))))) # Collect print information @@ -3912,16 +4020,18 @@ def on_event(self, event, payload) : # Otherwise check if a print is done elif event == octoprint.events.Events.PRINT_DONE : + # Empty command queue + self.emptyCommandQueue() + # Set first line number to zero and clear history if self._printer._comm is not None : self._printer._comm._gcode_M110_sending("N0") self._printer._comm._long_running_command = True - - # Empty command queue - self.emptyCommandQueue() # Clear sent commands self.sentCommands = {} + self.resetLineNumberCommandSent = False + self.numberWrapCounter = 0 # Check if pre-processing on the fly if self._settings.get_boolean(["PreprocessOnTheFly"]) : @@ -3953,16 +4063,18 @@ def on_event(self, event, payload) : # Otherwise check if a print failed elif event == octoprint.events.Events.PRINT_FAILED : + # Empty command queue + self.emptyCommandQueue() + # Set first line number to zero and clear history if self._printer._comm is not None : self._printer._comm._gcode_M110_sending("N0") self._printer._comm._long_running_command = True - - # Empty command queue - self.emptyCommandQueue() # Clear sent commands self.sentCommands = {} + self.resetLineNumberCommandSent = False + self.numberWrapCounter = 0 # Set commands commands = [ @@ -4083,310 +4195,291 @@ def on_printer_add_log(self, data) : pass self._printer.disconnect() - - # Connect to the printer - connection = serial.Serial(currentPort, currentBaudrate) - # Attempt to get current printer mode - try : - connection.write("M115") - bootloaderVersion = connection.read() + # Check if printer wasn't found + if currentPort is None : - if float(serial.VERSION) < 3 : - bootloaderVersion += connection.read(connection.inWaiting()) - else : - bootloaderVersion += connection.read(connection.in_waiting) + # Send message + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Show Message", message = "No Micro 3D printer detected. Try cycling the printer's power and try again.", confirm = True)) - # Check if an error occured - except serial.SerialException : + # Otherwise + else : - # Set error - error = True + # Connect to the printer + connection = serial.Serial(currentPort, currentBaudrate) - # Check if no errors occured - if not error : + # Attempt to get current printer mode + try : + connection.write("M115") + bootloaderVersion = connection.read() + + if float(serial.VERSION) < 3 : + bootloaderVersion += connection.read(connection.inWaiting()) + else : + bootloaderVersion += connection.read(connection.in_waiting) - # Check if not in bootloader mode - if not bootloaderVersion.startswith('B') : + # Check if an error occured + except serial.SerialException : - # Save ports - self.savePorts(currentPort) + # Set error + error = True + + # Check if no errors occured + if not error : + + # Check if not in bootloader mode + if not bootloaderVersion.startswith('B') : + + # Save ports + self.savePorts(currentPort) - # Switch to bootloader mode - connection.write("M115 S628") + # Switch to bootloader mode + connection.write("M115 S628") - try : - gcode = Gcode("M115 S628") - connection.write(gcode.getBinary()) + try : + gcode = Gcode("M115 S628") + connection.write(gcode.getBinary()) - # Check if an error occured - except serial.SerialException : - pass + # Check if an error occured + except serial.SerialException : + pass - time.sleep(1) + time.sleep(1) - # Close connection - connection.close() + # Close connection + connection.close() - # Set updated port - currentPort = self.getPort() + # Set updated port + currentPort = self.getPort() - # Check if printer wasn't found - if currentPort is None : + # Check if printer wasn't found + if currentPort is None : - # Send message - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Show Message", message = "No Micro 3D printer detected. Try cycling the printer's power and try again.", confirm = True)) + # Send message + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Show Message", message = "No Micro 3D printer detected. Try cycling the printer's power and try again.", confirm = True)) - # Set error - error = True + # Set error + error = True - # Otherwise - else : + # Otherwise + else : - # Re-connect; wait for the device to be available - connection = None - for i in xrange(5) : - try : - connection = serial.Serial(currentPort, currentBaudrate) - break + # Re-connect; wait for the device to be available + connection = None + for i in xrange(5) : + try : + connection = serial.Serial(currentPort, currentBaudrate) + break - except Exception : - connection = None - time.sleep(1) + except Exception : + connection = None + time.sleep(1) - # Check if using OS X or Linux and the user lacks read/write access to the printer - if (platform.uname()[0].startswith("Darwin") or platform.uname()[0].startswith("Linux")) and not os.access(currentPort, os.R_OK | os.W_OK) : + # Check if using OS X or Linux and the user lacks read/write access to the printer + if (platform.uname()[0].startswith("Darwin") or platform.uname()[0].startswith("Linux")) and not os.access(currentPort, os.R_OK | os.W_OK) : - # Send message - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Show Message", message = "You don't have read/write access to " + str(port), confirm = True)) + # Send message + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Show Message", message = "You don't have read/write access to " + str(port), confirm = True)) - # Set error - error = True + # Set error + error = True - # Otherwise check if connecting to printer failed - elif connection is None : + # Otherwise check if connecting to printer failed + elif connection is None : - # Send message - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Show Message", message = "No Micro 3D printer detected. Try cycling the printer's power and try again.", confirm = True)) + # Send message + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Show Message", message = "No Micro 3D printer detected. Try cycling the printer's power and try again.", confirm = True)) - # Set error - error = True + # Set error + error = True - # Check if an error hasn't occured and getting EEPROM was successful - if not error and self.getEeprom(connection) : + # Check if an error hasn't occured and getting EEPROM was successful + if not error and self.getEeprom(connection) : - # Get firmware CRC from EEPROM - index = 0 - eepromCrc = 0 - while index < 4 : - eepromCrc <<= 8 - eepromCrc += int(ord(self.eeprom[self.eepromOffsets["firmwareCrc"]["offset"] + index])) - index += 1 + # Get firmware CRC from EEPROM + index = 0 + eepromCrc = 0 + while index < 4 : + eepromCrc <<= 8 + eepromCrc += int(ord(self.eeprom[self.eepromOffsets["firmwareCrc"]["offset"] + index])) + index += 1 - # Request firmware CRC from chip - connection.write('C') - connection.write('A') + # Request firmware CRC from chip + connection.write('C') + connection.write('A') - # Get response - response = connection.read(4) + # Get response + response = connection.read(4) - # Get chip CRC - index = 0 - chipCrc = 0 - while index < 4 : - chipCrc <<= 8 - chipCrc += int(ord(response[index])) - index += 1 + # Get chip CRC + index = 0 + chipCrc = 0 + while index < 4 : + chipCrc <<= 8 + chipCrc += int(ord(response[index])) + index += 1 - # Get firmware details - firmwareName, firmwareVersion, firmwareRelease = self.getFirmwareDetails() - - # Get serial number from EEPROM - serialNumber = self.eeprom[self.eepromOffsets["serialNumber"]["offset"] : self.eepromOffsets["serialNumber"]["offset"] + self.eepromOffsets["serialNumber"]["bytes"] - 1] - - # Set printer color - color = serialNumber[0 : 2] - if color == "BK" : - self.printerColor = "Black" - self._settings.set(["PrinterColor"], "Black") - elif color == "WH" : - self.printerColor = "White" - self._settings.set(["PrinterColor"], "White") - elif color == "BL" : - self.printerColor = "Blue" - self._settings.set(["PrinterColor"], "Blue") - elif color == "GR" : - self.printerColor = "Green" - self._settings.set(["PrinterColor"], "Green") - elif color == "OR" : - self.printerColor = "Orange" - self._settings.set(["PrinterColor"], "Orange") - elif color == "CL" : - self.printerColor = "Clear" - self._settings.set(["PrinterColor"], "Clear") - elif color == "SL" : - self.printerColor = "Silver" - self._settings.set(["PrinterColor"], "Silver") - elif color == "PL" : - self.printerColor = "Purple" - self._settings.set(["PrinterColor"], "Purple") - - # Get fan type from EEPROM - fanType = int(ord(self.eeprom[self.eepromOffsets["fanType"]["offset"]])) - - # Check if fan hasn't been set yet - if fanType == 0 or fanType == 0xFF : - - # Check if device is newer - if int(serialNumber[2 : 8]) >= 150602 : - - # Set default newer fan - fanName = "Shenzhew" + # Get firmware details + firmwareName, firmwareVersion, firmwareRelease = self.getFirmwareDetails() + + # Get serial number from EEPROM + serialNumber = self.eeprom[self.eepromOffsets["serialNumber"]["offset"] : self.eepromOffsets["serialNumber"]["offset"] + self.eepromOffsets["serialNumber"]["bytes"] - 1] + + # Set printer color + color = serialNumber[0 : 2] + if color == "BK" : + self.printerColor = "Black" + self._settings.set(["PrinterColor"], "Black") + elif color == "WH" : + self.printerColor = "White" + self._settings.set(["PrinterColor"], "White") + elif color == "BL" : + self.printerColor = "Blue" + self._settings.set(["PrinterColor"], "Blue") + elif color == "GR" : + self.printerColor = "Green" + self._settings.set(["PrinterColor"], "Green") + elif color == "OR" : + self.printerColor = "Orange" + self._settings.set(["PrinterColor"], "Orange") + elif color == "CL" : + self.printerColor = "Clear" + self._settings.set(["PrinterColor"], "Clear") + elif color == "SL" : + self.printerColor = "Silver" + self._settings.set(["PrinterColor"], "Silver") + elif color == "PL" : + self.printerColor = "Purple" + self._settings.set(["PrinterColor"], "Purple") + + # Get fan type from EEPROM + fanType = int(ord(self.eeprom[self.eepromOffsets["fanType"]["offset"]])) + + # Check if fan hasn't been set yet + if fanType == 0 or fanType == 0xFF : + + # Check if device is newer + if int(serialNumber[2 : 8]) >= 150602 : + + # Set default newer fan + fanName = "Shenzhew" - # Otherwise - else : + # Otherwise + else : - # Set default older fan - fanName = "HengLiXin" + # Set default older fan + fanName = "HengLiXin" - # Check if setting fan failed - if not self.setFan(connection, fanName) : + # Check if setting fan failed + if not self.setFan(connection, fanName) : - # Set error - error = True + # Set error + error = True - # Check if an error occured - if error : + # Check if an error occured + if error : - # Display error - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Setting fan failed", confirm = True)) + # Display error + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Setting fan failed", confirm = True)) - # Otherwise - else : + # Otherwise + else : - # Set fan name - if fanType == 1 : - fanName = "HengLiXin" - elif fanType == 2 : - fanName = "Listener" - elif fanType == 3 : - fanName = "Shenzhew" - elif fanType == 4 : - fanName = "Xinyujie" + # Set fan name + if fanType == 1 : + fanName = "HengLiXin" + elif fanType == 2 : + fanName = "Listener" + elif fanType == 3 : + fanName = "Shenzhew" + elif fanType == 4 : + fanName = "Xinyujie" - # Check if updating fan failed - if not self.setFan(connection, fanName) : + # Check if updating fan failed + if not self.setFan(connection, fanName) : - # Set error - error = True + # Set error + error = True - # Display error - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating fan settings failed", confirm = True)) + # Display error + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating fan settings failed", confirm = True)) - # Check if printer uses 500mA extruder current - shortSerialNumber = serialNumber[0 : 13] - if not error and (shortSerialNumber == "BK15033001100" or shortSerialNumber == "BK15040201050" or shortSerialNumber == "BK15040301050" or shortSerialNumber == "BK15040602050" or shortSerialNumber == "BK15040801050" or shortSerialNumber == "BK15040802100" or shortSerialNumber == "GR15032702100" or shortSerialNumber == "GR15033101100" or shortSerialNumber == "GR15040601100" or shortSerialNumber == "GR15040701100" or shortSerialNumber == "OR15032701100" or shortSerialNumber == "SL15032601050") : + # Check if printer uses 500mA extruder current + shortSerialNumber = serialNumber[0 : 13] + if not error and (shortSerialNumber == "BK15033001100" or shortSerialNumber == "BK15040201050" or shortSerialNumber == "BK15040301050" or shortSerialNumber == "BK15040602050" or shortSerialNumber == "BK15040801050" or shortSerialNumber == "BK15040802100" or shortSerialNumber == "GR15032702100" or shortSerialNumber == "GR15033101100" or shortSerialNumber == "GR15040601100" or shortSerialNumber == "GR15040701100" or shortSerialNumber == "OR15032701100" or shortSerialNumber == "SL15032601050") : - # Check if setting extruder current failed - if not self.setExtruderCurrent(connection, 500) : + # Check if setting extruder current failed + if not self.setExtruderCurrent(connection, 500) : - # Set error - error = True + # Set error + error = True - # Display error - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating extruder current failed", confirm = True)) + # Display error + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating extruder current failed", confirm = True)) - # Check if using M3D firmware and it's from before new bed orientation and adjustable backlash speed - if not error and firmwareName is not None and firmwareName == "M3D" and firmwareVersion < 2015080402 : + # Check if using M3D firmware and it's from before new bed orientation and adjustable backlash speed + if not error and firmwareName is not None and firmwareName == "M3D" and firmwareVersion < 2015080402 : - # Go through bytes of bed offsets - index = 0 - while index < 19 : + # Go through bytes of bed offsets + index = 0 + while index < 19 : - # Check if zeroing out all bed offets in EEPROM failed - if not error and not self.writeToEeprom(connection, self.eepromOffsets["bedOffsetBackLeft"]["offset"] + index, '\x00') : + # Check if zeroing out all bed offets in EEPROM failed + if not error and not self.writeToEeprom(connection, self.eepromOffsets["bedOffsetBackLeft"]["offset"] + index, '\x00') : - # Set error - error = True + # Set error + error = True - # Increment index - index += 1 + # Increment index + index += 1 - # Check if an error hasn't occured - if not error : + # Check if an error hasn't occured + if not error : - # Convert default backlash speed to binary - packed = struct.pack('f', 1500) - backlashSpeed = ord(packed[0]) | (ord(packed[1]) << 8) | (ord(packed[2]) << 16) | (ord(packed[3]) << 24) + # Convert default backlash speed to binary + packed = struct.pack('f', 1500) + backlashSpeed = ord(packed[0]) | (ord(packed[1]) << 8) | (ord(packed[2]) << 16) | (ord(packed[3]) << 24) - # Go through bytes of backlash speed - index = 0 - while index < 4 : + # Go through bytes of backlash speed + index = 0 + while index < 4 : - # Check if saving backlash speed failed - if not error and not self.writeToEeprom(connection, self.eepromOffsets["backlashSpeed"]["offset"] + index, chr((backlashSpeed >> 8 * index) & 0xFF)) : + # Check if saving backlash speed failed + if not error and not self.writeToEeprom(connection, self.eepromOffsets["backlashSpeed"]["offset"] + index, chr((backlashSpeed >> 8 * index) & 0xFF)) : - # Set error - error = True + # Set error + error = True - # Increment index - index += 1 + # Increment index + index += 1 - # Check if an error has occured - if error : + # Check if an error has occured + if error : - # Display error - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating version changes failed", confirm = True)) - - # Check if an error hasn't occured - if not error : - - # Get speed limit X - data = [int(ord(self.eeprom[self.eepromOffsets["speedLimitX"]["offset"]])), int(ord(self.eeprom[self.eepromOffsets["speedLimitX"]["offset"] + 1])), int(ord(self.eeprom[self.eepromOffsets["speedLimitX"]["offset"] + 2])), int(ord(self.eeprom[self.eepromOffsets["speedLimitX"]["offset"] + 3]))] - bytes = struct.pack("4B", *data) - speedLimitX = round(struct.unpack('f', bytes)[0], 6) - - # Check if speed limit X is invalid - if math.isnan(speedLimitX) or speedLimitX < 120 or speedLimitX > 4800 : + # Display error + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating version changes failed", confirm = True)) - # Convert default speed limit X to binary - packed = struct.pack('f', 1500) - speedLimitX = ord(packed[0]) | (ord(packed[1]) << 8) | (ord(packed[2]) << 16) | (ord(packed[3]) << 24) - - # Go through bytes of speed limit X - index = 0 - while index < 4 : - - # Check if saving speed limit X failed - if not error and not self.writeToEeprom(connection, self.eepromOffsets["speedLimitX"]["offset"] + index, chr((speedLimitX >> 8 * index) & 0xFF)) : - - # Set error - error = True - - # Increment index - index += 1 - # Check if an error hasn't occured if not error : - - # Get speed limit Y - data = [int(ord(self.eeprom[self.eepromOffsets["speedLimitY"]["offset"]])), int(ord(self.eeprom[self.eepromOffsets["speedLimitY"]["offset"] + 1])), int(ord(self.eeprom[self.eepromOffsets["speedLimitY"]["offset"] + 2])), int(ord(self.eeprom[self.eepromOffsets["speedLimitY"]["offset"] + 3]))] + + # Get speed limit X + data = [int(ord(self.eeprom[self.eepromOffsets["speedLimitX"]["offset"]])), int(ord(self.eeprom[self.eepromOffsets["speedLimitX"]["offset"] + 1])), int(ord(self.eeprom[self.eepromOffsets["speedLimitX"]["offset"] + 2])), int(ord(self.eeprom[self.eepromOffsets["speedLimitX"]["offset"] + 3]))] bytes = struct.pack("4B", *data) - speedLimitY = round(struct.unpack('f', bytes)[0], 6) + speedLimitX = round(struct.unpack('f', bytes)[0], 6) - # Check if speed limit Y is invalid - if math.isnan(speedLimitY) or speedLimitY < 120 or speedLimitY > 4800 : + # Check if speed limit X is invalid + if math.isnan(speedLimitX) or speedLimitX < 120 or speedLimitX > 4800 : - # Convert default speed limit Y to binary + # Convert default speed limit X to binary packed = struct.pack('f', 1500) - speedLimitY = ord(packed[0]) | (ord(packed[1]) << 8) | (ord(packed[2]) << 16) | (ord(packed[3]) << 24) + speedLimitX = ord(packed[0]) | (ord(packed[1]) << 8) | (ord(packed[2]) << 16) | (ord(packed[3]) << 24) - # Go through bytes of speed limit Y + # Go through bytes of speed limit X index = 0 while index < 4 : - # Check if saving speed limit Y failed - if not error and not self.writeToEeprom(connection, self.eepromOffsets["speedLimitY"]["offset"] + index, chr((speedLimitY >> 8 * index) & 0xFF)) : + # Check if saving speed limit X failed + if not error and not self.writeToEeprom(connection, self.eepromOffsets["speedLimitX"]["offset"] + index, chr((speedLimitX >> 8 * index) & 0xFF)) : # Set error error = True @@ -4394,320 +4487,322 @@ def on_printer_add_log(self, data) : # Increment index index += 1 - # Check if an error hasn't occured - if not error : + # Check if an error hasn't occured + if not error : - # Get speed limit Z - data = [int(ord(self.eeprom[self.eepromOffsets["speedLimitZ"]["offset"]])), int(ord(self.eeprom[self.eepromOffsets["speedLimitZ"]["offset"] + 1])), int(ord(self.eeprom[self.eepromOffsets["speedLimitZ"]["offset"] + 2])), int(ord(self.eeprom[self.eepromOffsets["speedLimitZ"]["offset"] + 3]))] - bytes = struct.pack("4B", *data) - speedLimitZ = round(struct.unpack('f', bytes)[0], 6) + # Get speed limit Y + data = [int(ord(self.eeprom[self.eepromOffsets["speedLimitY"]["offset"]])), int(ord(self.eeprom[self.eepromOffsets["speedLimitY"]["offset"] + 1])), int(ord(self.eeprom[self.eepromOffsets["speedLimitY"]["offset"] + 2])), int(ord(self.eeprom[self.eepromOffsets["speedLimitY"]["offset"] + 3]))] + bytes = struct.pack("4B", *data) + speedLimitY = round(struct.unpack('f', bytes)[0], 6) + + # Check if speed limit Y is invalid + if math.isnan(speedLimitY) or speedLimitY < 120 or speedLimitY > 4800 : + + # Convert default speed limit Y to binary + packed = struct.pack('f', 1500) + speedLimitY = ord(packed[0]) | (ord(packed[1]) << 8) | (ord(packed[2]) << 16) | (ord(packed[3]) << 24) + + # Go through bytes of speed limit Y + index = 0 + while index < 4 : - # Check if speed limit Z is invalid - if math.isnan(speedLimitZ) or speedLimitZ < 30 or speedLimitZ > 60 : + # Check if saving speed limit Y failed + if not error and not self.writeToEeprom(connection, self.eepromOffsets["speedLimitY"]["offset"] + index, chr((speedLimitY >> 8 * index) & 0xFF)) : + + # Set error + error = True + + # Increment index + index += 1 + + # Check if an error hasn't occured + if not error : + + # Get speed limit Z + data = [int(ord(self.eeprom[self.eepromOffsets["speedLimitZ"]["offset"]])), int(ord(self.eeprom[self.eepromOffsets["speedLimitZ"]["offset"] + 1])), int(ord(self.eeprom[self.eepromOffsets["speedLimitZ"]["offset"] + 2])), int(ord(self.eeprom[self.eepromOffsets["speedLimitZ"]["offset"] + 3]))] + bytes = struct.pack("4B", *data) + speedLimitZ = round(struct.unpack('f', bytes)[0], 6) + + # Check if speed limit Z is invalid + if math.isnan(speedLimitZ) or speedLimitZ < 30 or speedLimitZ > 60 : - # Convert default speed limit Z to binary - packed = struct.pack('f', 60) - speedLimitZ = ord(packed[0]) | (ord(packed[1]) << 8) | (ord(packed[2]) << 16) | (ord(packed[3]) << 24) + # Convert default speed limit Z to binary + packed = struct.pack('f', 60) + speedLimitZ = ord(packed[0]) | (ord(packed[1]) << 8) | (ord(packed[2]) << 16) | (ord(packed[3]) << 24) - # Go through bytes of speed limit Z - index = 0 - while index < 4 : + # Go through bytes of speed limit Z + index = 0 + while index < 4 : - # Check if saving speed limit Z failed - if not error and not self.writeToEeprom(connection, self.eepromOffsets["speedLimitZ"]["offset"] + index, chr((speedLimitZ >> 8 * index) & 0xFF)) : + # Check if saving speed limit Z failed + if not error and not self.writeToEeprom(connection, self.eepromOffsets["speedLimitZ"]["offset"] + index, chr((speedLimitZ >> 8 * index) & 0xFF)) : - # Set error - error = True + # Set error + error = True - # Increment index - index += 1 + # Increment index + index += 1 - # Check if an error hasn't occured - if not error : + # Check if an error hasn't occured + if not error : - # Get speed limit E positive - data = [int(ord(self.eeprom[self.eepromOffsets["speedLimitEPositive"]["offset"]])), int(ord(self.eeprom[self.eepromOffsets["speedLimitEPositive"]["offset"] + 1])), int(ord(self.eeprom[self.eepromOffsets["speedLimitEPositive"]["offset"] + 2])), int(ord(self.eeprom[self.eepromOffsets["speedLimitEPositive"]["offset"] + 3]))] - bytes = struct.pack("4B", *data) - speedLimitEPositive = round(struct.unpack('f', bytes)[0], 6) + # Get speed limit E positive + data = [int(ord(self.eeprom[self.eepromOffsets["speedLimitEPositive"]["offset"]])), int(ord(self.eeprom[self.eepromOffsets["speedLimitEPositive"]["offset"] + 1])), int(ord(self.eeprom[self.eepromOffsets["speedLimitEPositive"]["offset"] + 2])), int(ord(self.eeprom[self.eepromOffsets["speedLimitEPositive"]["offset"] + 3]))] + bytes = struct.pack("4B", *data) + speedLimitEPositive = round(struct.unpack('f', bytes)[0], 6) - # Check if speed limit E positive is invalid - if math.isnan(speedLimitEPositive) or speedLimitEPositive < 60 or speedLimitEPositive > 600 : + # Check if speed limit E positive is invalid + if math.isnan(speedLimitEPositive) or speedLimitEPositive < 60 or speedLimitEPositive > 600 : - # Convert default speed limit E positive to binary - packed = struct.pack('f', 102) - speedLimitEPositive = ord(packed[0]) | (ord(packed[1]) << 8) | (ord(packed[2]) << 16) | (ord(packed[3]) << 24) + # Convert default speed limit E positive to binary + packed = struct.pack('f', 102) + speedLimitEPositive = ord(packed[0]) | (ord(packed[1]) << 8) | (ord(packed[2]) << 16) | (ord(packed[3]) << 24) - # Go through bytes of speed limit E positive - index = 0 - while index < 4 : + # Go through bytes of speed limit E positive + index = 0 + while index < 4 : - # Check if saving speed limit E positive failed - if not error and not self.writeToEeprom(connection, self.eepromOffsets["speedLimitEPositive"]["offset"] + index, chr((speedLimitEPositive >> 8 * index) & 0xFF)) : + # Check if saving speed limit E positive failed + if not error and not self.writeToEeprom(connection, self.eepromOffsets["speedLimitEPositive"]["offset"] + index, chr((speedLimitEPositive >> 8 * index) & 0xFF)) : - # Set error - error = True + # Set error + error = True - # Increment index - index += 1 + # Increment index + index += 1 - # Check if an error hasn't occured - if not error : + # Check if an error hasn't occured + if not error : - # Get speed limit E negative - data = [int(ord(self.eeprom[self.eepromOffsets["speedLimitENegative"]["offset"]])), int(ord(self.eeprom[self.eepromOffsets["speedLimitENegative"]["offset"] + 1])), int(ord(self.eeprom[self.eepromOffsets["speedLimitENegative"]["offset"] + 2])), int(ord(self.eeprom[self.eepromOffsets["speedLimitENegative"]["offset"] + 3]))] - bytes = struct.pack("4B", *data) - speedLimitENegative = round(struct.unpack('f', bytes)[0], 6) + # Get speed limit E negative + data = [int(ord(self.eeprom[self.eepromOffsets["speedLimitENegative"]["offset"]])), int(ord(self.eeprom[self.eepromOffsets["speedLimitENegative"]["offset"] + 1])), int(ord(self.eeprom[self.eepromOffsets["speedLimitENegative"]["offset"] + 2])), int(ord(self.eeprom[self.eepromOffsets["speedLimitENegative"]["offset"] + 3]))] + bytes = struct.pack("4B", *data) + speedLimitENegative = round(struct.unpack('f', bytes)[0], 6) - # Check if speed limit E negative is invalid - if math.isnan(speedLimitENegative) or speedLimitENegative < 60 or speedLimitENegative > 720 : + # Check if speed limit E negative is invalid + if math.isnan(speedLimitENegative) or speedLimitENegative < 60 or speedLimitENegative > 720 : - # Convert default speed limit E negative to binary - packed = struct.pack('f', 360) - speedLimitENegative = ord(packed[0]) | (ord(packed[1]) << 8) | (ord(packed[2]) << 16) | (ord(packed[3]) << 24) + # Convert default speed limit E negative to binary + packed = struct.pack('f', 360) + speedLimitENegative = ord(packed[0]) | (ord(packed[1]) << 8) | (ord(packed[2]) << 16) | (ord(packed[3]) << 24) - # Go through bytes of speed limit E negative - index = 0 - while index < 4 : + # Go through bytes of speed limit E negative + index = 0 + while index < 4 : - # Check if saving speed limit E negative failed - if not error and not self.writeToEeprom(connection, self.eepromOffsets["speedLimitENegative"]["offset"] + index, chr((speedLimitENegative >> 8 * index) & 0xFF)) : + # Check if saving speed limit E negative failed + if not error and not self.writeToEeprom(connection, self.eepromOffsets["speedLimitENegative"]["offset"] + index, chr((speedLimitENegative >> 8 * index) & 0xFF)) : - # Set error - error = True + # Set error + error = True - # Increment index - index += 1 + # Increment index + index += 1 - # Check if an error has occured - if error : + # Check if an error has occured + if error : - # Display error - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating speed limits failed", confirm = True)) + # Display error + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating speed limits failed", confirm = True)) - # Check if firmware is corrupt - if not error and eepromCrc != chipCrc : + # Check if firmware is corrupt + if not error and eepromCrc != chipCrc : - # Set temp firmware name - if firmwareName is None : - currentFirmwareName = "M3D" - else : - currentFirmwareName = firmwareName + # Set temp firmware name + if firmwareName is None : + currentFirmwareName = "M3D" + else : + currentFirmwareName = firmwareName - # Display message - self.messageResponse = None - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Firmware is corrupt. Update to " + currentFirmwareName + " firmware version " + self.providedFirmwares[currentFirmwareName]["Release"] + '?', response = True)) + # Display message + self.messageResponse = None + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Firmware is corrupt. Update to " + currentFirmwareName + " firmware version " + self.providedFirmwares[currentFirmwareName]["Release"] + '?', response = True)) - # Wait until response is obtained - while self.messageResponse is None : - time.sleep(0.01) + # Wait until response is obtained + while self.messageResponse is None : + time.sleep(0.01) - # Check if response was no - if not self.messageResponse : + # Check if response was no + if not self.messageResponse : - # Set error - error = True + # Set error + error = True - # Otherwise - else : + # Otherwise + else : - # Send message - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating firmware")) + # Send message + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating firmware")) - # Check if updating firmware failed - if not self.updateToProvidedFirmware(connection, currentFirmwareName) : + # Check if updating firmware failed + if not self.updateToProvidedFirmware(connection, currentFirmwareName) : - # Send message - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating firmware failed", confirm = True)) + # Send message + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating firmware failed", confirm = True)) - # Set error - error = True + # Set error + error = True - # Otherwise - else : + # Otherwise + else : - # Send message - self.messageResponse = None - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating firmware was successful", confirm = True)) + # Send message + self.messageResponse = None + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating firmware was successful", confirm = True)) - # Wait until response is obtained - while self.messageResponse is None : - time.sleep(0.01) + # Wait until response is obtained + while self.messageResponse is None : + time.sleep(0.01) - # Otherwise check if firmware is outdated - elif not error and firmwareName is not None and firmwareVersion < int(self.providedFirmwares[firmwareName]["Version"]) : + # Otherwise check if firmware is outdated + elif not error and firmwareName is not None and firmwareVersion < int(self.providedFirmwares[firmwareName]["Version"]) : - # Set if firmware is incompatible - if firmwareName == "M3D" : - incompatible = firmwareVersion < 2015122112 - elif firmwareName == "iMe" : - incompatible = firmwareVersion < 1900000001 + # Set if firmware is incompatible + if firmwareName == "M3D" : + incompatible = firmwareVersion < 2015122112 + elif firmwareName == "iMe" : + incompatible = firmwareVersion < 1900000001 - # Display message - self.messageResponse = None - if incompatible : - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Firmware is incompatible. Update to " + firmwareName + " firmware version " + self.providedFirmwares[firmwareName]["Release"] + '?', response = True)) - else : - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Newer firmware available. Update to " + firmwareName + " firmware version " + self.providedFirmwares[firmwareName]["Release"] + '?', response = True)) + # Display message + self.messageResponse = None + if incompatible : + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Firmware is incompatible. Update to " + firmwareName + " firmware version " + self.providedFirmwares[firmwareName]["Release"] + '?', response = True)) + else : + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Newer firmware available. Update to " + firmwareName + " firmware version " + self.providedFirmwares[firmwareName]["Release"] + '?', response = True)) - # Wait until response is obtained - while self.messageResponse is None : - time.sleep(0.01) + # Wait until response is obtained + while self.messageResponse is None : + time.sleep(0.01) - # Check if response was no - if not self.messageResponse : + # Check if response was no + if not self.messageResponse : - # Set error if incompatible - if incompatible : - error = True + # Set error if incompatible + if incompatible : + error = True - # Otherwise - else : + # Otherwise + else : - # Send message - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating firmware")) + # Send message + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating firmware")) - # Check if updating firmware failed - if not self.updateToProvidedFirmware(connection, firmwareName) : + # Check if updating firmware failed + if not self.updateToProvidedFirmware(connection, firmwareName) : - # Send message - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating firmware failed", confirm = True)) + # Send message + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating firmware failed", confirm = True)) - # Set error - error = True + # Set error + error = True - # Otherwise - else : + # Otherwise + else : - # Send message - self.messageResponse = None - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating firmware was successful", confirm = True)) + # Send message + self.messageResponse = None + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Error", message = "Updating firmware was successful", confirm = True)) - # Wait until response is obtained - while self.messageResponse is None : - time.sleep(0.01) + # Wait until response is obtained + while self.messageResponse is None : + time.sleep(0.01) - # Check if no errors occured - if not error : + # Check if no errors occured + if not error : - # Send new EEPROM - self.getEeprom(connection, True) - - # Otherwise - else : + # Send new EEPROM + self.getEeprom(connection, True) - # Set error - error = True - - # Close connection - connection.close() - - # Check if an error has occured - if error : + # Otherwise + else : - # Clear EEPROM - self.eeprom = None + # Set error + error = True - # Re-connect - self._printer.connect(currentPort, currentBaudrate, currentProfile) - - # Wait until connection is established - while not isinstance(self._printer.get_transport(), serial.Serial) : - time.sleep(0.01) + # Close connection + connection.close() - # Remove serial timeout - self._printer.get_transport().timeout = None - if float(serial.VERSION) < 3 : - self._printer.get_transport().writeTimeout = None - else : - self._printer.get_transport().write_timeout = None + # Check if an error has occured + if error : - # Check if an error didn't occur - if not error : + # Clear EEPROM + self.eeprom = None - # Close connection - if self._printer._comm is not None : + # Close connection + if self._printer._comm is not None : - try : - self._printer._comm.close(False, False) - except TypeError : - pass + try : + self._printer._comm.close(False, False) + except TypeError : + pass - self._printer.disconnect() + self._printer.disconnect() + + # Otherwise + else : - # Connect to the printer - connection = serial.Serial(currentPort, currentBaudrate) + # Connect to the printer + connection = serial.Serial(currentPort, currentBaudrate) - # Save ports - self.savePorts(currentPort) + # Save ports + self.savePorts(currentPort) - # Attempt to put printer into G-code processing mode - connection.write("Q") - time.sleep(1) + # Attempt to put printer into G-code processing mode + connection.write("Q") + time.sleep(1) - # Close connection - connection.close() + # Close connection + connection.close() - # Set updated port - currentPort = self.getPort() + # Set updated port + currentPort = self.getPort() - # Check if printer wasn't found - if currentPort is None : + # Check if printer wasn't found + if currentPort is None : - # Send message - self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Show Message", message = "No Micro 3D printer detected. Try cycling the printer's power and try again.", confirm = True)) + # Send message + self._plugin_manager.send_plugin_message(self._identifier, dict(value = "Show Message", message = "No Micro 3D printer detected. Try cycling the printer's power and try again.", confirm = True)) - # Otherwise - else : + # Otherwise + else : - # Re-connect to printer - self._printer.connect(currentPort, currentBaudrate, currentProfile) + # Re-connect to printer + self._printer.connect(currentPort, currentBaudrate, currentProfile) - # Wait until connection is established - while not isinstance(self._printer.get_transport(), serial.Serial) : - time.sleep(0.01) + # Wait until connection is established + while not isinstance(self._printer.get_transport(), serial.Serial) : + time.sleep(0.01) - # Remove serial timeout - self._printer.get_transport().timeout = None - if float(serial.VERSION) < 3 : - self._printer.get_transport().writeTimeout = None - else : - self._printer.get_transport().write_timeout = None + # Remove serial timeout + self._printer.get_transport().timeout = None + if float(serial.VERSION) < 3 : + self._printer.get_transport().writeTimeout = None + else : + self._printer.get_transport().write_timeout = None - # Check if communication layer has been established - if self._printer._comm is not None : + # Check if communication layer has been established + if self._printer._comm is not None : - # Set printer state to operational - self._printer._comm._changeState(self._printer._comm.STATE_OPERATIONAL) + # Set printer state to operational + self._printer._comm._changeState(self._printer._comm.STATE_OPERATIONAL) - # Check if using M3D firmware - if self.getFirmwareDetails()[0] == "M3D" : + # Check if using M3D firmware + if self.getFirmwareDetails()[0] == "M3D" : - # Save original write and read functions - self.originalWrite = self._printer.get_transport().write - self.originalRead = self._printer.get_transport().readline + # Save original write and read functions + self.originalWrite = self._printer.get_transport().write + self.originalRead = self._printer.get_transport().readline - # Overwrite write and read functions to process write and read functions - self._printer.get_transport().write = self.processWrite - self._printer.get_transport().readline = self.processRead - - # Clear invalid printer - self.invalidPrinter = False + # Overwrite write and read functions to process write and read functions + self._printer.get_transport().write = self.processWrite + self._printer.get_transport().readline = self.processRead - # Request printer information - self._printer.get_transport().write("M115") - - # Otherwise - else : - - # Close connection - if self._printer._comm is not None : - - try : - self._printer._comm.close(False, False) - except TypeError : - pass - - self._printer.disconnect() + # Clear invalid printer + self.invalidPrinter = False + + # Request printer information + time.sleep(0.5) + self._printer.get_transport().write("M115") # Enable printer callbacks self._printer.register_callback(self) @@ -4719,7 +4814,7 @@ def on_printer_add_log(self, data) : if "MACHINE_TYPE:The_Micro" not in data : # Set write and read functions back to original - if self.originalWrite is not None : + if self.originalWrite is not None and isinstance(self._printer.get_transport(), serial.Serial) : self._printer.get_transport().write = self.originalWrite self._printer.get_transport().readline = self.originalRead @@ -5495,7 +5590,7 @@ def preprocessGcode(self, path, file_object, links = None, printer_profile = Non if self._settings.get_int(["GpioLayer"]) is not None : self.sharedLibrary.setGpioLayer(ctypes.c_ushort(self._settings.get_int(["GpioLayer"]))) self.sharedLibrary.setHeatbedTemperature(ctypes.c_ushort(self._settings.get_int(["HeatbedTemperature"]))) - self.sharedLibrary.setHeatbedHeight(ctypes.c_double(self._settings.get_float(["HeatbedHeight"]))) + self.sharedLibrary.setExternalBedHeight(ctypes.c_double(self._settings.get_float(["ExternalBedHeight"]))) self.sharedLibrary.setMidPrintFilamentChangeLayers(ctypes.c_char_p(' '.join(re.findall("\\d+", str(self._settings.get(["MidPrintFilamentChangeLayers"])))))) # Collect print information @@ -5616,21 +5711,10 @@ def collectPrintInformation(self, file) : tier = "Low" gcode = Gcode() - # Check if using a heatbed - if self.heatbedConnected : - - # Adjust bed Z values - self.bedMediumMaxZ = 73.5 - self._settings.get_float(["HeatbedHeight"]) - self.bedHighMaxZ = 112.0 - self._settings.get_float(["HeatbedHeight"]) - self.bedHighMinZ = self.bedMediumMaxZ - - # Otherwise - else : - - # Set bed Z values to defaults - self.bedMediumMaxZ = 73.5 - self.bedHighMaxZ = 112.0 - self.bedHighMinZ = self.bedMediumMaxZ + # Adjust bed Z values to account for external bed height + self.bedMediumMaxZ = 73.5 - self._settings.get_float(["ExternalBedHeight"]) + self.bedHighMaxZ = 112.0 - self._settings.get_float(["ExternalBedHeight"]) + self.bedHighMinZ = self.bedMediumMaxZ # Reset detected fan speed self.detectedFanSpeed = None @@ -7792,7 +7876,7 @@ def autoConnect(self, comm_instance, port, baudrate, read_timeout, *args, **kwar # Check if printer isn't detected port = self.getPort() - if not port : + if port is None : # Set state to failed comm_instance._log("Failed to autodetect serial port") @@ -8014,12 +8098,22 @@ def setGpioPinHigh(self) : # Check if using Linux if platform.uname()[0].startswith("Linux") : - + # Set GPIO pin high - os.system("echo \"" + str(gpioPin) + "\" > /sys/class/gpio/export") - os.system("echo \"out\" > /sys/class/gpio/gpio" + str(gpioPin) + "/direction") - os.system("echo \"1\" > /sys/class/gpio/gpio" + str(gpioPin) + "/value") - os.system("echo \"" + str(gpioPin) + "\" > /sys/class/gpio/unexport") + # try gpio/wiringPi method + try: + subprocess.call(["gpio", "-g", "mode", str(gpioPin), "out"]) + subprocess.call(["gpio", "-g", "write", str(gpioPin), "1"]) + except OSError as e: + if e.errno == os.errno.ENOENT: + # wiringPi not found + os.system("echo \"" + str(gpioPin) + "\" > /sys/class/gpio/export") + os.system("echo \"out\" > /sys/class/gpio/gpio" + str(gpioPin) + "/direction") + os.system("echo \"1\" > /sys/class/gpio/gpio" + str(gpioPin) + "/value") + os.system("echo \"" + str(gpioPin) + "\" > /sys/class/gpio/unexport") + else: + # Something else went wrong while trying to run `gpio` + raise # Set GPIO pin low def setGpioPinLow(self) : @@ -8030,12 +8124,22 @@ def setGpioPinLow(self) : # Check if using Linux if platform.uname()[0].startswith("Linux") : - + # Set GPIO pin low - os.system("echo \"" + str(gpioPin) + "\" > /sys/class/gpio/export") - os.system("echo \"out\" > /sys/class/gpio/gpio" + str(gpioPin) + "/direction") - os.system("echo \"0\" > /sys/class/gpio/gpio" + str(gpioPin) + "/value") - os.system("echo \"" + str(gpioPin) + "\" > /sys/class/gpio/unexport") + # try gpio/wiringPi method + try: + subprocess.call(["gpio", "-g", "mode", str(gpioPin), "out"]) + subprocess.call(["gpio", "-g", "write", str(gpioPin), "0"]) + except OSError as e: + if e.errno == os.errno.ENOENT: + # wiringPi not found + os.system("echo \"" + str(gpioPin) + "\" > /sys/class/gpio/export") + os.system("echo \"out\" > /sys/class/gpio/gpio" + str(gpioPin) + "/direction") + os.system("echo \"0\" > /sys/class/gpio/gpio" + str(gpioPin) + "/value") + os.system("echo \"" + str(gpioPin) + "\" > /sys/class/gpio/unexport") + else: + # Something else went wrong while trying to run `gpio` + raise # Plugin info diff --git a/octoprint_m3dfio/static/css/m3dfio.css b/octoprint_m3dfio/static/css/m3dfio.css index 0fc7c4c..e73e2ae 100644 --- a/octoprint_m3dfio/static/css/m3dfio.css +++ b/octoprint_m3dfio/static/css/m3dfio.css @@ -99,14 +99,15 @@ outline: none; } -#settings_plugin_m3dfio label.control-label { - cursor: default; -} - #settings_plugin_m3dfio div.input-append { width: calc(100% - 24px); } +#settings_plugin_m3dfio div.control-group.empty { + margin-top: 0; + margin-bottom: 3px; +} + #settings_plugin_m3dfio input[type="number"], #settings_plugin_m3dfio select { width: calc(100% - 24px); } @@ -545,10 +546,25 @@ body > div.page-container > div.message > div > div > div.printSettings input, b width: 145px; } -body > div.page-container > div.message > div > div > div.printSettings div.heatbed input, body > div.page-container > div.message > div > div > div.filamentSettings div.heatbed input { +body > div.page-container > div.message > div > div > div.printSettings div.heatbed input { width: 146px; } +body > div.page-container > div.message > div > div > div.filamentSettings p { + text-align: center; + font-size: 14px; + cursor: default; + margin-top: -10px; +} + +body > div.page-container > div.message > div > div > div.filamentSettings p > ul { + display: inline; + margin: 0; + list-style-type: none; + font-size: 13px; + color: #999; +} + body > div.page-container > div.message > div > div > div.printSettings label[title] { cursor: pointer; min-height: auto; @@ -619,7 +635,7 @@ body > div.page-container > div.message > div > div > span.show { cursor: default; } -#slicing_configuration_dialog .modal-footer a.link, #slicing_configuration_dialog:not(.model):not(.profile) .modal-footer a.save { +#slicing_configuration_dialog .modal-footer a.link, #slicing_configuration_dialog:not(.model):not(.profile) .modal-footer a.save, #slicing_configuration_dialog:not(.profile) .modal-footer a.skip { display: none; } diff --git a/octoprint_m3dfio/static/js/m3dfio.js b/octoprint_m3dfio/static/js/m3dfio.js index 92aa869..9031fc2 100644 --- a/octoprint_m3dfio/static/js/m3dfio.js +++ b/octoprint_m3dfio/static/js/m3dfio.js @@ -25,7 +25,8 @@ $(function() { var skippedMessages = 0; var continueWithPrint = false; var waitingCallback = null; - var usingHeatbed = false; + var locationCallback = null; + var skipModelEditor = false; var self = this; // Get state views @@ -538,55 +539,95 @@ $(function() { // Show message function showMessage(header, text, secondButton, secondButtonCallback, firstButton, firstButtonCallback) { + // Append message to list + messages.push({ + header: header, + text: text, + secondButton: secondButton, + firstButton: firstButton, + secondButtonCallback: secondButtonCallback, + firstButtonCallback: firstButtonCallback + }); + } + + // Hide message + function hideMessage() { + // Get message var message = $("body > div.page-container > div.message"); - - // Check if message is already being shown that needs confirmation - if(message.css("z-index") == "9999" && message.find("button.confirm").eq(1).hasClass("show")) { - - // Append message to list - messages.push({ - header: header, - text: text, - secondButton: secondButton, - firstButton: firstButton, - secondButtonCallback: secondButtonCallback, - firstButtonCallback: firstButtonCallback - }); + + // Check if a message is shown + if(message.hasClass("show")) { + + // Hide message + message.removeClass("show").find("button.confirm").off("click"); + + setTimeout(function() { + + message.css("z-index", '') + }, 300); } // Otherwise - else { + else - // Skip message - if(skippedMessages) - skippedMessages--; + // Increment skipped messages + skippedMessages++; + } + + // Show stored messages + setInterval(function() { + + // Get message + var message = $("body > div.page-container > div.message"); + + // Check if skipping a message and the current displayed message doesn't need confirmation + if(skippedMessages && message.hasClass("show") && !message.find("button.confirm").eq(1).hasClass("show")) { + + // Decrement skipped messages + skippedMessages--; - // Otherwise - else { + // Hide message + hideMessage(); + } + // Check if more messages exist + if(messages.length) { + + // Skip messages + while(skippedMessages && messages.length) { + skippedMessages--; + messages.shift(); + } + + // Check if a message can be displayed + if(messages.length && ((message.hasClass("show") && !message.find("button.confirm").eq(1).hasClass("show")) || message.css("z-index") != "9999")) { + + // Get current message + var currentMessage = messages.shift(); + // Blur focused element $("*:focus").blur(); // Set header and text - message.find("h4").text(header); - message.find("p").html(text); + message.find("h4").text(currentMessage.header); + message.find("p").html(currentMessage.text); // Set first button if specified var buttons = message.find("button.confirm"); - if(typeof firstButton === "undefined") + if(typeof currentMessage.firstButton === "undefined") buttons.eq(0).removeClass("show"); else - buttons.eq(0).text(firstButton).addClass("show"); + buttons.eq(0).text(currentMessage.firstButton).addClass("show"); // Set second button if specified - if(typeof secondButton === "undefined") + if(typeof currentMessage.secondButton === "undefined") buttons.eq(1).removeClass("show"); else - buttons.eq(1).text(secondButton).addClass("show"); + buttons.eq(1).text(currentMessage.secondButton).addClass("show"); // Hide button area and show loading if no buttons are specified - if(typeof secondButton === "undefined" && typeof firstButton === "undefined") { + if(typeof currentMessage.secondButton === "undefined" && typeof currentMessage.firstButton === "undefined") { $("body > div.page-container > div.message > div > div > div").removeClass("show"); $("body > div.page-container > div.message > div > img").addClass("show"); $("body > div.page-container > div.message > div > div > span").addClass("show"); @@ -600,9 +641,9 @@ $(function() { // Show calibration menu or print settings if applicable $("body > div.page-container > div.message > div > div > div.calibrate, body > div.page-container > div.message > div > div > div.printSettings, body > div.page-container > div.message > div > div > div.filamentSettings").removeClass("show"); - if(secondButton == "Done") + if(currentMessage.secondButton == "Done") $("body > div.page-container > div.message > div > div > div.calibrate").addClass("show"); - else if(secondButton == "Print") { + else if(currentMessage.secondButton == "Print") { $("body > div.page-container > div.message > div > div > div.printSettings input").eq(0).val(self.settings.settings.plugins.m3dfio.FilamentTemperature()); $("body > div.page-container > div.message > div > div > div.printSettings input").eq(1).val(self.settings.settings.plugins.m3dfio.HeatbedTemperature()); $("body > div.page-container > div.message > div > div > div.printSettings select").val(self.settings.settings.plugins.m3dfio.FilamentType()); @@ -610,20 +651,21 @@ $(function() { $("body > div.page-container > div.message > div > div > div.printSettings").addClass("show"); } - else if(secondButton == "Unload" || secondButton == "Load" || secondButton == "Set") { + else if(currentMessage.secondButton == "Unload" || currentMessage.secondButton == "Load" || currentMessage.secondButton == "Set") { $("body > div.page-container > div.message > div > div > div.filamentSettings input").eq(0).val(self.settings.settings.plugins.m3dfio.FilamentTemperature()); - $("body > div.page-container > div.message > div > div > div.filamentSettings label").text((secondButton == "Set" ? "New Print" : secondButton) + " Temperature"); + $("body > div.page-container > div.message > div > div > div.filamentSettings label").text((currentMessage.secondButton == "Set" ? "New Print" : currentMessage.secondButton) + " Temperature"); + $("body > div.page-container > div.message > div > div > div.filamentSettings p").html("Recommended"); $("body > div.page-container > div.message > div > div > div.filamentSettings").addClass("show"); } } // Attach function callbacks - if(typeof firstButtonCallback === "function") - buttons.eq(0).one("click", firstButtonCallback); + if(typeof currentMessage.firstButtonCallback === "function") + buttons.eq(0).one("click", currentMessage.firstButtonCallback); else buttons.eq(0).off("click"); - if(typeof secondButtonCallback === "function") - buttons.eq(1).one("click", secondButtonCallback); + if(typeof currentMessage.secondButtonCallback === "function") + buttons.eq(1).one("click", currentMessage.secondButtonCallback); else buttons.eq(1).off("click"); @@ -631,63 +673,7 @@ $(function() { message.addClass("show").css("z-index", "9999"); } } - } - - // Hide message - function hideMessage() { - - // Get message - var message = $("body > div.page-container > div.message"); - - // Check if a message is shown - if(message.hasClass("show")) { - - // Hide message - message.removeClass("show").find("button.confirm").off("click"); - - setTimeout(function() { - - message.css("z-index", '') - }, 300); - } - - // Otherwise - else - - // Increment skipped messages - skippedMessages++; - } - - // Show stored messages - setInterval(function() { - - // Get message - var message = $("body > div.page-container > div.message"); - - // Check if a messages need to be skipped and a message is being displayed that doesn't need confirmation - if(skippedMessages && message.hasClass("show") && !message.find("button.confirm").eq(1).hasClass("show")) { - - // Hide message - skippedMessages--; - hideMessage(); - } - - // Check if more messages exist and they can be displayed - if(messages.length && message.css("z-index") != "9999") { - - // Skip messages - while(skippedMessages && messages.length) { - skippedMessages--; - messages.shift(); - } - - // Show next message - if(messages.length) { - var message = messages.shift(); - showMessage(message.header, message.text, message.secondButton, message.secondButtonCallback, message.firstButton, message.firstButtonCallback); - } - } - }, 500); + }, 300); // Message button click event $(document).on("click", "body > div.page-container > div.message button", function() { @@ -911,29 +897,13 @@ $(function() { // Initialize init: function() { - // Check if using a heatbed - if(usingHeatbed) { - - // Adjust bed Z values - bedLowMaxZ = 5.0 + parseFloat(self.settings.settings.plugins.m3dfio.HeatbedHeight()); - bedLowMinZ = 0.0 + parseFloat(self.settings.settings.plugins.m3dfio.HeatbedHeight()); - bedMediumMinZ = bedLowMaxZ; - bedMediumMaxZ = 73.5; - bedHighMaxZ = 112.0; - bedHighMinZ = bedMediumMaxZ; - } - - // otherwise - else { - - // Set bed Z values to defaults - bedLowMaxZ = 5.0; - bedLowMinZ = 0.0; - bedMediumMinZ = bedLowMaxZ; - bedMediumMaxZ = 73.5; - bedHighMaxZ = 112.0; - bedHighMinZ = bedMediumMaxZ; - } + // Adjust bed Z values to account for external bed height + bedLowMaxZ = 5.0 + parseFloat(self.settings.settings.plugins.m3dfio.ExternalBedHeight()); + bedLowMinZ = 0.0 + parseFloat(self.settings.settings.plugins.m3dfio.ExternalBedHeight()); + bedMediumMinZ = bedLowMaxZ; + bedMediumMaxZ = 73.5; + bedHighMaxZ = 112.0; + bedHighMinZ = bedMediumMaxZ; // Check if using Cura if(slicerName == "cura") { @@ -1015,7 +985,7 @@ $(function() { // Create controls this.orbitControls = new THREE.OrbitControls(this.camera, this.renderer.domElement); - this.orbitControls.target.set(0, usingHeatbed ? 54.9 + parseFloat(self.settings.settings.plugins.m3dfio.HeatbedHeight()) : 54.9, 0); + this.orbitControls.target.set(0, 54.9 + parseFloat(self.settings.settings.plugins.m3dfio.ExternalBedHeight()), 0); this.orbitControls.minDistance = 200; this.orbitControls.maxDistance = 500; this.orbitControls.minPolarAngle = 0; @@ -2425,7 +2395,7 @@ $(function() { viewport.models[i].adhesion.mesh.geometry.center(); // Set adhesion's orientation - viewport.models[i].adhesion.mesh.position.set(viewport.models[i].mesh.position.x, 0, viewport.models[i].mesh.position.z); + viewport.models[i].adhesion.mesh.position.set(viewport.models[i].mesh.position.x, bedLowMinZ, viewport.models[i].mesh.position.z); viewport.models[i].adhesion.mesh.rotation.set(0, 0, 0); var boundaryBox = new THREE.Box3().setFromObject(viewport.models[i].mesh); viewport.models[i].adhesion.mesh.scale.set((boundaryBox.max.x - boundaryBox.min.x + viewport.adhesionSize * 2) / (boundaryBox.max.x - boundaryBox.min.x), 0.000000000001, (boundaryBox.max.z - boundaryBox.min.z + viewport.adhesionSize * 2) / (boundaryBox.max.z - boundaryBox.min.z)); @@ -3710,6 +3680,7 @@ $(function() { +

@@ -3738,6 +3709,9 @@ $(function() { // Add save button and warning $("#slicing_configuration_dialog .modal-footer").append("Save

"); + // Add skip model editor button + $("#slicing_configuration_dialog > div.modal-footer > .btn-primary").before("Skip Model Editor"); + // Allow positioning OctoPrint instance manager $("div.navbar-inner div.container").css("position", "relative"); $("div.navbar-inner ul.nav.pull-right").css("position", "static"); @@ -4349,6 +4323,13 @@ $(function() { } }); + // Setting label click event + $("#settings_plugin_m3dfio label.control-label").click(function() { + + // Focus on input + $(this).siblings("div.controls").find("input").focus(); + }); + // Download log click event $("#settings_plugin_m3dfio div.control-group.log button:nth-of-type(1)").click(function(event) { @@ -4739,13 +4720,14 @@ $(function() { if(viewport) viewport.destroy(); - // Restore slicer + // Restore slicer dialog $("#slicing_configuration_dialog").removeClass("profile model"); $("#slicing_configuration_dialog p.currentMenu").text("Select Profile"); $("#slicing_configuration_dialog .modal-extra").remove(); $("#slicing_configuration_dialog .modal-body").css("display", ''); $("#slicing_configuration_dialog .modal-cover").removeClass("show").css("z-index", ''); $("#slicing_configuration_dialog .modal-footer p.warning").text(''); + skipModelEditor = false; // Save software settings self.settings.saveData(); @@ -4754,6 +4736,22 @@ $(function() { } }, 300); + // Skip model editor button click event + $("#slicing_configuration_dialog > div.modal-footer > a.skip").click(function(event) { + + // Stop default behavior + event.stopImmediatePropagation(); + + // Set skip model editor + skipModelEditor = true; + + // Set slicer menu + slicerMenu = "Modify Model"; + + // Skip model editor + $("#slicing_configuration_dialog > div.modal-footer > .btn-primary").removeClass("disabled").click(); + }); + // Slicer next button click event $("#slicing_configuration_dialog > div.modal-footer > .btn-primary").text("Next").click(function(event) { @@ -6215,8 +6213,8 @@ $(function() { // Set parameter var parameter = []; - // Check if WebGL is supported - if(Detector.webgl) { + // Check if WebGL is supported and not skipping model editor + if(Detector.webgl && !skipModelEditor) { // Export scene as an STL var scene = viewport.exportScene(); @@ -6277,8 +6275,8 @@ $(function() { // On success success: function() { - // Check if WebGL is supported - if(Detector.webgl) { + // Check if WebGL is supported and not skipping model editor + if(Detector.webgl && !skipModelEditor) { // Create request var form = new FormData(); @@ -6779,7 +6777,7 @@ $(function() { var temperature = self.temperature.temperatures.tool0.actual[self.temperature.temperatures.tool0.actual.length - 1][1]; if(temperature != 0) - showMessage("Filament Status", "Warming up: " + temperature + "°C"); + showMessage("Temperature Status", "Warming up: " + temperature + "°C"); } }, 1000); @@ -6840,7 +6838,7 @@ $(function() { var temperature = self.temperature.temperatures.bed.actual[self.temperature.temperatures.bed.actual.length - 1][1]; if(temperature != 0) - showMessage("Filament Status", "Warming up: " + temperature + "°C"); + showMessage("Temperature Status", "Warming up: " + temperature + "°C"); } }, 1000); @@ -7159,392 +7157,370 @@ $(function() { "M114" ]; - // Clear current position - currentX = currentY = currentZ = currentE = null; - - // Wait until position is obtained - function waitUntilPositionIsObtained() { + // Set location callback + locationCallback = function() { - // Check if position has been obtained - if(currentX !== null && currentY !== null && currentZ !== null && currentE !== null) { - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: "Print Information"}), - contentType: "application/json; charset=UTF-8", + // Check if X, Y, and E positions weren't specified + if(currentX === null && currentY === null && currentE == null) { + + // Set default values + currentX = 54; + currentY = 50; + currentE = 0; + } - // On success - success: function(data) { - - // Check if using a heatbed - if(usingHeatbed) { - - // Adjust bed Z values - bedLowMaxZ = 5.0; - bedLowMinZ = 0.0; - bedMediumMinZ = bedLowMaxZ; - bedMediumMaxZ = 73.5 - parseFloat(self.settings.settings.plugins.m3dfio.HeatbedHeight()); - bedHighMaxZ = 112.0 - parseFloat(self.settings.settings.plugins.m3dfio.HeatbedHeight()); - bedHighMinZ = bedMediumMaxZ; - } - - // Otherwise - else { - - // Set bed Z values to defaults - bedLowMaxZ = 5.0; - bedLowMinZ = 0.0; - bedMediumMinZ = bedLowMaxZ; - bedMediumMaxZ = 73.5; - bedHighMaxZ = 112.0; - bedHighMinZ = bedMediumMaxZ; - } - - // Set move Z - var moveZ = currentZ + 3; - if(currentZ <= bedMediumMaxZ && moveZ >= bedHighMinZ) - moveZ = bedMediumMaxZ; - else if(moveZ > bedHighMaxZ) - moveZ = bedHighMaxZ; + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: "Print Information"}), + contentType: "application/json; charset=UTF-8", + + // On success + success: function(data) { + + // Adjust bed Z values to account for external bed height + bedLowMaxZ = 5.0; + bedLowMinZ = 0.0; + bedMediumMinZ = bedLowMaxZ; + bedMediumMaxZ = 73.5 - parseFloat(self.settings.settings.plugins.m3dfio.ExternalBedHeight()); + bedHighMaxZ = 112.0 - parseFloat(self.settings.settings.plugins.m3dfio.ExternalBedHeight()); + bedHighMinZ = bedMediumMaxZ; + + // Set move Z + var moveZ = currentZ + 3; + if(currentZ <= bedMediumMaxZ && moveZ >= bedHighMinZ) + moveZ = bedMediumMaxZ; + else if(moveZ > bedHighMaxZ) + moveZ = bedHighMaxZ; + + // Get min and max X and Y values + var minModelX, maxModelX, minMoveX, maxMoveX; + var minModelY, maxModelY, minMoveY, maxMoveY; + if(moveZ >= bedHighMinZ) { + + minModelX = Math.min(data.minXLow, data.minXMedium, data.minXHigh); + maxModelX = Math.max(data.maxXLow, data.maxXMedium, data.maxXHigh); + minMoveX = bedHighMinX; + maxMoveX = bedHighMaxX; - // Get min and max X and Y values - var minModelX, maxModelX, minMoveX, maxMoveX; - var minModelY, maxModelY, minMoveY, maxMoveY; - if(moveZ >= bedHighMinZ) { + minModelY = Math.min(data.minYLow, data.minYMedium, data.minYHigh); + maxModelY = Math.max(data.maxYLow, data.maxYMedium, data.maxYHigh); + minMoveY = bedHighMinY; + maxMoveY = bedHighMaxY; - minModelX = Math.min(data.minXLow, data.minXMedium, data.minXHigh); - maxModelX = Math.max(data.maxXLow, data.maxXMedium, data.maxXHigh); - minMoveX = bedHighMinX; - maxMoveX = bedHighMaxX; - - minModelY = Math.min(data.minYLow, data.minYMedium, data.minYHigh); - maxModelY = Math.max(data.maxYLow, data.maxYMedium, data.maxYHigh); - minMoveY = bedHighMinY; - maxMoveY = bedHighMaxY; - - if(minMoveY < bedLowMinY) - minMoveY = bedLowMinY; - } - else if(moveZ >= bedMediumMinZ) { + if(minMoveY < bedLowMinY) + minMoveY = bedLowMinY; + } + else if(moveZ >= bedMediumMinZ) { + + minModelX = Math.min(data.minXLow, data.minXMedium); + maxModelX = Math.max(data.maxXLow, data.maxXMedium); + minMoveX = bedMediumMinX; + maxMoveX = bedMediumMaxX; - minModelX = Math.min(data.minXLow, data.minXMedium); - maxModelX = Math.max(data.maxXLow, data.maxXMedium); - minMoveX = bedMediumMinX; - maxMoveX = bedMediumMaxX; - - minModelY = Math.min(data.minYLow, data.minYMedium); - maxModelY = Math.max(data.maxYLow, data.maxYMedium); - minMoveY = bedMediumMinY; - maxMoveY = bedMediumMaxY; - - if(minMoveY < bedLowMinY) - minMoveY = bedLowMinY; - } - else { + minModelY = Math.min(data.minYLow, data.minYMedium); + maxModelY = Math.max(data.maxYLow, data.maxYMedium); + minMoveY = bedMediumMinY; + maxMoveY = bedMediumMaxY; - minModelX = data.minXLow; - maxModelX = data.maxXLow; - minMoveX = bedLowMinX; - maxMoveX = bedLowMaxX; - - minModelY = data.minYLow; - maxModelY = data.maxYLow; + if(minMoveY < bedLowMinY) minMoveY = bedLowMinY; - maxMoveY = bedLowMaxY; - } + } + else { + + minModelX = data.minXLow; + maxModelX = data.maxXLow; + minMoveX = bedLowMinX; + maxMoveX = bedLowMaxX; - // Set move X - var moveX = null; - if(minModelX > minMoveX) { - moveX = minModelX - 20; - if(moveX < minMoveX) - moveX = minMoveX; - } - else if(maxModelX < maxMoveX) { - moveX = maxModelX + 20; - if(moveX > maxMoveX) - moveX = maxMoveX; - } + minModelY = data.minYLow; + maxModelY = data.maxYLow; + minMoveY = bedLowMinY; + maxMoveY = bedLowMaxY; + } + + // Set move X + var moveX = null; + if(minModelX > minMoveX) { + moveX = minModelX - 20; + if(moveX < minMoveX) + moveX = minMoveX; + } + else if(maxModelX < maxMoveX) { + moveX = maxModelX + 20; + if(moveX > maxMoveX) + moveX = maxMoveX; + } + + // Set move Y + var moveY = null; + if(minModelY > minMoveY) { + moveY = minModelY - 20; + if(moveY < minMoveY) + moveY = minMoveY; + } + else if(maxModelY < maxMoveY) { + moveY = maxModelY + 20; + if(moveY > maxMoveY) + moveY = maxMoveY; + } - // Set move Y - var moveY = null; - if(minModelY > minMoveY) { - moveY = minModelY - 20; - if(moveY < minMoveY) - moveY = minMoveY; - } - else if(maxModelY < maxMoveY) { - moveY = maxModelY + 20; - if(moveY > maxMoveY) - moveY = maxMoveY; - } - - // Check if an X or Y movement isn't possible - if(moveX === null || moveY === null) { + // Check if an X or Y movement isn't possible + if(moveX === null || moveY === null) { + + // Show message + showMessage("Filament Status", "The filament can't be changed since the extruder can't be moved away from the print. The print will now resume.", "OK", function() { - // Show message - showMessage("Filament Status", "The filament can't be changed since the extruder can't be moved away from the print. The print will now resume.", "OK", function() { + // Hide message + hideMessage(); + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: "Resume"}), + contentType: "application/json; charset=UTF-8" + }); + }); + } + + // Otherwise + else { + + // Set commands + commands = [ + "G90", + "G0 Z" + moveZ + " E" + (currentE - 5) + " F345", + "G0 X" + moveX + " Y" + moveY + " F2000", + "M65536;wait" + ]; + // Set waiting callback + waitingCallback = function() { + + // Show message + showMessage("Filament Status", '', "Unload", function() { + // Hide message hideMessage(); - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: "Resume"}), - contentType: "application/json; charset=UTF-8" - }); - }); - } - - // Otherwise - else { - - // Set commands - commands = [ - "G90", - "G0 Z" + moveZ + " E" + (currentE - 5) + " F345", - "G0 X" + moveX + " Y" + moveY + " F2000", - "M65536;wait" - ]; - - // Set waiting callback - waitingCallback = function() { - - // Show message - showMessage("Filament Status", '', "Unload", function() { - - // Hide message - hideMessage(); - - // Unload filament - function unloadFilament() { - + + // Unload filament + function unloadFilament() { + + // Show message + showMessage("Filament Status", "Warming up"); + + // Set commands + commands = [ + "M109 S" + parseInt($("body > div.page-container > div.message > div > div > div.filamentSettings input").eq(0).val()), + "M65536;wait" + ]; + + // Display temperature + var updateTemperature = setInterval(function() { + // Show message - showMessage("Filament Status", "Warming up"); + if(self.temperature.temperatures.tool0.actual.length) { + + var temperature = self.temperature.temperatures.tool0.actual[self.temperature.temperatures.tool0.actual.length - 1][1]; + + if(temperature != 0) + showMessage("Filament Status", "Warming up: " + temperature + "°C"); + } + }, 1000); + // Set waiting callback + waitingCallback = function() { + + // Stop displaying temperature + clearInterval(updateTemperature); + + // Show message + showMessage("Filament Status", "Remove filament"); + // Set commands commands = [ - "M109 S" + parseInt($("body > div.page-container > div.message > div > div > div.filamentSettings input").eq(0).val()), - "M65536;wait" + "G90", + "G92" ]; + + for(var i = 2; i <= 40; i += 2) + commands.push("G0 E-" + i + " F345"); - // Display temperature - var updateTemperature = setInterval(function() { - - // Show message - if(self.temperature.temperatures.tool0.actual.length) { - - var temperature = self.temperature.temperatures.tool0.actual[self.temperature.temperatures.tool0.actual.length - 1][1]; - - if(temperature != 0) - showMessage("Filament Status", "Warming up: " + temperature + "°C"); - } - }, 1000); + commands.push("M65536;wait"); // Set waiting callback waitingCallback = function() { - // Stop displaying temperature - clearInterval(updateTemperature); - // Show message - showMessage("Filament Status", "Remove filament"); - - // Set commands - commands = [ - "G90", - "G92" - ]; + showMessage("Filament Status", "Was filament removed?", "Yes", function() { + + // Hide message + hideMessage(); + + // Show message + showMessage("Filament Status", '', "Load", function() { - for(var i = 2; i <= 40; i += 2) - commands.push("G0 E-" + i + " F345"); - - commands.push("M65536;wait"); - - // Set waiting callback - waitingCallback = function() { - - // Show message - showMessage("Filament Status", "Was filament removed?", "Yes", function() { - // Hide message hideMessage(); - - // Show message - showMessage("Filament Status", '', "Load", function() { - - // Hide message - hideMessage(); - - // Load filament - function loadFilament() { + // Load filament + function loadFilament() { + + // Show message + showMessage("Filament Status", "Warming up"); + + // Set commands + commands = [ + "M109 S" + parseInt($("body > div.page-container > div.message > div > div > div.filamentSettings input").eq(0).val()), + "M65536;wait" + ]; + + // Display temperature + updateTemperature = setInterval(function() { + // Show message - showMessage("Filament Status", "Warming up"); + if(self.temperature.temperatures.tool0.actual.length) { + var temperature = self.temperature.temperatures.tool0.actual[self.temperature.temperatures.tool0.actual.length - 1][1]; + + if(temperature != 0) + showMessage("Filament Status", "Warming up: " + temperature + "°C"); + } + }, 1000); + + // Set waiting callback + waitingCallback = function() { + + // Stop displaying temperature + clearInterval(updateTemperature); + + // Show message + showMessage("Filament Status", "Insert filament"); + // Set commands commands = [ - "M109 S" + parseInt($("body > div.page-container > div.message > div > div > div.filamentSettings input").eq(0).val()), - "M65536;wait" + "G90", + "G92" ]; + + for(var i = 2; i <= 40; i += 2) + commands.push("G0 E" + i + " F345"); - // Display temperature - updateTemperature = setInterval(function() { - - // Show message - if(self.temperature.temperatures.tool0.actual.length) { - - var temperature = self.temperature.temperatures.tool0.actual[self.temperature.temperatures.tool0.actual.length - 1][1]; - - if(temperature != 0) - showMessage("Filament Status", "Warming up: " + temperature + "°C"); - } - }, 1000); + commands.push("M65536;wait"); // Set waiting callback waitingCallback = function() { - // Stop displaying temperature - clearInterval(updateTemperature); - // Show message - showMessage("Filament Status", "Insert filament"); - - // Set commands - commands = [ - "G90", - "G92" - ]; - - for(var i = 2; i <= 40; i += 2) - commands.push("G0 E" + i + " F345"); - - commands.push("M65536;wait"); - - // Set waiting callback - waitingCallback = function() { - + showMessage("Filament Status", "Was filament inserted?", "Yes", function() { + + // Hide message + hideMessage(); + // Show message - showMessage("Filament Status", "Was filament inserted?", "Yes", function() { - + showMessage("Filament Status", '', "Set", function() { + // Hide message hideMessage(); - + // Show message - showMessage("Filament Status", '', "Set", function() { + showMessage("Filament Status", "Warming up"); + + // Set commands + commands = [ + "M109 S" + parseInt($("body > div.page-container > div.message > div > div > div.filamentSettings input").eq(0).val()), + "M65536;wait" + ]; + + // Display temperature + updateTemperature = setInterval(function() { - // Hide message - hideMessage(); - // Show message - showMessage("Filament Status", "Warming up"); + if(self.temperature.temperatures.tool0.actual.length) { - // Set commands - commands = [ - "M109 S" + parseInt($("body > div.page-container > div.message > div > div > div.filamentSettings input").eq(0).val()), - "M65536;wait" - ]; - - // Display temperature - updateTemperature = setInterval(function() { - - // Show message - if(self.temperature.temperatures.tool0.actual.length) { + var temperature = self.temperature.temperatures.tool0.actual[self.temperature.temperatures.tool0.actual.length - 1][1]; - var temperature = self.temperature.temperatures.tool0.actual[self.temperature.temperatures.tool0.actual.length - 1][1]; - - if(temperature != 0) - showMessage("Filament Status", "Warming up: " + temperature + "°C"); - } - }, 1000); - - // Set waiting callback - waitingCallback = function() { - - // Stop displaying temperature - clearInterval(updateTemperature); + if(temperature != 0) + showMessage("Filament Status", "Warming up: " + temperature + "°C"); + } + }, 1000); + + // Set waiting callback + waitingCallback = function() { + + // Stop displaying temperature + clearInterval(updateTemperature); + + // Show message + showMessage("Filament Status", "Make sure the nozzle is clean before continuing. It will be hot, so be careful.", "OK", function() { + // Hide message + hideMessage(); + // Show message - showMessage("Filament Status", "Make sure the nozzle is clean before continuing. It will be hot, so be careful.", "OK", function() { + showMessage("Filament Status", "Resuming print"); + + // Set commands + commands = [ + "G90", + "G92 E" + currentE, + "G0 E" + (currentE - 0.3) + " F345", + "G0 X" + currentX + " Y" + currentY + " F2000", + "G0 Z" + currentZ + " F90", + "G0 F300", + "M65536;wait" + ]; + // Set waiting callback + waitingCallback = function() { + // Hide message hideMessage(); - - // Show message - showMessage("Filament Status", "Resuming print"); - - // Set commands - commands = [ - "G90", - "G92 E" + currentE, - "G0 E" + (currentE - 0.3) + " F345", - "G0 X" + currentX + " Y" + currentY + " F2000", - "G0 Z" + currentZ + " F90", - "M65536;wait" - ]; - - // Set waiting callback - waitingCallback = function() { - // Hide message - hideMessage(); - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: "Resume"}), - contentType: "application/json; charset=UTF-8" - }); - } - // Send request $.ajax({ url: API_BASEURL + "plugin/m3dfio", type: "POST", dataType: "json", - data: JSON.stringify({command: "message", value: commands}), + data: JSON.stringify({command: "message", value: "Resume"}), contentType: "application/json; charset=UTF-8" }); + } + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" }); - } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" }); + } + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" }); - }, "No", function() { - - // Hide message - hideMessage(); - - // Load filament again - loadFilament() }); - } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" + }, "No", function() { + + // Hide message + hideMessage(); + + // Load filament again + loadFilament() }); } - + // Send request $.ajax({ url: API_BASEURL + "plugin/m3dfio", @@ -7554,28 +7530,28 @@ $(function() { contentType: "application/json; charset=UTF-8" }); } - loadFilament(); - }); - }, "No", function() { - - // Hide message - hideMessage(); - - // Unload filament again - unloadFilament() + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); + } + loadFilament(); }); - } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" + }, "No", function() { + + // Hide message + hideMessage(); + + // Unload filament again + unloadFilament() }); } - + // Send request $.ajax({ url: API_BASEURL + "plugin/m3dfio", @@ -7585,40 +7561,41 @@ $(function() { contentType: "application/json; charset=UTF-8" }); } - unloadFilament(); - }); - } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); + } + unloadFilament(); }); } + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); } - }); - } - - // Otherwise - else { - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - - // Check if position is obtained again - setTimeout(waitUntilPositionIsObtained, 100); - } + } + }); } - waitUntilPositionIsObtained(); + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); } // Otherwise @@ -8011,74 +7988,59 @@ $(function() { var commands = [ "M114" ]; + + // Set location callback + locationCallback = function() { - // Clear current position - currentZ = null; + // Set commands + commands = [ + "M618 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.FrontLeftOrientation())), + "M619 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"], + "M65536;wait" + ]; - // Wait until position is obtained - function waitUntilPositionIsObtained() { + // Set waiting callback + waitingCallback = function() { - // Check if position has been obtained - if(currentZ !== null) { + // Save settings + function saveSettings() { - // Set commands - commands = [ - "M618 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.FrontLeftOrientation())), - "M619 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"], - "M65536;wait" - ]; - - // Set waiting callback - waitingCallback = function() { - - // Save settings - function saveSettings() { - - // Save software settings - self.settings.saveData(); - - // Show message - showMessage("Calibration Status", "Done", "OK", function() { + // Save software settings + self.settings.saveData(); - // Hide message - hideMessage(); - }); - } + // Show message + showMessage("Calibration Status", "Done", "OK", function() { - // Update settings - if(self.settings.requestData.toString().split('\n')[0].indexOf("callback") != -1) - self.settings.requestData(saveSettings); - else - self.settings.requestData().done(saveSettings); + // Hide message + hideMessage(); + }); } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - } - - // Otherwise - else { - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - - // Check if position is obtained again - setTimeout(waitUntilPositionIsObtained, 100); + + // Update settings + if(self.settings.requestData.toString().split('\n')[0].indexOf("callback") != -1) + self.settings.requestData(saveSettings); + else + self.settings.requestData().done(saveSettings); } + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); } - waitUntilPositionIsObtained(); + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); }, "No", function() { // Hide message @@ -8102,74 +8064,59 @@ $(function() { var commands = [ "M114" ]; + + // Set location callback + locationCallback = function() { - // Clear current position - currentZ = null; + // Set commands + commands = [ + "M618 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.FrontRightOrientation())), + "M619 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"], + "M65536;wait" + ]; - // Wait until position is obtained - function waitUntilPositionIsObtained() { + // Set waiting callback + waitingCallback = function() { - // Check if position has been obtained - if(currentZ !== null) { + // Save settings + function saveSettings() { - // Set commands - commands = [ - "M618 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.FrontRightOrientation())), - "M619 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"], - "M65536;wait" - ]; - - // Set waiting callback - waitingCallback = function() { - - // Save settings - function saveSettings() { - - // Save software settings - self.settings.saveData(); - - // Show message - showMessage("Calibration Status", "Done", "OK", function() { + // Save software settings + self.settings.saveData(); - // Hide message - hideMessage(); - }); - } + // Show message + showMessage("Calibration Status", "Done", "OK", function() { - // Update settings - if(self.settings.requestData.toString().split('\n')[0].indexOf("callback") != -1) - self.settings.requestData(saveSettings); - else - self.settings.requestData().done(saveSettings); + // Hide message + hideMessage(); + }); } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - } - - // Otherwise - else { - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - - // Check if position is obtained again - setTimeout(waitUntilPositionIsObtained, 100); + + // Update settings + if(self.settings.requestData.toString().split('\n')[0].indexOf("callback") != -1) + self.settings.requestData(saveSettings); + else + self.settings.requestData().done(saveSettings); } + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); } - waitUntilPositionIsObtained(); + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); }, "No", function() { // Hide message @@ -8193,74 +8140,59 @@ $(function() { var commands = [ "M114" ]; + + // Set location callback + locationCallback = function() { - // Clear current position - currentZ = null; + // Set commands + commands = [ + "M618 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.BackRightOrientation())), + "M619 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"], + "M65536;wait" + ]; - // Wait until position is obtained - function waitUntilPositionIsObtained() { + // Set waiting callback + waitingCallback = function() { - // Check if position has been obtained - if(currentZ !== null) { + // Save settings + function saveSettings() { - // Set commands - commands = [ - "M618 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.BackRightOrientation())), - "M619 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"], - "M65536;wait" - ]; - - // Set waiting callback - waitingCallback = function() { - - // Save settings - function saveSettings() { - - // Save software settings - self.settings.saveData(); - - // Show message - showMessage("Calibration Status", "Done", "OK", function() { + // Save software settings + self.settings.saveData(); - // Hide message - hideMessage(); - }); - } + // Show message + showMessage("Calibration Status", "Done", "OK", function() { - // Update settings - if(self.settings.requestData.toString().split('\n')[0].indexOf("callback") != -1) - self.settings.requestData(saveSettings); - else - self.settings.requestData().done(saveSettings); + // Hide message + hideMessage(); + }); } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - } - - // Otherwise - else { - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - - // Check if position is obtained again - setTimeout(waitUntilPositionIsObtained, 100); + + // Update settings + if(self.settings.requestData.toString().split('\n')[0].indexOf("callback") != -1) + self.settings.requestData(saveSettings); + else + self.settings.requestData().done(saveSettings); } + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); } - waitUntilPositionIsObtained(); + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); }, "No", function() { // Hide message @@ -8284,74 +8216,59 @@ $(function() { var commands = [ "M114" ]; + + // Set location callback + locationCallback = function() { - // Clear current position - currentZ = null; + // Set commands + commands = [ + "M618 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.BackLeftOrientation())), + "M619 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"], + "M65536;wait" + ]; - // Wait until position is obtained - function waitUntilPositionIsObtained() { + // Set waiting callback + waitingCallback = function() { - // Check if position has been obtained - if(currentZ !== null) { + // Save settings + function saveSettings() { - // Set commands - commands = [ - "M618 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.BackLeftOrientation())), - "M619 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"], - "M65536;wait" - ]; - - // Set waiting callback - waitingCallback = function() { - - // Save settings - function saveSettings() { - - // Save software settings - self.settings.saveData(); - - // Show message - showMessage("Calibration Status", "Done", "OK", function() { + // Save software settings + self.settings.saveData(); - // Hide message - hideMessage(); - }); - } + // Show message + showMessage("Calibration Status", "Done", "OK", function() { - // Update settings - if(self.settings.requestData.toString().split('\n')[0].indexOf("callback") != -1) - self.settings.requestData(saveSettings); - else - self.settings.requestData().done(saveSettings); + // Hide message + hideMessage(); + }); } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - } - - // Otherwise - else { - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - - // Check if position is obtained again - setTimeout(waitUntilPositionIsObtained, 100); + + // Update settings + if(self.settings.requestData.toString().split('\n')[0].indexOf("callback") != -1) + self.settings.requestData(saveSettings); + else + self.settings.requestData().done(saveSettings); } + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); } - waitUntilPositionIsObtained(); + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); }, "No", function() { // Hide message @@ -8692,19 +8609,28 @@ $(function() { "M114" ]; - // Clear current position - currentZ = null; - - // Wait until position is obtained - function waitUntilPositionIsObtained() { - - // Check if position has been obtained - if(currentZ !== null) { + // Set location callback + locationCallback = function() { + + // Set commands + commands = [ + "M618 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.FrontLeftOrientation())), + "M619 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"], + "M65536;wait" + ]; + + // Set waiting callback + waitingCallback = function() { + // Show message + showMessage("Calibration Status", "Calibrating front right offset"); + // Set commands commands = [ - "M618 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.FrontLeftOrientation())), - "M619 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"], + "G90", + "G0 Z3 F90", + "G28", + "G0 X99 Y5 Z3 F3000", "M65536;wait" ]; @@ -8712,245 +8638,182 @@ $(function() { waitingCallback = function() { // Show message - showMessage("Calibration Status", "Calibrating front right offset"); - - // Set commands - commands = [ - "G90", - "G0 Z3 F90", - "G28", - "G0 X99 Y5 Z3 F3000", - "M65536;wait" - ]; - - // Set waiting callback - waitingCallback = function() { - - // Show message - showMessage("Calibration Status", "Lower the print head until it barely touches the bed. One way to get to that point is to place a single sheet of paper on the bed under the print head, and lower the print head until the paper can no longer be moved.", "Done", function() { + showMessage("Calibration Status", "Lower the print head until it barely touches the bed. One way to get to that point is to place a single sheet of paper on the bed under the print head, and lower the print head until the paper can no longer be moved.", "Done", function() { - // Hide message - hideMessage(); - - // Show message - showMessage("Calibration Status", "Saving front right offset"); - + // Hide message + hideMessage(); + + // Show message + showMessage("Calibration Status", "Saving front right offset"); + + // Set commands + commands = [ + "M114" + ]; + + // Set location callback + locationCallback = function() { + // Set commands commands = [ - "M114" + "M618 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.FrontRightOrientation())), + "M619 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"], + "M65536;wait" ]; - - // Clear current position - currentZ = null; - - // Wait until position is obtained - function waitUntilPositionIsObtained() { - - // Check if position has been obtained - if(currentZ !== null) { + + // Set waiting callback + waitingCallback = function() { + + // Show message + showMessage("Calibration Status", "Calibrating back right offset"); + + // Set commands + commands = [ + "G90", + "G0 Z3 F90", + "G28", + "G0 X99 Y95 Z3 F3000", + "M65536;wait" + ]; - // Set commands - commands = [ - "M618 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.FrontRightOrientation())), - "M619 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"], - "M65536;wait" - ]; - - // Set waiting callback - waitingCallback = function() { - - // Show message - showMessage("Calibration Status", "Calibrating back right offset"); + // Set waiting callback + waitingCallback = function() { + + // Show message + showMessage("Calibration Status", "Lower the print head until it barely touches the bed. One way to get to that point is to place a single sheet of paper on the bed under the print head, and lower the print head until the paper can no longer be moved.", "Done", function() { + // Hide message + hideMessage(); + + // Show message + showMessage("Calibration Status", "Saving back right offset"); + // Set commands commands = [ - "G90", - "G0 Z3 F90", - "G28", - "G0 X99 Y95 Z3 F3000", - "M65536;wait" + "M114" ]; + + // Set location callback + locationCallback = function() { + + // Set commands + commands = [ + "M618 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.BackRightOrientation())), + "M619 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"], + "M65536;wait" + ]; - // Set waiting callback - waitingCallback = function() { + // Set waiting callback + waitingCallback = function() { - // Show message - showMessage("Calibration Status", "Lower the print head until it barely touches the bed. One way to get to that point is to place a single sheet of paper on the bed under the print head, and lower the print head until the paper can no longer be moved.", "Done", function() { - - // Hide message - hideMessage(); - // Show message - showMessage("Calibration Status", "Saving back right offset"); - + showMessage("Calibration Status", "Calibrating back left offset"); + // Set commands commands = [ - "M114" + "G90", + "G0 Z3 F90", + "G28", + "G0 X9 Y95 Z3 F3000", + "M65536;wait" ]; - - // Clear current position - currentZ = null; - - // Wait until position is obtained - function waitUntilPositionIsObtained() { - - // Check if position has been obtained - if(currentZ !== null) { - + + // Set waiting callback + waitingCallback = function() { + + // Show message + showMessage("Calibration Status", "Lower the print head until it barely touches the bed. One way to get to that point is to place a single sheet of paper on the bed under the print head, and lower the print head until the paper can no longer be moved.", "Done", function() { + + // Hide message + hideMessage(); + + // Show message + showMessage("Calibration Status", "Saving back left offset"); + // Set commands commands = [ - "M618 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.BackRightOrientation())), - "M619 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"], - "M65536;wait" + "M114" ]; - - // Set waiting callback - waitingCallback = function() { - - // Show message - showMessage("Calibration Status", "Calibrating back left offset"); + // Set location callback + locationCallback = function() { + // Set commands commands = [ - "G90", - "G0 Z3 F90", - "G28", - "G0 X9 Y95 Z3 F3000", + "M618 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.BackLeftOrientation())), + "M619 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"], "M65536;wait" ]; - + // Set waiting callback waitingCallback = function() { - + // Show message - showMessage("Calibration Status", "Lower the print head until it barely touches the bed. One way to get to that point is to place a single sheet of paper on the bed under the print head, and lower the print head until the paper can no longer be moved.", "Done", function() { - - // Hide message - hideMessage(); - + showMessage("Calibration Status", "Resetting bed height offset"); + + // Set commands + commands = [ + "M618 S" + eepromOffsets["bedHeightOffset"]["offset"] + " T" + eepromOffsets["bedHeightOffset"]["bytes"] + " P" + floatToBinary(0), + "M619 S" + eepromOffsets["bedHeightOffset"]["offset"] + " T" + eepromOffsets["bedHeightOffset"]["bytes"], + "M65536;wait" + ]; + + // Set waiting callback + waitingCallback = function() { + // Show message - showMessage("Calibration Status", "Saving back left offset"); - + showMessage("Calibration Status", "Finishing calibration"); + // Set commands commands = [ - "M114" + "G90", + "G0 Z3 F90", + "G28", + "M18", + "M65536;wait" ]; - - // Clear current position - currentZ = null; - - // Wait until position is obtained - function waitUntilPositionIsObtained() { - - // Check if position has been obtained - if(currentZ !== null) { - - // Set commands - commands = [ - "M618 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"] + " P" + floatToBinary(currentZ - parseFloat(self.settings.settings.plugins.m3dfio.BackLeftOrientation())), - "M619 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"], - "M65536;wait" - ]; - - // Set waiting callback - waitingCallback = function() { - - // Show message - showMessage("Calibration Status", "Resetting bed height offset"); - - // Set commands - commands = [ - "M618 S" + eepromOffsets["bedHeightOffset"]["offset"] + " T" + eepromOffsets["bedHeightOffset"]["bytes"] + " P" + floatToBinary(0), - "M619 S" + eepromOffsets["bedHeightOffset"]["offset"] + " T" + eepromOffsets["bedHeightOffset"]["bytes"], - "M65536;wait" - ]; - - // Set waiting callback - waitingCallback = function() { - - // Show message - showMessage("Calibration Status", "Finishing calibration"); - - // Set commands - commands = [ - "G90", - "G0 Z3 F90", - "G28", - "M18", - "M65536;wait" - ]; - - // Set waiting callback - waitingCallback = function() { - - // Save settings - function saveSettings() { - - // Save software settings - self.settings.saveData(); - - // Show message - showMessage("Calibration Status", "Done", "OK", function() { - - // Hide message - hideMessage(); - }); - } - - // Update settings - if(self.settings.requestData.toString().split('\n')[0].indexOf("callback") != -1) - self.settings.requestData(saveSettings); - else - self.settings.requestData().done(saveSettings); - } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" + + // Set waiting callback + waitingCallback = function() { + + // Save settings + function saveSettings() { + + // Save software settings + self.settings.saveData(); + + // Show message + showMessage("Calibration Status", "Done", "OK", function() { + + // Hide message + hideMessage(); }); } - - // Otherwise - else { - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - // Check if position is obtained again - setTimeout(waitUntilPositionIsObtained, 100); - } + // Update settings + if(self.settings.requestData.toString().split('\n')[0].indexOf("callback") != -1) + self.settings.requestData(saveSettings); + else + self.settings.requestData().done(saveSettings); } - waitUntilPositionIsObtained(); + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); + } + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" }); } @@ -8963,20 +8826,7 @@ $(function() { contentType: "application/json; charset=UTF-8" }); } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - } - - // Otherwise - else { - + // Send request $.ajax({ url: API_BASEURL + "plugin/m3dfio", @@ -8985,15 +8835,29 @@ $(function() { data: JSON.stringify({command: "message", value: commands}), contentType: "application/json; charset=UTF-8" }); - - // Check if position is obtained again - setTimeout(waitUntilPositionIsObtained, 100); - } + }); } - waitUntilPositionIsObtained(); + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); + } + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" }); } - + // Send request $.ajax({ url: API_BASEURL + "plugin/m3dfio", @@ -9002,45 +8866,37 @@ $(function() { data: JSON.stringify({command: "message", value: commands}), contentType: "application/json; charset=UTF-8" }); - } - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" }); } - - // Otherwise - else { - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - // Check if position is obtained again - setTimeout(waitUntilPositionIsObtained, 100); - } + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); } - waitUntilPositionIsObtained(); - }); - } - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); + } + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); }); } @@ -9053,24 +8909,25 @@ $(function() { contentType: "application/json; charset=UTF-8" }); } - - // Otherwise - else { - - // Send request - $.ajax({ - url: API_BASEURL + "plugin/m3dfio", - type: "POST", - dataType: "json", - data: JSON.stringify({command: "message", value: commands}), - contentType: "application/json; charset=UTF-8" - }); - // Check if position is obtained again - setTimeout(waitUntilPositionIsObtained, 100); - } + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); } - waitUntilPositionIsObtained(); + + // Send request + $.ajax({ + url: API_BASEURL + "plugin/m3dfio", + type: "POST", + dataType: "json", + data: JSON.stringify({command: "message", value: commands}), + contentType: "application/json; charset=UTF-8" + }); }); } @@ -9866,9 +9723,6 @@ $(function() { // Display heatbed controls $("#control .heatbed, #settings_plugin_m3dfio .heatbed, body > div.page-container > div.message .heatbed").css("display", "block"); $("#control > div.jog-panel.extruder").find("h1:not(.heatbed)").text("Tools"); - - // Set using heatbed - usingHeatbed = true; } // Otherwise check if data is that a heatbed is not detected @@ -9877,9 +9731,6 @@ $(function() { // Hide heatbed controls $("#control .heatbed, #settings_plugin_m3dfio .heatbed, body > div.page-container > div.message .heatbed").css("display", "none"); $("#control > div.jog-panel.extruder").find("h1:not(.heatbed)").text("Extruder"); - - // Clear using heatbed - usingHeatbed = false; } // Otherwise check if data is that camera is hostable @@ -9925,13 +9776,20 @@ $(function() { $("#settings_plugin_m3dfio .camera").css("display", "none"); // Otherwise check if data is current location - else if(data.value == "Current Location" && typeof data.locationX !== "undefined" && typeof data.locationY !== "undefined" && typeof data.locationZ !== "undefined" && typeof data.locationE !== "undefined") { + else if(data.value == "Current Location" && typeof locationCallback === "function" && typeof data.locationX !== "undefined" && typeof data.locationY !== "undefined" && typeof data.locationZ !== "undefined" && typeof data.locationE !== "undefined") { // Set current values currentX = data.locationX === null ? null : parseFloat(data.locationX); currentY = data.locationY === null ? null : parseFloat(data.locationY); currentZ = parseFloat(data.locationZ); currentE = data.locationE === null ? null : parseFloat(data.locationE); + + // Clear location callback + var temp = locationCallback; + locationCallback = null; + + // Call location callback + temp(); } // Otherwise check if data is to change progress bar percent @@ -10645,16 +10503,16 @@ $(function() { // On server disconnect event self.onServerDisconnect = function() { + + // Reset message system + messages = []; + skippedMessages = 0; // Get message var message = $("body > div.page-container > div.message"); // Check if a progress message is being shown if(message.hasClass("show") && !message.find("button.confirm").eq(1).hasClass("show")) { - - // Reset message system - messages = []; - skippedMessages = 0; // Show message showMessage("Server Status", "You've been disconnected from the server which has most likely caused the printer's current operation to fail. It's recommended that you refresh this page to prevent further problems. Refresh now?", "Yes", function() { @@ -10723,6 +10581,16 @@ $(function() { self.settings.requestData().done(updateValues); } + // On error event + self.onEventError = function(payload) { + + // Check if error is an unhandled firmware or communication error + if($("div.ui-pnotify:last-of-type h4.ui-pnotify-title").text() == "Unhandled firmware error" || $("div.ui-pnotify:last-of-type h4.ui-pnotify-title").text() == "Unhandled communication error") + + // Remove error + $("div.ui-pnotify:last-of-type").remove(); + } + // On print started event self.onEventPrintStarted = function(payload) { diff --git a/octoprint_m3dfio/static/libraries/preprocessor_arm1176jzf-s.so b/octoprint_m3dfio/static/libraries/preprocessor_arm1176jzf-s.so index 9955b41..2592bda 100755 Binary files a/octoprint_m3dfio/static/libraries/preprocessor_arm1176jzf-s.so and b/octoprint_m3dfio/static/libraries/preprocessor_arm1176jzf-s.so differ diff --git a/octoprint_m3dfio/static/libraries/preprocessor_arm7.so b/octoprint_m3dfio/static/libraries/preprocessor_arm7.so index 1516a3f..d3fe925 100755 Binary files a/octoprint_m3dfio/static/libraries/preprocessor_arm7.so and b/octoprint_m3dfio/static/libraries/preprocessor_arm7.so differ diff --git a/octoprint_m3dfio/static/libraries/preprocessor_arm_cortex-a7.so b/octoprint_m3dfio/static/libraries/preprocessor_arm_cortex-a7.so index f926b6e..79b3c0f 100755 Binary files a/octoprint_m3dfio/static/libraries/preprocessor_arm_cortex-a7.so and b/octoprint_m3dfio/static/libraries/preprocessor_arm_cortex-a7.so differ diff --git a/octoprint_m3dfio/static/libraries/preprocessor_i386.dll b/octoprint_m3dfio/static/libraries/preprocessor_i386.dll index 7756ad0..c8a3284 100755 Binary files a/octoprint_m3dfio/static/libraries/preprocessor_i386.dll and b/octoprint_m3dfio/static/libraries/preprocessor_i386.dll differ diff --git a/octoprint_m3dfio/static/libraries/preprocessor_i386.dylib b/octoprint_m3dfio/static/libraries/preprocessor_i386.dylib index f01af78..137fb3c 100644 Binary files a/octoprint_m3dfio/static/libraries/preprocessor_i386.dylib and b/octoprint_m3dfio/static/libraries/preprocessor_i386.dylib differ diff --git a/octoprint_m3dfio/static/libraries/preprocessor_i386.so b/octoprint_m3dfio/static/libraries/preprocessor_i386.so index c99c53f..c2e503f 100644 Binary files a/octoprint_m3dfio/static/libraries/preprocessor_i386.so and b/octoprint_m3dfio/static/libraries/preprocessor_i386.so differ diff --git a/octoprint_m3dfio/static/libraries/preprocessor_x86-64.dll b/octoprint_m3dfio/static/libraries/preprocessor_x86-64.dll index e1a1a22..ec875b3 100755 Binary files a/octoprint_m3dfio/static/libraries/preprocessor_x86-64.dll and b/octoprint_m3dfio/static/libraries/preprocessor_x86-64.dll differ diff --git a/octoprint_m3dfio/static/libraries/preprocessor_x86-64.dylib b/octoprint_m3dfio/static/libraries/preprocessor_x86-64.dylib index cd2dc19..82a649e 100644 Binary files a/octoprint_m3dfio/static/libraries/preprocessor_x86-64.dylib and b/octoprint_m3dfio/static/libraries/preprocessor_x86-64.dylib differ diff --git a/octoprint_m3dfio/static/libraries/preprocessor_x86-64.so b/octoprint_m3dfio/static/libraries/preprocessor_x86-64.so index a0ff452..d153e20 100644 Binary files a/octoprint_m3dfio/static/libraries/preprocessor_x86-64.so and b/octoprint_m3dfio/static/libraries/preprocessor_x86-64.so differ diff --git a/octoprint_m3dfio/templates/m3dfio_settings.jinja2 b/octoprint_m3dfio/templates/m3dfio_settings.jinja2 index b24ecfd..623b461 100644 --- a/octoprint_m3dfio/templates/m3dfio_settings.jinja2 +++ b/octoprint_m3dfio/templates/m3dfio_settings.jinja2 @@ -175,7 +175,7 @@
-
+

Printer Settings

@@ -185,7 +185,7 @@
-
+
@@ -194,7 +194,7 @@
-
+
@@ -203,7 +203,7 @@
-
+
@@ -212,7 +212,7 @@
-
+
@@ -221,7 +221,7 @@
-
+
@@ -230,7 +230,7 @@
-
+
@@ -239,7 +239,7 @@
-
+
@@ -248,7 +248,7 @@
-
+
@@ -257,7 +257,7 @@
-
+
@@ -266,7 +266,7 @@
-
+
@@ -275,7 +275,7 @@
-
+
@@ -284,7 +284,16 @@
-
+
+ +
+
+ + mm +
+
+
+
@@ -293,7 +302,7 @@
-
+
@@ -302,16 +311,7 @@
-
- -
-
- - mm -
-
-
-
+
-
+

Changes to speed limits require restarting the printer to take effect

+
+
@@ -335,7 +337,7 @@
-
+
@@ -344,7 +346,7 @@
-
+
@@ -353,7 +355,7 @@
-
+
@@ -362,7 +364,7 @@
-
+
diff --git a/setup.py b/setup.py index 4853301..bdf9354 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ plugin_identifier = "m3dfio" plugin_package = "octoprint_%s" % plugin_identifier plugin_name = "OctoPrint-M3DFio" -plugin_version = "0.29" +plugin_version = "0.30" plugin_description = "Makes OctoPrint fully compatible with the Micro 3D printer" plugin_author = "donovan6000" plugin_author_email = "donovan6000@exploitkings.com" diff --git a/shared library source/preprocessor.cpp b/shared library source/preprocessor.cpp index d64fb93..afa6393 100644 --- a/shared library source/preprocessor.cpp +++ b/shared library source/preprocessor.cpp @@ -156,7 +156,7 @@ bool removeTemperatureCommands; bool useGpio; uint16_t gpioLayer; uint16_t heatbedTemperature; -double heatbedHeight; +double externalBedHeight; int16_t detectedFanSpeed; bool detectedMidPrintFilamentChange; bool objectSuccessfullyCentered; @@ -720,10 +720,10 @@ EXPORT void setHeatbedTemperature(unsigned short value) { heatbedTemperature = value; } -EXPORT void setHeatbedHeight(double value) { +EXPORT void setExternalBedHeight(double value) { - // Set heatbed height - heatbedHeight = value; + // Set external bed height + externalBedHeight = value; } EXPORT void setMidPrintFilamentChangeLayers(const char *value) { @@ -926,23 +926,10 @@ EXPORT bool collectPrintInformation(const char *file) { bool relativeMode = false; double localX = NAN, localY = NAN, localZ = NAN; - // Check if using a heatbed - if(usingHeatbed) { - - // Adjust bed Z values - bedMediumMaxZ = 73.5 - heatbedHeight; - bedHighMaxZ = 112.0 - heatbedHeight; - bedHighMinZ = bedMediumMaxZ; - } - - // Otherwise - else { - - // Set bed Z values to defaults - bedMediumMaxZ = 73.5; - bedHighMaxZ = 112.0; - bedHighMinZ = bedMediumMaxZ; - } + // Adjust bed Z values to account for external bed height + bedMediumMaxZ = 73.5 - externalBedHeight; + bedHighMaxZ = 112.0 - externalBedHeight; + bedHighMinZ = bedMediumMaxZ; // Reset detected fan speed detectedFanSpeed = -1; diff --git a/shared library source/preprocessor.h b/shared library source/preprocessor.h index 0b0a4a6..52fb71f 100644 --- a/shared library source/preprocessor.h +++ b/shared library source/preprocessor.h @@ -144,7 +144,7 @@ extern "C" { EXPORT void setUseGpio(bool value); EXPORT void setGpioLayer(unsigned short value); EXPORT void setHeatbedTemperature(unsigned short value); - EXPORT void setHeatbedHeight(double value); + EXPORT void setExternalBedHeight(double value); EXPORT void setMidPrintFilamentChangeLayers(const char *value); /*