OctoPrint-SmartPreheat
OctoPrint-SmartPreheat copied to clipboard
Temperature offsets are not applied
When temperature offsets have been set via the OctoPrint temperature UI, Smart Preheat does not see them and preheats to the original temperatures in the sliced file rather than the offset ones. I looked in the OctoPrint documentation for a way to retrieve the offsets and apply them in the script but I could not find one. If such a method exists it would be nice to use it by default or at least have comments indicating how to enable using it. If not, maybe a method for exporting the value to gcode scripts could be added to Smart Preheat - I would assume the Python side has access to them in some way.
I was able to hack this in by adding offsets = self._printer._comm.getOffsets()
and applying them to the value returned in get_temps_from_file
. I'm not sure if this would be acceptable for upstream or if it would be preferable to export the offsets to the snippet in separate variables for it to apply.
To be honest I never tested w/ offsets and forgot it was even a feature. I'll look into supporting this.
Thanks. As for the motivation, I really need the starting temps the file to be printed will initially wait for (with offsets applied) because my "start print" gcode script in octoprint is responsible for priming. If there's any wait again between it and the file (to heat up from un-offset temp to offset temp) the nozzle will ooze, defeating the whole purpose of having primed it.
Since initially posting this, the hack I described has been working fine for me. I think it's just a matter of evaluating whether that change in behavior is reasonable as-is or whether it should be done in a less invasive way.
Ping. Proposed possible patch for this:
--- __init__.py.orig 2022-04-04 07:40:17.406609696 +0100
+++ __init__.py 2022-04-05 17:24:59.116629495 +0100
@@ -89,6 +89,8 @@
if gcode in ('M104', 'M109', 'M140', 'M190'):
self._logger.debug("Line %d: Detected SetTemp. Line=%s", lineNum, line)
+ offsets = self._printer._comm.getOffsets()
+
toolMatch = octoprint.util.comm.regexes_parameters["intT"].search(line)
if toolMatch:
toolNum = int(toolMatch.group("value"))
@@ -101,10 +103,10 @@
if gcode in ("M104", "M109"):
self._logger.debug("Line %d: Tool %s = %s", lineNum, toolNum, temp)
- temps["tools"][toolNum] = temp
+ temps["tools"][toolNum] = temp + offsets.get("tool%d" % toolNum, 0)
elif gcode in ("M140", "M190"):
self._logger.debug("Line %d: Bed = %s", lineNum, temp)
- temps["bed"] = temp
+ temps["bed"] = temp + offsets.get("bed", 0)
self._logger.debug("Temperatures: %r", temps)
return temps