From c2936b5e6ce75b2f4434e66e46ea7ada408f0d61 Mon Sep 17 00:00:00 2001 From: scmanjarrez Date: Fri, 28 Apr 2023 02:17:36 +0200 Subject: [PATCH] Recovered save to EEPROM from earlier versions --- octoprint_SmartABL/__init__.py | 40 ++++++++++++++++++++++++---------- setup.py | 2 +- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/octoprint_SmartABL/__init__.py b/octoprint_SmartABL/__init__.py index c9ebbec..570b332 100644 --- a/octoprint_SmartABL/__init__.py +++ b/octoprint_SmartABL/__init__.py @@ -173,7 +173,7 @@ def gcode_queuing( gcode in self._gcodes_ignore() or cmd in self._gcodes_ignore() ): self._smartabl_logger.debug( - f"@gcode_queuing:ignore >> " + f"@gcode_queuing:ignore > " f"Trigger(cmd={cmd}, gcode={gcode}) || " f"{self._dbg()}" ) @@ -181,6 +181,11 @@ def gcode_queuing( elif gcode == "G28": self.cache = set() elif gcode in self._gcodes_abl() or cmd in self._gcodes_abl(): + self._smartabl_logger.debug( + f"@gcode_queuing:abl > " + f"Trigger(cmd={cmd}, gcode={gcode}) || " + f"{self._dbg()}" + ) self._printer.set_job_on_hold(True) if self.thread is None: self.thread = threading.Thread( @@ -191,7 +196,7 @@ def gcode_queuing( self.last_cmd = cmd cmd = ["@SMARTABLQUERY"] self._smartabl_logger.debug( - f"@gcode_queuing:abl >> Sending {cmd} > {self._dbg()}" + f"@gcode_queuing:abl_send >> Sending {cmd}" ) return cmd return [cmd] @@ -206,10 +211,20 @@ def at_command( self.state["prints"] = 0 self.state["last_mesh"] = self._today() self._save() - self._smartabl_logger.debug( - f"@at_command:save > {self._dbgstate()}" - ) self._update_frontend() + if self.save_allowed: + cmds = self.fw_metadata[self.firmware]["save"] + self._smartabl_logger.debug( + f"@at_command:save >> Sending {cmds} > " + f"{self._dbgstate()} || " + f"{self._dbginternal()}" + ) + self._printer.commands(cmds) + else: + self._smartabl_logger.debug( + f"@at_command:save > {self._dbgstate()} || " + f"{self._dbginternal()}" + ) elif cmd == "SMARTABLQUERY": self.querying = True cmds = self.fw_metadata[self.firmware]["info"][0] @@ -247,15 +262,18 @@ def at_command( cmds.append("@SMARTABLSAVE") self._smartabl_logger.debug( f"@at_command:decide >> ABL trigger >> Sending {cmds} > " - f"{self._dbginternal()}" + f"{self._dbg()}" ) self.probe_required = False else: if self.save_allowed: - cmds = [self.fw_metadata[self.firmware]["load"]] + if self.last_cmd.startswith("M420 S1 Z"): + cmds = [self.last_cmd] + else: + cmds = [self.fw_metadata[self.firmware]["load"]] self._smartabl_logger.debug( f"@at_command:decide >> ABL skip >> Sending {cmds} > " - f"{self._dbginternal()}" + f"{self._dbg()}" ) if cmds is not None: self._printer.commands(cmds) @@ -316,14 +334,14 @@ def process_line(self, comm_instance, line, *args, **kwargs): if "EEPROM disabled" in line: # marlin eeprom disabled self.save_allowed = False elif self._line_mesh(line) and self.querying: - cmd = "@SMARTABLDECIDE" + cmds = "@SMARTABLDECIDE" self.valid_mesh = self._valid_mesh(line) self._smartabl_logger.debug( f"@process_line:" f"{'' if self.valid_mesh else 'in'}valid_mesh >> " - f"Sending {cmd} > {self._dbginternal()}" + f"Sending {cmds} > {self._dbginternal()}" ) - self._printer.commands(cmd) + self._printer.commands(cmds) # elif "M420 S1.0 Z0.0" in line: # self.valid_mesh = True # self._smartabl_logger.debug( diff --git a/setup.py b/setup.py index a629d3f..56d5cca 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "OctoPrint-SmartABL" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "1.0.0" +plugin_version = "1.1.0" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module