paneldue: update macros on first connection
Report that the PanelDue is "idle" until it is first initialized. This allows for the Macros to be set upon first connection Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
d19e9e2d28
commit
ec5be560d5
|
@ -153,6 +153,7 @@ class PanelDue:
|
||||||
self.heaters = []
|
self.heaters = []
|
||||||
self.is_ready = False
|
self.is_ready = False
|
||||||
self.is_shutdown = False
|
self.is_shutdown = False
|
||||||
|
self.initialized = False
|
||||||
self.last_printer_state = 'C'
|
self.last_printer_state = 'C'
|
||||||
|
|
||||||
# Set up macros
|
# Set up macros
|
||||||
|
@ -353,7 +354,8 @@ class PanelDue:
|
||||||
for p in parts[1:]:
|
for p in parts[1:]:
|
||||||
arg = p[0].lower() if p[0].lower() in "psr" else "p"
|
arg = p[0].lower() if p[0].lower() in "psr" else "p"
|
||||||
try:
|
try:
|
||||||
val = int(p[1:].strip()) if arg in "sr" else p[1:].strip()
|
val = int(p[1:].strip()) if arg in "sr" \
|
||||||
|
else p[1:].strip(" \"\t\n")
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = f"paneldue: Error parsing direct gcode {script}"
|
msg = f"paneldue: Error parsing direct gcode {script}"
|
||||||
self.handle_gcode_response("!! " + msg)
|
self.handle_gcode_response("!! " + msg)
|
||||||
|
@ -383,6 +385,8 @@ class PanelDue:
|
||||||
logging.exception(msg)
|
logging.exception(msg)
|
||||||
|
|
||||||
def _clean_filename(self, filename):
|
def _clean_filename(self, filename):
|
||||||
|
# Remove quotes and whitespace
|
||||||
|
filename.strip(" \"\t\n")
|
||||||
# Remove drive number
|
# Remove drive number
|
||||||
if filename.startswith("0:/"):
|
if filename.startswith("0:/"):
|
||||||
filename = filename[3:]
|
filename = filename[3:]
|
||||||
|
@ -399,15 +403,15 @@ class PanelDue:
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
def _prepare_M23(self, args):
|
def _prepare_M23(self, args):
|
||||||
filename = self._clean_filename(args[0].strip())
|
filename = self._clean_filename(args[0])
|
||||||
return "M23 " + filename
|
return "M23 " + filename
|
||||||
|
|
||||||
def _prepare_M32(self, args):
|
def _prepare_M32(self, args):
|
||||||
filename = self._clean_filename(args[0].strip())
|
filename = self._clean_filename(args[0])
|
||||||
return "SDCARD_PRINT_FILE FILENAME=" + filename
|
return "SDCARD_PRINT_FILE FILENAME=" + filename
|
||||||
|
|
||||||
def _prepare_M98(self, args):
|
def _prepare_M98(self, args):
|
||||||
macro = args[0][1:].strip()
|
macro = args[0][1:].strip(" \"\t\n")
|
||||||
name_start = macro.rfind('/') + 1
|
name_start = macro.rfind('/') + 1
|
||||||
macro = macro[name_start:]
|
macro = macro[name_start:]
|
||||||
cmd = self.available_macros.get(macro)
|
cmd = self.available_macros.get(macro)
|
||||||
|
@ -499,8 +503,12 @@ class PanelDue:
|
||||||
sequence = arg_r
|
sequence = arg_r
|
||||||
response_type = arg_s
|
response_type = arg_s
|
||||||
|
|
||||||
|
if not self.initialized:
|
||||||
|
response['dir'] = "/macros"
|
||||||
|
response['files'] = list(self.available_macros.keys())
|
||||||
|
self.initialized = True
|
||||||
|
|
||||||
if not self.is_ready:
|
if not self.is_ready:
|
||||||
# Klipper is still starting up, do not query status
|
|
||||||
self.last_printer_state = 'S' if self.is_shutdown else 'C'
|
self.last_printer_state = 'S' if self.is_shutdown else 'C'
|
||||||
response['status'] = self.last_printer_state
|
response['status'] = self.last_printer_state
|
||||||
await self.write_response(response)
|
await self.write_response(response)
|
||||||
|
|
Loading…
Reference in New Issue