Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temperature offsets are not applied #17

Open
richfelker opened this issue Apr 8, 2021 · 4 comments
Open

Temperature offsets are not applied #17

richfelker opened this issue Apr 8, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@richfelker
Copy link

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.

@richfelker
Copy link
Author

richfelker commented Apr 8, 2021

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.

@kantlivelong kantlivelong added the enhancement New feature or request label Apr 16, 2021
@kantlivelong
Copy link
Owner

To be honest I never tested w/ offsets and forgot it was even a feature. I'll look into supporting this.

@richfelker
Copy link
Author

richfelker commented Apr 16, 2021

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.

@richfelker
Copy link
Author

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

TheThief added a commit to TheThief/OctoPrint-SmartPreheat that referenced this issue Oct 17, 2024
TheThief added a commit to TheThief/OctoPrint-SmartPreheat that referenced this issue Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants