|
3 | 3 | import octoprint.plugin
|
4 | 4 | import re
|
5 | 5 |
|
| 6 | + |
6 | 7 | class Ender3V2TempFixPlugin(octoprint.plugin.OctoPrintPlugin):
|
| 8 | + # |
| 9 | + # Recv: TT::27.7627.76 //0.000.00 BB::39.3539.35 //0.000.00 @@::00 BB@@::00 |
| 10 | + # Recv: T:23.84 /0.00 B:24.05 /0.00 @:0 B@:0 |
| 11 | + # |
| 12 | + parse_Ender3V2Temp = re.compile( |
| 13 | + '.*TT::(\d+)\.\d+\.(\d+).+\/\/(\d+)\.\d+\.(\d+).*BB::(\d+)\.\d+\.(\d+).+\/\/(\d+)\.\d+\.(\d+)') |
| 14 | + |
| 15 | + def check_for_temp_report(self, comm_instance, line, *args, **kwargs): |
| 16 | + # Check to see if we received the broken temperature response and if so extract temperature for octoprint |
| 17 | + # self._logger.debug("Testing: %s" % line) |
| 18 | + if "TT::" not in line: |
| 19 | + return line |
| 20 | + self._logger.debug("Original: %s" % line) |
| 21 | + m = self.parse_Ender3V2Temp.search(line) |
| 22 | + new_line = (" T:%s.%s /%s.%s B:%s.%s /%s.%s" % ( |
| 23 | + m.group(1), m.group(2), m.group(3), m.group(4), m.group(5), m.group(6), m.group(7), m.group(8))) |
| 24 | + self._logger.debug("Modified: %s" % new_line) |
| 25 | + return new_line |
| 26 | + |
| 27 | + def TempReport(self, comm_instance, parsed_temperatures, *args, **kwargs): |
| 28 | + self._logger.debug("Before: %s" % parsed_temperatures) |
| 29 | + # self._logger.debug("After: %s" % parsed_temperatures) |
| 30 | + return parsed_temperatures |
| 31 | + |
7 | 32 |
|
8 |
| -# |
9 |
| -# Recv: TT::27.7627.76 //0.000.00 BB::39.3539.35 //0.000.00 @@::00 BB@@::00 |
10 |
| -# Recv: T:23.84 /0.00 B:24.05 /0.00 @:0 B@:0 |
11 |
| -# |
12 |
| - parse_Ender3V2Temp = re.compile('.*TT::(\d+)\.\d+\.(\d+).+\/\/(\d+)\.\d+\.(\d+).*BB::(\d+)\.\d+\.(\d+).+\/\/(\d+)\.\d+\.(\d+)') |
13 |
| - |
14 |
| - def check_for_temp_report(self, comm_instance, line, *args, **kwargs): |
15 |
| - # Check to see if we received the broken temperature response and if so extract temperature for octoprint |
16 |
| -# self._logger.debug("Testing: %s" % line) |
17 |
| - if "TT::" not in line: |
18 |
| - return line |
19 |
| - self._logger.debug("Original: %s" % line) |
20 |
| - m = self.parse_Ender3V2Temp.search(line) |
21 |
| - new_line = (" T:%s.%s /%s.%s B:%s.%s /%s.%s" % (m.group(1), m.group(2), m.group(3), m.group(4), m.group(5), m.group(6), m.group(7), m.group(8))) |
22 |
| - self._logger.debug("Modified: %s" % new_line) |
23 |
| - return new_line |
24 |
| - |
25 |
| - def TempReport(self, comm_instance, parsed_temperatures, *args, **kwargs): |
26 |
| - self._logger.debug("Before: %s" % parsed_temperatures) |
27 |
| -# self._logger.debug("After: %s" % parsed_temperatures) |
28 |
| - return parsed_temperatures |
29 |
| - |
30 |
| -__plugin_name__ = "Ender 3 V2 Temp Fix" |
31 |
| -__plugin_version__ = "1.0.4" |
32 |
| -__plugin_description__ = "This plugin modified the very broken temperature report from the Ender 3 V2 firmware" |
33 |
| -__plugin_author__ = "Brad Morgan" |
34 |
| -__plugin_license__ = "AGPLv3" |
35 | 33 | __plugin_pythoncompat__ = ">=2.7,<4"
|
| 34 | + |
| 35 | + |
36 | 36 | def __plugin_load__():
|
37 |
| - global __plugin_implementation__ |
38 |
| - __plugin_implementation__ = Ender3V2TempFixPlugin() |
39 |
| - |
40 |
| - global __plugin_hooks__ |
41 |
| - __plugin_hooks__ = { |
42 |
| - "octoprint.comm.protocol.temperatures.received": __plugin_implementation__.TempReport, |
43 |
| - "octoprint.comm.protocol.gcode.received": __plugin_implementation__.check_for_temp_report |
44 |
| - } |
| 37 | + global __plugin_implementation__ |
| 38 | + __plugin_implementation__ = Ender3V2TempFixPlugin() |
| 39 | + |
| 40 | + global __plugin_hooks__ |
| 41 | + __plugin_hooks__ = { |
| 42 | + "octoprint.comm.protocol.temperatures.received": __plugin_implementation__.TempReport, |
| 43 | + "octoprint.comm.protocol.gcode.received": __plugin_implementation__.check_for_temp_report |
| 44 | + } |
0 commit comments