From a5657f87a75599b1306e75daab5f61b76df2965d Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Tue, 5 Nov 2019 22:27:47 -0500 Subject: [PATCH 01/13] test for positioning mode --- octoprint_bettergrblsupport/__init__.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/octoprint_bettergrblsupport/__init__.py b/octoprint_bettergrblsupport/__init__.py index fac59d2..e3e05c1 100644 --- a/octoprint_bettergrblsupport/__init__.py +++ b/octoprint_bettergrblsupport/__init__.py @@ -339,11 +339,24 @@ def on_event(self, event, payload): x = float(0) y = float(0) + positioning = 0 + for line in f: - if line.startswith("G0") or line.startswith("G1"): - match = re.search(r"^G[01].*X\ *(-?[\d.]+).*", line) + if line.startswith("G90"): + positioning = 0 + continue + + if line.startswith("G91"): + positioning = 1 + continue + + if line.startswith("G0") or line.startswith("G1") or line.startswith("G2") or line.startswith("G3"): + match = re.search(r"^G[0123].*X\ *(-?[\d.]+).*", line) if not match is None: - x = x + float(match.groups(1)[0]) + if positioning == 1: + x = x + float(match.groups(1)[0]) + else + x = float(match.groups(1)[0]) if x < minX: minX = x if x > maxX: @@ -351,7 +364,10 @@ def on_event(self, event, payload): match = re.search(r"^G[01].*Y\ *(-?[\d.]+).*", line) if not match is None: - y = y + float(match.groups(1)[0]) + if positioning == 1: + y = y + float(match.groups(1)[0]) + else + y = float(match.groups(1)[0]) if y < minY: minY = y if y > maxY: From b8670cdcb6870510986351be5cd9422f9dc2c1c2 Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Tue, 5 Nov 2019 23:30:44 -0500 Subject: [PATCH 02/13] ignore comments --- octoprint_bettergrblsupport/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/octoprint_bettergrblsupport/__init__.py b/octoprint_bettergrblsupport/__init__.py index e3e05c1..466cb1a 100644 --- a/octoprint_bettergrblsupport/__init__.py +++ b/octoprint_bettergrblsupport/__init__.py @@ -343,10 +343,12 @@ def on_event(self, event, payload): for line in f: if line.startswith("G90"): + # absolute positioning positioning = 0 continue if line.startswith("G91"): + # relative positioning positioning = 1 continue @@ -355,18 +357,18 @@ def on_event(self, event, payload): if not match is None: if positioning == 1: x = x + float(match.groups(1)[0]) - else + else: x = float(match.groups(1)[0]) if x < minX: minX = x if x > maxX: maxX = x - match = re.search(r"^G[01].*Y\ *(-?[\d.]+).*", line) + match = re.search(r"^G[0123].*Y\ *(-?[\d.]+).*", line) if not match is None: if positioning == 1: y = y + float(match.groups(1)[0]) - else + else: y = float(match.groups(1)[0]) if y < minY: minY = y @@ -410,6 +412,11 @@ def hook_gcode_sending(self, comm_instance, phase, cmd, cmd_type, gcode, *args, # return (self.helloCommand, ) return "$$" + # suppress comments + if cmd.upper().lstrip().startswith(';') or cmd.upper().lstrip().startswith('('): + self._logger.debug('Ignoring comment [%s]', cmd) + return (None, ) + # suppress reset line #s if self.suppressM110 and cmd.upper().startswith('M110'): self._logger.debug('Ignoring %s', cmd) From 6d610ab4da5aa88f6a3690e09be7150b44b4f759 Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Wed, 6 Nov 2019 00:04:54 -0500 Subject: [PATCH 03/13] cast feedrate properly --- octoprint_bettergrblsupport/__init__.py | 56 ++++++++++++++++--------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/octoprint_bettergrblsupport/__init__.py b/octoprint_bettergrblsupport/__init__.py index 466cb1a..3b68bf3 100644 --- a/octoprint_bettergrblsupport/__init__.py +++ b/octoprint_bettergrblsupport/__init__.py @@ -55,6 +55,7 @@ def __init__(self): self.grblZ = float(0) self.grblSpeed = 0 self.grblPowerLevel = 0 + self.positioning = 0 self.timeRef = 0 @@ -339,23 +340,23 @@ def on_event(self, event, payload): x = float(0) y = float(0) - positioning = 0 + self.positioning = 0 for line in f: if line.startswith("G90"): # absolute positioning - positioning = 0 + self.positioning = 0 continue if line.startswith("G91"): # relative positioning - positioning = 1 + self.positioning = 1 continue if line.startswith("G0") or line.startswith("G1") or line.startswith("G2") or line.startswith("G3"): match = re.search(r"^G[0123].*X\ *(-?[\d.]+).*", line) if not match is None: - if positioning == 1: + if self.positioning == 1: x = x + float(match.groups(1)[0]) else: x = float(match.groups(1)[0]) @@ -366,7 +367,7 @@ def on_event(self, event, payload): match = re.search(r"^G[0123].*Y\ *(-?[\d.]+).*", line) if not match is None: - if positioning == 1: + if self.positioning == 1: y = y + float(match.groups(1)[0]) else: y = float(match.groups(1)[0]) @@ -416,7 +417,7 @@ def hook_gcode_sending(self, comm_instance, phase, cmd, cmd_type, gcode, *args, if cmd.upper().lstrip().startswith(';') or cmd.upper().lstrip().startswith('('): self._logger.debug('Ignoring comment [%s]', cmd) return (None, ) - + # suppress reset line #s if self.suppressM110 and cmd.upper().startswith('M110'): self._logger.debug('Ignoring %s', cmd) @@ -453,28 +454,45 @@ def hook_gcode_sending(self, comm_instance, phase, cmd, cmd_type, gcode, *args, # self._printer.commands("\x18") return ("\x18",) + if cmd.upper().lstrip().startswith("G90"): + # absolute positioning + self.positioning = 0 + + if cmd.upper().lstrip().startswith("G91"): + # relative positioning + self.positioning = 1 + # keep track of distance traveled - if cmd.startswith("G0") or cmd.startswith("G1") or cmd.startswith("M4"): + if cmd.startswith("G0") or cmd.startswith("G1") or cmd.startswith("G2") or cmd.startswith("G3") or cmd.startswith("M4"): found = False - match = re.search(r"^G[01].*X\ *(-?[\d.]+).*", cmd) + match = re.search(r"^G[0123].*X\ *(-?[\d.]+).*", cmd) if not match is None: - self.grblX = self.grblX + float(match.groups(1)[0]) + if self.positioning == 1: + self.grblX = self.grblX + float(match.groups(1)[0]) + else: + self.grblX = float(match.groups(1)[0]) found = True - match = re.search(r"^G[01].*Y\ *(-?[\d.]+).*", cmd) + match = re.search(r"^G[0123].*Y\ *(-?[\d.]+).*", cmd) if not match is None: - self.grblY = self.grblY + float(match.groups(1)[0]) + if self.positioning == 1: + self.grblY = self.grblY + float(match.groups(1)[0]) + else: + self.grblY = float(match.groups(1)[0]) found = True - match = re.search(r"^G[01].*Z\ *(-?[\d.]+).*", cmd) + match = re.search(r"^G[0123].*Z\ *(-?[\d.]+).*", cmd) if not match is None: - self.grblZ = self.grblZ + float(match.groups(1)[0]) + if self.positioning == 1: + self.grblZ = self.grblZ + float(match.groups(1)[0]) + else: + self.grblZ = float(match.groups(1)[0]) found = True - match = re.search(r"^[GM][014].*F\ *(-?[\d.]+).*", cmd) + match = re.search(r"^[GM][01234].*F\ *(-?[\d.]+).*", cmd) if not match is None: - grblSpeed = int(match.groups(1)[0]) + grblSpeed = round(float(match.groups(1)[0])) # make sure we post all speed on / off events if (grblSpeed == 0 and self.grblSpeed != 0) or (self.grblSpeed == 0 and grblSpeed != 0): @@ -483,9 +501,9 @@ def hook_gcode_sending(self, comm_instance, phase, cmd, cmd_type, gcode, *args, self.grblSpeed = grblSpeed found = True - match = re.search(r"^[GM][014].*S\ *(-?[\d.]+).*", cmd) + match = re.search(r"^[GM][01234].*S\ *(-?[\d.]+).*", cmd) if not match is None: - grblPowerLevel = int(float(match.groups(1)[0])) + grblPowerLevel = round(float(match.groups(1)[0])) # make sure we post all power on / off events if (grblPowerLevel == 0 and self.grblPowerLevel != 0) or (self.grblPowerLevel == 0 and grblPowerLevel != 0): @@ -608,8 +626,8 @@ def hook_gcode_received(self, comm_instance, line, *args, **kwargs): match = re.search(r"F(-?[\d.]+) S(-?[\d.]+)", line) if not match is None: - self.grblSpeed = int(match.groups(1)[0]) - self.grblPowerLevel = int(match.groups(1)[1]) + self.grblSpeed = round(float(match.groups(1)[0])) + self.grblPowerLevel = round(float(match.groups(1)[1])) self._plugin_manager.send_plugin_message(self._identifier, dict(type="grbl_state", state=self.grblState, From 53cf8e8bbdac513f5ff36ee6ef9b6283871fb16e Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Wed, 6 Nov 2019 00:56:32 -0500 Subject: [PATCH 04/13] add T2 support --- octoprint_bettergrblsupport/__init__.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/octoprint_bettergrblsupport/__init__.py b/octoprint_bettergrblsupport/__init__.py index 3b68bf3..6d9f576 100644 --- a/octoprint_bettergrblsupport/__init__.py +++ b/octoprint_bettergrblsupport/__init__.py @@ -462,11 +462,21 @@ def hook_gcode_sending(self, comm_instance, phase, cmd, cmd_type, gcode, *args, # relative positioning self.positioning = 1 + #T2 # HACK: + if cmd.upper().lstrip().startswith("X"): + match = re.search(r"^X *(-?[\d.]+).*", cmd) + if not match is None: + command = "G01 " + cmd.upper().strip() + else: + command = cmd.upper().strip() + else: + command = cmd.upper().strip() + # keep track of distance traveled - if cmd.startswith("G0") or cmd.startswith("G1") or cmd.startswith("G2") or cmd.startswith("G3") or cmd.startswith("M4"): + if command.startswith("G0") or command.startswith("G1") or command.startswith("G2") or command.startswith("G3") or command.startswith("M4"): found = False - match = re.search(r"^G[0123].*X\ *(-?[\d.]+).*", cmd) + match = re.search(r"^G[0123].*X\ *(-?[\d.]+).*", command) if not match is None: if self.positioning == 1: self.grblX = self.grblX + float(match.groups(1)[0]) @@ -474,7 +484,7 @@ def hook_gcode_sending(self, comm_instance, phase, cmd, cmd_type, gcode, *args, self.grblX = float(match.groups(1)[0]) found = True - match = re.search(r"^G[0123].*Y\ *(-?[\d.]+).*", cmd) + match = re.search(r"^G[0123].*Y\ *(-?[\d.]+).*", command) if not match is None: if self.positioning == 1: self.grblY = self.grblY + float(match.groups(1)[0]) @@ -482,7 +492,7 @@ def hook_gcode_sending(self, comm_instance, phase, cmd, cmd_type, gcode, *args, self.grblY = float(match.groups(1)[0]) found = True - match = re.search(r"^G[0123].*Z\ *(-?[\d.]+).*", cmd) + match = re.search(r"^G[0123].*Z\ *(-?[\d.]+).*", command) if not match is None: if self.positioning == 1: self.grblZ = self.grblZ + float(match.groups(1)[0]) @@ -490,7 +500,7 @@ def hook_gcode_sending(self, comm_instance, phase, cmd, cmd_type, gcode, *args, self.grblZ = float(match.groups(1)[0]) found = True - match = re.search(r"^[GM][01234].*F\ *(-?[\d.]+).*", cmd) + match = re.search(r"^[GM][01234].*F\ *(-?[\d.]+).*", command) if not match is None: grblSpeed = round(float(match.groups(1)[0])) @@ -501,7 +511,7 @@ def hook_gcode_sending(self, comm_instance, phase, cmd, cmd_type, gcode, *args, self.grblSpeed = grblSpeed found = True - match = re.search(r"^[GM][01234].*S\ *(-?[\d.]+).*", cmd) + match = re.search(r"^[GM][01234].*S\ *(-?[\d.]+).*", command) if not match is None: grblPowerLevel = round(float(match.groups(1)[0])) @@ -525,7 +535,7 @@ def hook_gcode_sending(self, comm_instance, phase, cmd, cmd_type, gcode, *args, power=self.grblPowerLevel)) self.timeRef = currentTime - return None + return (command, ) # #-- gcode received hook ( # original author: https://github.com/mic159 From adb7df7fa70d23f85a015e2bac60122e26078c49 Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Wed, 6 Nov 2019 08:39:09 -0500 Subject: [PATCH 05/13] update bounding box calculation for T2 format --- octoprint_bettergrblsupport/__init__.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/octoprint_bettergrblsupport/__init__.py b/octoprint_bettergrblsupport/__init__.py index 6d9f576..f7844f5 100644 --- a/octoprint_bettergrblsupport/__init__.py +++ b/octoprint_bettergrblsupport/__init__.py @@ -343,18 +343,28 @@ def on_event(self, event, payload): self.positioning = 0 for line in f: - if line.startswith("G90"): + #T2 # HACK: + if line.upper().lstrip().startswith("X"): + match = re.search(r"^X *(-?[\d.]+).*", line) + if not match is None: + command = "G01 " + line.upper().strip() + else: + command = line.upper().strip() + else: + command = line.upper().strip() + + if command.startswith("G90"): # absolute positioning self.positioning = 0 continue - if line.startswith("G91"): + if command.startswith("G91"): # relative positioning self.positioning = 1 continue - if line.startswith("G0") or line.startswith("G1") or line.startswith("G2") or line.startswith("G3"): - match = re.search(r"^G[0123].*X\ *(-?[\d.]+).*", line) + if command.startswith("G0") or command.startswith("G1") or command.startswith("G2") or command.startswith("G3"): + match = re.search(r"^G[0123].*X\ *(-?[\d.]+).*", command) if not match is None: if self.positioning == 1: x = x + float(match.groups(1)[0]) @@ -365,7 +375,7 @@ def on_event(self, event, payload): if x > maxX: maxX = x - match = re.search(r"^G[0123].*Y\ *(-?[\d.]+).*", line) + match = re.search(r"^G[0123].*Y\ *(-?[\d.]+).*", command) if not match is None: if self.positioning == 1: y = y + float(match.groups(1)[0]) From 60e405cf8eca27398ae22906640e79fbb3bd8b9f Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Wed, 6 Nov 2019 08:48:37 -0500 Subject: [PATCH 06/13] swapped W and L in bounding box message --- octoprint_bettergrblsupport/static/js/bettergrblsupport.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octoprint_bettergrblsupport/static/js/bettergrblsupport.js b/octoprint_bettergrblsupport/static/js/bettergrblsupport.js index 24784d1..7b2600b 100644 --- a/octoprint_bettergrblsupport/static/js/bettergrblsupport.js +++ b/octoprint_bettergrblsupport/static/js/bettergrblsupport.js @@ -255,7 +255,7 @@ $(function() { new PNotify({ title: "Frame Size Computed", - text: "Dimension are " + width + "W x " + length + "L", + text: "Dimensions are " + length + "L x " + width + "W", hide: true, buttons: { sticker: false, From 6b111b14c709a27de8f93d9f72d6d71eb1ac5b01 Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Wed, 6 Nov 2019 09:02:57 -0500 Subject: [PATCH 07/13] logging update to troubleshoot missing GRBL settings descriptions --- octoprint_bettergrblsupport/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/octoprint_bettergrblsupport/__init__.py b/octoprint_bettergrblsupport/__init__.py index f7844f5..d5d98be 100644 --- a/octoprint_bettergrblsupport/__init__.py +++ b/octoprint_bettergrblsupport/__init__.py @@ -280,7 +280,7 @@ def serializeGrblSettings(self): for id, data in sorted(self.grblSettings.items(), key=lambda x: int(x[0])): ret = ret + "{}|{}|{}||".format(id, data[0], data[1]) - # self._logger.info("serializeGrblSettings=[\n{}\n]".format(ret)) + self._logger.info("serializeGrblSettings=[\n{}\n]".format(ret)) return ret def on_settings_save(self, data): @@ -601,7 +601,7 @@ def hook_gcode_received(self, comm_instance, line, *args, **kwargs): settingsValue = match.groups(1)[1] self.grblSettings.update({settingsId: [settingsValue, self.grblSettingsNames.get(settingsId)]}) - # self._logger.info("setting id={} value={} description={}".format(settingsId, settingsValue, self.grblSettingsNames.get(settingsId))) + self._logger.info("setting id={} value={} description={}".format(settingsId, settingsValue, self.grblSettingsNames.get(settingsId))) if settingsId >= 132: self._settings.set(["grblSettingsText"], self.serializeGrblSettings()) From 8764086aa31f9a5a309d6ac8d941ec4ae26de10a Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Wed, 6 Nov 2019 09:50:45 -0500 Subject: [PATCH 08/13] fixed GRBL Settings descriptions - reverted logging commit --- octoprint_bettergrblsupport/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/octoprint_bettergrblsupport/__init__.py b/octoprint_bettergrblsupport/__init__.py index d5d98be..b386ec6 100644 --- a/octoprint_bettergrblsupport/__init__.py +++ b/octoprint_bettergrblsupport/__init__.py @@ -70,6 +70,8 @@ def __init__(self): # #~~ SettingsPlugin mixin def get_settings_defaults(self): + self.loadGrblDescriptions() + return dict( hideTempTab = True, hideControlTab = True, @@ -231,7 +233,6 @@ def on_after_startup(self): self._settings.save() - self.loadGrblDescriptions() self.deSerializeGrblSettings() def loadGrblDescriptions(self): @@ -257,6 +258,7 @@ def loadGrblDescriptions(self): match = re.search(r"^(-?[\d\.]+)[\ ]+(-?[\S\ ]*)", line) if not match is None: self.grblSettingsNames[int(match.groups(1)[0])] = match.groups(1)[1] + # self._logger.info("setting id={} description={}".format(int(match.groups(1)[0]), match.groups(1)[1])) # for k, v in self.grblErrors.items(): # self._logger.info("error id={} desc={}".format(k, v)) @@ -280,7 +282,7 @@ def serializeGrblSettings(self): for id, data in sorted(self.grblSettings.items(), key=lambda x: int(x[0])): ret = ret + "{}|{}|{}||".format(id, data[0], data[1]) - self._logger.info("serializeGrblSettings=[\n{}\n]".format(ret)) + # self._logger.info("serializeGrblSettings=[\n{}\n]".format(ret)) return ret def on_settings_save(self, data): From 0102d390d67f61401e6b696c8d6c796d2e9a8a1c Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Wed, 6 Nov 2019 10:49:21 -0500 Subject: [PATCH 09/13] add weak laser intensity to settings panel --- octoprint_bettergrblsupport/__init__.py | 7 ++++++- .../templates/bettergrblsupport_settings.jinja2 | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/octoprint_bettergrblsupport/__init__.py b/octoprint_bettergrblsupport/__init__.py index b386ec6..22539c7 100644 --- a/octoprint_bettergrblsupport/__init__.py +++ b/octoprint_bettergrblsupport/__init__.py @@ -43,6 +43,7 @@ def __init__(self): self.reOrderTabs = True self.disablePrinterSafety = True self.showZ = False + self.weakLaserValue = 1 self.overrideM8 = False self.overrideM9 = False @@ -101,6 +102,7 @@ def get_settings_defaults(self): grblSettingsText = "This space intentionally left blank", grblSettingsBackup = "", showZ = False, + weakLaserValue = 1, overrideM8 = False, overrideM9 = False, m8Command = "/home/pi/bin/tplink_smartplug.py -t air-assist.shellware.com -c on", @@ -139,6 +141,9 @@ def on_after_startup(self): self.m8Command = self._settings.get(["m8Command"]) self.m9Command = self._settings.get(["m9Command"]) + self.showZ = self._settings.get_boolean(["showZ"]) + self.weakLaserValue = self._settings.get(["weakLaserValue"]) + # self._settings.global_set_boolean(["feature", "temperatureGraph"], not self.hideTempTab) # self._settings.global_set_boolean(["feature", "gCodeVisualizer"], not self.hideGCodeTab) # self._settings.global_set_boolean(["gcodeViewer", "enabled"], not self.hideGCodeTab) @@ -603,7 +608,7 @@ def hook_gcode_received(self, comm_instance, line, *args, **kwargs): settingsValue = match.groups(1)[1] self.grblSettings.update({settingsId: [settingsValue, self.grblSettingsNames.get(settingsId)]}) - self._logger.info("setting id={} value={} description={}".format(settingsId, settingsValue, self.grblSettingsNames.get(settingsId))) + # self._logger.info("setting id={} value={} description={}".format(settingsId, settingsValue, self.grblSettingsNames.get(settingsId))) if settingsId >= 132: self._settings.set(["grblSettingsText"], self.serializeGrblSettings()) diff --git a/octoprint_bettergrblsupport/templates/bettergrblsupport_settings.jinja2 b/octoprint_bettergrblsupport/templates/bettergrblsupport_settings.jinja2 index 1ccf1be..f8f4788 100644 --- a/octoprint_bettergrblsupport/templates/bettergrblsupport_settings.jinja2 +++ b/octoprint_bettergrblsupport/templates/bettergrblsupport_settings.jinja2 @@ -79,6 +79,13 @@
+ +
+ +
+ +
+
@@ -103,7 +110,7 @@

* Server restart is required for this setting change to take effect

-
+

Grbl Settings


From 9ffd8f0b5ef3fd3d514caa862086712d93f01471 Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Wed, 6 Nov 2019 11:05:36 -0500 Subject: [PATCH 10/13] implement variable weak laser intensity --- octoprint_bettergrblsupport/__init__.py | 86 ++++++++++++------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/octoprint_bettergrblsupport/__init__.py b/octoprint_bettergrblsupport/__init__.py index 22539c7..27ec3d3 100644 --- a/octoprint_bettergrblsupport/__init__.py +++ b/octoprint_bettergrblsupport/__init__.py @@ -143,7 +143,7 @@ def on_after_startup(self): self.showZ = self._settings.get_boolean(["showZ"]) self.weakLaserValue = self._settings.get(["weakLaserValue"]) - + # self._settings.global_set_boolean(["feature", "temperatureGraph"], not self.hideTempTab) # self._settings.global_set_boolean(["feature", "gCodeVisualizer"], not self.hideGCodeTab) # self._settings.global_set_boolean(["gcodeViewer", "enabled"], not self.hideGCodeTab) @@ -686,7 +686,7 @@ def send_frame_init_gcode(self): self._printer.commands("G00 G17 G40 G21 G54") self._printer.commands("G91") self._printer.commands("$32=0") - self._printer.commands("M4 F1000 S1") + self._printer.commands("M4 F1000 S{}".format(self.weakLaserValue)) self._printer.commands("G91") # self._printer.commands("M8") @@ -699,65 +699,65 @@ def send_frame_end_gcode(self): self._printer.commands("M2") def send_bounding_box_upper_left(self, y, x): - self._printer.commands("G0 X{:f} F2000 S1".format(x)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y * -1)) - self._printer.commands("G0 X{:f} F2000 S1".format(x * -1)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y * -1, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x * -1, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y, self.weakLaserValue)) def send_bounding_box_upper_center(self, y, x): - self._printer.commands("G0 X{:f} F2000 S1".format(x / 2)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y * -1)) - self._printer.commands("G0 X{:f} F2000 S1".format(x * -1)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y)) - self._printer.commands("G0 X{:f} F2000 S1".format(x / 2)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x / 2, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y * -1, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x * -1, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x / 2, self.weakLaserValue)) def send_bounding_box_upper_right(self, y, x): - self._printer.commands("G0 Y{:f} F2000 S1".format(y * -1)) - self._printer.commands("G0 X{:f} F2000 S1".format(x * -1)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y)) - self._printer.commands("G0 X{:f} F2000 S1".format(x)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y * -1, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x * -1, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x, self.weakLaserValue)) def send_bounding_box_center_left(self, y, x): - self._printer.commands("G0 Y{:f} F2000 S1".format(y / 2)) - self._printer.commands("G0 X{:f} F2000 S1".format(x)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y * -1)) - self._printer.commands("G0 X{:f} F2000 S1".format(x * -1)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y / 2)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y / 2, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y * -1, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x * -1, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y / 2, self.weakLaserValue)) def send_bounding_box_center(self, y, x): self._printer.commands("G0 X{:f} Y{:f} F4000".format(x / 2 * -1, y / 2)) - self._printer.commands("G0 X{} F2000 S1".format(x)) - self._printer.commands("G0 Y{:f} S1".format(y * -1)) - self._printer.commands("G0 X{} S1".format(x * -1)) - self._printer.commands("G0 Y{} S1".format(y)) + self._printer.commands("G0 X{} F2000 S{}".format(x, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} S{}".format(y * -1, self.weakLaserValue)) + self._printer.commands("G0 X{} S{}".format(x * -1, self.weakLaserValue)) + self._printer.commands("G0 Y{} S{}".format(y, self.weakLaserValue)) self._printer.commands("G0 X{:f} Y{:f} F4000".format(x / 2, y / 2 * -1)) def send_bounding_box_center_right(self, y, x): - self._printer.commands("G0 Y{:f} F2000 S1".format(y / 2 * -1)) - self._printer.commands("G0 X{:f} F2000 S1".format(x * -1)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y)) - self._printer.commands("G0 X{:f} F2000 S1".format(x)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y / 2 * -1)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y / 2 * -1, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x * -1, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y / 2 * -1, self.weakLaserValue)) def send_bounding_box_lower_left(self, y, x): - self._printer.commands("G0 Y{:f} F2000 S1".format(y)) - self._printer.commands("G0 X{:f} F2000 S1".format(x)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y * -1)) - self._printer.commands("G0 X{:f} F2000 S1".format(x * -1)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y * -1, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x * -1, self.weakLaserValue)) def send_bounding_box_lower_center(self, y, x): - self._printer.commands("G0 X{:f} F2000 S1".format(x / 2 * -1)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y)) - self._printer.commands("G0 X{:f} F2000 S1".format(x)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y * -1)) - self._printer.commands("G0 X{:f} F2000 S1".format(x / 2 * -1)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x / 2 * -1, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y * -1, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x / 2 * -1, self.weakLaserValue)) def send_bounding_box_lower_right(self, y, x): - self._printer.commands("G0 X{:f} F2000 S1".format(x * -1)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y)) - self._printer.commands("G0 X{:f} F2000 S1".format(x)) - self._printer.commands("G0 Y{:f} F2000 S1".format(y * -1)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x * -1, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y, self.weakLaserValue)) + self._printer.commands("G0 X{:f} F2000 S{}".format(x, self.weakLaserValue)) + self._printer.commands("G0 Y{:f} F2000 S{}".format(y * -1, self.weakLaserValue)) def get_api_commands(self): return dict( @@ -928,7 +928,7 @@ def toggleWeak(self): if powerLevel == 0: self._printer.commands("$32=0") - self._printer.commands("M4 F1000 S1") + self._printer.commands("M4 F1000 S{}".format(self.weakLaserValue)) res = "Laser Off" else: # self._printer.commands("M9") From e63eef4ae00765286a73eefd0f515fb7b6ee02a9 Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Wed, 6 Nov 2019 11:21:52 -0500 Subject: [PATCH 11/13] fix grbl error #8 when toggling laser mode --- octoprint_bettergrblsupport/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/octoprint_bettergrblsupport/__init__.py b/octoprint_bettergrblsupport/__init__.py index 27ec3d3..12a4d12 100644 --- a/octoprint_bettergrblsupport/__init__.py +++ b/octoprint_bettergrblsupport/__init__.py @@ -683,9 +683,11 @@ def hook_gcode_received(self, comm_instance, line, *args, **kwargs): return 'ok' def send_frame_init_gcode(self): + self._printer.commands("G4 P0") + self._printer.commands("$32=0") self._printer.commands("G00 G17 G40 G21 G54") self._printer.commands("G91") - self._printer.commands("$32=0") + # self._printer.commands("$32=0") self._printer.commands("M4 F1000 S{}".format(self.weakLaserValue)) self._printer.commands("G91") # self._printer.commands("M8") @@ -694,9 +696,11 @@ def send_frame_end_gcode(self): # self._printer.commands("M9") self._printer.commands("G1S0") self._printer.commands("M4 F0 S0") - self._printer.commands("$32=1") + # self._printer.commands("$32=1") self._printer.commands("M5") self._printer.commands("M2") + self._printer.commands("G4 P0") + self._printer.commands("$32=1") def send_bounding_box_upper_left(self, y, x): self._printer.commands("G0 X{:f} F2000 S{}".format(x, self.weakLaserValue)) From 31a75a442f91ceb598648517df6098b009c4da53 Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Thu, 7 Nov 2019 21:12:18 -0500 Subject: [PATCH 12/13] add Z axis jogging support --- octoprint_bettergrblsupport/__init__.py | 23 +++++++--- .../templates/bettergrblsupport_tab.jinja2 | 45 ++++++++++++++++--- 2 files changed, 55 insertions(+), 13 deletions(-) diff --git a/octoprint_bettergrblsupport/__init__.py b/octoprint_bettergrblsupport/__init__.py index 12a4d12..357e2c6 100644 --- a/octoprint_bettergrblsupport/__init__.py +++ b/octoprint_bettergrblsupport/__init__.py @@ -883,26 +883,37 @@ def on_api_command(self, command, data): self._printer.commands("G28 X0 Y0") self._printer.commands("G90") - if direction == "up": + if direction == "forward": self._printer.commands("G91") - self._printer.commands("G1 Y{} F4000".format(distance)) + self._printer.commands("G0 Y{}".format(distance)) self._printer.commands("G90") - if direction == "down": + if direction == "backward": self._printer.commands("G91") - self._printer.commands("G1 Y{} F4000".format(distance * -1)) + self._printer.commands("G0 Y{}".format(distance * -1)) self._printer.commands("G90") if direction == "left": self._printer.commands("G91") - self._printer.commands("G1 X{} F4000".format(distance * -1)) + self._printer.commands("G0 X{}".format(distance * -1)) self._printer.commands("G90") if direction == "right": self._printer.commands("G91") - self._printer.commands("G1 X{} F4000".format(distance)) + self._printer.commands("G0 X{}".format(distance)) + self._printer.commands("G90") + + if direction == "up": + self._printer.commands("G91") + self._printer.commands("G0 Z{}".format(distance)) self._printer.commands("G90") + if direction == "down": + self._printer.commands("G91") + self._printer.commands("G0 Z{}".format(distance * -1)) + self._printer.commands("G90") + + return if command == "origin": diff --git a/octoprint_bettergrblsupport/templates/bettergrblsupport_tab.jinja2 b/octoprint_bettergrblsupport/templates/bettergrblsupport_tab.jinja2 index 8561a12..b7f84c7 100644 --- a/octoprint_bettergrblsupport/templates/bettergrblsupport_tab.jinja2 +++ b/octoprint_bettergrblsupport/templates/bettergrblsupport_tab.jinja2 @@ -94,7 +94,7 @@
- -
+
@@ -126,9 +126,39 @@
- - + + + + + + -
+ + + + + + + + + + + + + + + + +
 
+ +
 Z
+ +
 
+
+ @@ -163,7 +193,7 @@ @@ -180,7 +210,7 @@
 X/Y
@@ -139,7 +169,7 @@
-
-
+

@@ -194,6 +224,7 @@

+
From ecee70b4e72e61068c9021be943c450268eda626 Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Thu, 7 Nov 2019 21:13:39 -0500 Subject: [PATCH 13/13] increment version number --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7d3a0f4..cb0d9f1 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "Better Grbl Support" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "1.6.0" +plugin_version = "1.7.0" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module