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

fix: remove scanner.z_offset #147

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
)

atypes = {"median": "median", "average": "average"}
self.samples_config = {

Check warning on line 124 in scanner.py

View workflow job for this annotation

GitHub Actions / Standard Checks

Type of "samples_config" is partially unknown   Type of "samples_config" is "dict[str, Unknown]" (reportUnknownMemberType)

Check warning on line 124 in scanner.py

View workflow job for this annotation

GitHub Actions / K1 Checks

Type of "samples_config" is partially unknown   Type of "samples_config" is "dict[str, Unknown]" (reportUnknownMemberType)
"samples": config.getfloat("samples", 5, above=0.0),
"retract_dist": config.getfloat("samples_retract_dist", 5, above=0.0),
"tolerance": config.getfloat("samples_tolerance", 0.2, minval=0.0),
Expand All @@ -134,7 +134,6 @@
self.offset = {
"x": config.getfloat("x_offset", 0.0),
"y": config.getfloat("y_offset", 0.0),
"z": config.getfloat("z_offset", 0.0),
}

if config.has_section("safe_z_home"):
Expand Down Expand Up @@ -167,7 +166,7 @@
"scanner_touch_max_speed", 10, above=0, maxval=30
)
## NEW VARIABLES HERE
self.scanner_touch_config = {

Check warning on line 169 in scanner.py

View workflow job for this annotation

GitHub Actions / Standard Checks

Type of "scanner_touch_config" is partially unknown   Type of "scanner_touch_config" is "dict[str, Unknown]" (reportUnknownMemberType)

Check warning on line 169 in scanner.py

View workflow job for this annotation

GitHub Actions / K1 Checks

Type of "scanner_touch_config" is partially unknown   Type of "scanner_touch_config" is "dict[str, Unknown]" (reportUnknownMemberType)
"accel": config.getfloat("scanner_touch_accel", 100, above=0, minval=100),
"max_speed": max_speed_value,
"speed": config.getfloat("scanner_touch_speed", 3, maxval=max_speed_value),
Expand All @@ -192,7 +191,7 @@
raise self.printer.command_error(
"Please change detect_threshold_z to scanner_touch_threshold in printer.cfg"
)
self.detect_threshold_z = self.scanner_touch_config["threshold"]

Check warning on line 194 in scanner.py

View workflow job for this annotation

GitHub Actions / Standard Checks

Type of "detect_threshold_z" is unknown (reportUnknownMemberType)

Check warning on line 194 in scanner.py

View workflow job for this annotation

GitHub Actions / Standard Checks

Type of "scanner_touch_config" is partially unknown   Type of "scanner_touch_config" is "dict[str, Unknown]" (reportUnknownMemberType)

Check warning on line 194 in scanner.py

View workflow job for this annotation

GitHub Actions / K1 Checks

Type of "detect_threshold_z" is unknown (reportUnknownMemberType)

Check warning on line 194 in scanner.py

View workflow job for this annotation

GitHub Actions / K1 Checks

Type of "scanner_touch_config" is partially unknown   Type of "scanner_touch_config" is "dict[str, Unknown]" (reportUnknownMemberType)
self.previous_probe_success = None

self.cal_config = {
Expand Down Expand Up @@ -230,7 +229,7 @@
self._stream_buffer = []
self._stream_buffer_limit = STREAM_BUFFER_LIMIT_DEFAULT
self._stream_buffer_limit_new = self._stream_buffer_limit
self._stream_samples_queue = queue.Queue()

Check warning on line 232 in scanner.py

View workflow job for this annotation

GitHub Actions / Standard Checks

Type of "_stream_samples_queue" is partially unknown   Type of "_stream_samples_queue" is "Queue[Unknown]" (reportUnknownMemberType)

Check warning on line 232 in scanner.py

View workflow job for this annotation

GitHub Actions / K1 Checks

Type of "_stream_samples_queue" is partially unknown   Type of "_stream_samples_queue" is "Queue[Unknown]" (reportUnknownMemberType)
self._stream_flush_event = threading.Event()
self._log_stream = None
self._data_filter = AlphaBetaFilter(
Expand Down Expand Up @@ -266,7 +265,7 @@
)
self._mcu.register_config_callback(self._build_config)
self._mcu.register_response(
self._handle_scanner_data, self.sensor.lower() + "_data"

Check warning on line 268 in scanner.py

View workflow job for this annotation

GitHub Actions / Standard Checks

Type of "_handle_scanner_data" is partially unknown   Type of "_handle_scanner_data" is "(params: Unknown) -> None" (reportUnknownMemberType)

Check warning on line 268 in scanner.py

View workflow job for this annotation

GitHub Actions / Standard Checks

Argument type is partially unknown   Argument corresponds to parameter "callback" in function "register_response"   Argument type is "(params: Unknown) -> None" (reportUnknownArgumentType)

Check warning on line 268 in scanner.py

View workflow job for this annotation

GitHub Actions / K1 Checks

Type of "_handle_scanner_data" is partially unknown   Type of "_handle_scanner_data" is "(params: Unknown) -> None" (reportUnknownMemberType)

Check warning on line 268 in scanner.py

View workflow job for this annotation

GitHub Actions / K1 Checks

Argument type is partially unknown   Argument corresponds to parameter "callback" in function "register_response"   Argument type is "(params: Unknown) -> None" (reportUnknownArgumentType)
)
# Register webhooks
webhooks = self.printer.lookup_object("webhooks")
Expand Down Expand Up @@ -322,11 +321,6 @@
self.cmd_Z_OFFSET_APPLY_PROBE,
desc=self.cmd_Z_OFFSET_APPLY_PROBE_help,
)
self.gcode.register_command(
"SAVE_TOUCH_OFFSET",
self.cmd_SAVE_TOUCH_OFFSET,
desc=self.cmd_SAVE_TOUCH_OFFSET_help,
)

cmd_SCANNER_CALIBRATE_help = "Calibrate scanner response curve"

Expand All @@ -348,11 +342,11 @@
self.calibration_method = "scan"
self._start_calibration(gcmd)

def _get_common_variables(self, gcmd: GCodeCommand):

Check warning on line 345 in scanner.py

View workflow job for this annotation

GitHub Actions / Standard Checks

Return type, "dict[str, Unknown]", is partially unknown (reportUnknownParameterType)

Check warning on line 345 in scanner.py

View workflow job for this annotation

GitHub Actions / K1 Checks

Return type, "dict[str, Unknown]", is partially unknown (reportUnknownParameterType)
return {

Check warning on line 346 in scanner.py

View workflow job for this annotation

GitHub Actions / Standard Checks

Return type, "dict[str, Unknown]", is partially unknown (reportUnknownVariableType)

Check warning on line 346 in scanner.py

View workflow job for this annotation

GitHub Actions / K1 Checks

Return type, "dict[str, Unknown]", is partially unknown (reportUnknownVariableType)
"speed": gcmd.get_float(
"SPEED",
self.scanner_touch_config["speed"],

Check warning on line 349 in scanner.py

View workflow job for this annotation

GitHub Actions / Standard Checks

Type of "scanner_touch_config" is partially unknown   Type of "scanner_touch_config" is "dict[str, Unknown]" (reportUnknownMemberType)

Check warning on line 349 in scanner.py

View workflow job for this annotation

GitHub Actions / K1 Checks

Type of "scanner_touch_config" is partially unknown   Type of "scanner_touch_config" is "dict[str, Unknown]" (reportUnknownMemberType)
above=0,
maxval=self.scanner_touch_config["max_speed"],
),
Expand Down Expand Up @@ -1416,7 +1410,6 @@
pos[2] = status["axis_maximum"][2]
self.toolhead.set_position(pos, homing_axes=(0, 1, 2))
self.touch_probe(self.probe_speed)
pos[2] = -self.offset["z"]
self.toolhead.set_position(pos)
self._move([None, None, 0], self.lift_speed)
kin = self.toolhead.get_kinematics()
Expand Down Expand Up @@ -2276,14 +2269,6 @@
"printer config file and restart the printer."
)

cmd_SAVE_TOUCH_OFFSET_help = "Save offset to z_offset for TOUCH method"

def cmd_SAVE_TOUCH_OFFSET(self, gcmd: GCodeCommand):
gcode_move = self.printer.lookup_object("gcode_move")
offset = gcode_move.get_status()["homing_origin"].z
configfile = self.printer.lookup_object("configfile")
configfile.set("scanner", "z_offset", "%.3f" % (self.offset["z"] + offset))


class TouchSettings:
def __init__(
Expand Down Expand Up @@ -2864,7 +2849,7 @@
# After homing Z we perform a measurement and adjust the toolhead
# kinematic position.
if self.scanner.trigger_method != 0:
homing_state.set_homed_position([None, None, -self.scanner.offset["z"]])
homing_state.set_homed_position([None, None, 0])
return
(dist, samples) = self.scanner._sample(self.scanner.z_settling_time, 10)
if math.isinf(dist):
Expand Down Expand Up @@ -3164,7 +3149,7 @@
pa = (begin_a, pos_p) if even else (end_a, pos_p)
pb = (end_a, pos_p) if even else (begin_a, pos_p)

l = (pa, pb)

Check failure on line 3152 in scanner.py

View workflow job for this annotation

GitHub Actions / Standard Checks

Ruff (E741)

scanner.py:3152:13: E741 Ambiguous variable name: `l`

Check failure on line 3152 in scanner.py

View workflow job for this annotation

GitHub Actions / K1 Checks

Ruff (E741)

scanner.py:3152:13: E741 Ambiguous variable name: `l`

if len(points) > 0 and corner_radius > 0:
# We need to insert an overscan corner. Basically we insert
Expand Down
Loading