Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jneilliii/7e3643b86a89c7d74d6c4b7038022dc4 to your computer and use it in GitHub Desktop.
Save jneilliii/7e3643b86a89c7d74d6c4b7038022dc4 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
import re
import octoprint.plugin
TIME_REMAINING_THRESHOLD = 2 # mins
COOLDOWN_COMMAND = "M140 S0"
M73_R_REGEX = re.compile(r"R(\d*)")
class CooldownTimeRemainingPlugin(octoprint.plugin):
def process_gcode(
self, comm, phase, cmd, cmd_type, gcode, subcode=None, tags=None, *args, **kwargs
):
if gcode != 'M73':
return
match = M73_R_REGEX.match(cmd)
if match:
time_remaining = match.group(1)
if int(time_remaining) <= TIME_REMAINING_THRESHOLD:
return COOLDOWN_COMMAND,
return None,
__plugin_name__ = "Cooldown after Time Remaining"
__plugin_version__ = "1.0.0"
__plugin_description__ = "Waits for an M73 R<time> command to indicate there is less than {} time remaining, too begin cooling the bed"
__plugin_pythoncompat__ = ">=2.7,<4"
__plugin_implementation__ = CooldownTimeRemainingPlugin()
__plugin_hooks__ = {
"octoprint.comm.protocol.gcode.queuing": __plugin_implementation__.process_gcode,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment