Skip to content

Commit

Permalink
Feature: pass params from calibrate to touch (#120)
Browse files Browse the repository at this point in the history
* pass params from calibrate to touch

* fix: types for GCodeCommand.get_command_parameters

---------

Co-authored-by: Jonas Damtoft <[email protected]>
  • Loading branch information
krautech and Jomik authored Nov 28, 2024
1 parent d2d5739 commit 5bcef1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,17 @@ def __init__(self, config: ConfigWrapper):
cmd_SCANNER_CALIBRATE_help = "Calibrate scanner response curve"

def cmd_SCANNER_CALIBRATE(self, gcmd: GCodeCommand):
orig_params = gcmd.get_command_parameters()
if self.calibration_method != "scan":
cmd = self.sensor_name + "_TOUCH"
params = {}
params: dict[str, str] = {}
if gcmd.get("METHOD", "None").lower() == "manual":
params["METHOD"] = "manual"
else:
params["CALIBRATE"] = "1"

params.update(orig_params)

cmd = self.gcode.create_gcode_command(cmd, cmd, params)
self.cmd_SCANNER_TOUCH(cmd)
else:
Expand Down
3 changes: 3 additions & 0 deletions typings/gcode.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Callable, NamedTuple, final, overload
# Types for https://github.com/Klipper3d/klipper/blob/master/klippy/gcode.py

@final
class CommandError(Exception):
Expand All @@ -14,6 +15,8 @@ class GCodeCommand:
pass
def respond_info(self, msg: str, log: bool = True) -> None:
pass
def get_command_parameters(self) -> dict[str, str]:
pass

@overload
def get(
Expand Down

0 comments on commit 5bcef1a

Please sign in to comment.