Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xD34D committed Jun 14, 2024
2 parents 95109a6 + fcf064b commit 6c416fd
Show file tree
Hide file tree
Showing 17 changed files with 778 additions and 505 deletions.
14 changes: 9 additions & 5 deletions klippy/extras/axis_twist_compensation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ def __init__(self, config):

# setup calibrater
self.calibrater = Calibrater(self, config)
# register events
self.printer.register_event_handler("probe:update_results",
self._update_z_compensation_value)

def get_z_compensation_value(self, pos):
def _update_z_compensation_value(self, pos):
if not self.z_compensations:
return 0
return

x_coord = pos[0]
z_compensations = self.z_compensations
Expand All @@ -55,7 +58,7 @@ def get_z_compensation_value(self, pos):
interpolated_z_compensation = BedMesh.lerp(
interpolate_t, z_compensations[interpolate_i],
z_compensations[interpolate_i + 1])
return interpolated_z_compensation
pos[2] += interpolated_z_compensation

def clear_compensations(self):
self.z_compensations = []
Expand Down Expand Up @@ -95,7 +98,7 @@ def _handle_connect(self):
config = self.printer.lookup_object('configfile')
raise config.error(
"AXIS_TWIST_COMPENSATION requires [probe] to be defined")
self.lift_speed = self.probe.get_lift_speed()
self.lift_speed = self.probe.get_probe_params()['lift_speed']
self.probe_x_offset, self.probe_y_offset, _ = \
self.probe.get_offsets()

Expand Down Expand Up @@ -186,7 +189,8 @@ def _calibration(self, probe_points, nozzle_points, interval):
probe_points[self.current_point_index][1], None))

# probe the point
self.current_measured_z = self.probe.run_probe(self.gcmd)[2]
pos = probe.run_single_probe(self.probe, self.gcmd)
self.current_measured_z = pos[2]

# horizontal_move_z (to prevent probe trigger or hitting bed)
self._move_helper((None, None, self.horizontal_move_z))
Expand Down
42 changes: 23 additions & 19 deletions klippy/extras/bltouch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BLTouch support
#
# Copyright (C) 2018-2021 Kevin O'Connor <[email protected]>
# Copyright (C) 2018-2024 Kevin O'Connor <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
Expand All @@ -23,13 +23,9 @@
}

# BLTouch "endstop" wrapper
class BLTouchEndstopWrapper:
class BLTouchProbe:
def __init__(self, config):
self.printer = config.get_printer()
self.printer.register_event_handler("klippy:connect",
self.handle_connect)
self.printer.register_event_handler('klippy:mcu_identify',
self.handle_mcu_identify)
self.position_endstop = config.getfloat('z_offset', minval=0.)
self.stow_on_each_sample = config.getboolean('stow_on_each_sample',
True)
Expand All @@ -44,10 +40,7 @@ def __init__(self, config):
self.next_cmd_time = self.action_end_time = 0.
self.finish_home_complete = self.wait_trigger_complete = None
# Create an "endstop" object to handle the sensor pin
pin = config.get('sensor_pin')
pin_params = ppins.lookup_pin(pin, can_invert=True, can_pullup=True)
mcu = pin_params['chip']
self.mcu_endstop = mcu.setup_pin('endstop', pin_params)
self.mcu_endstop = ppins.setup_pin('endstop', config.get('sensor_pin'))
# output mode
omodes = {'5V': '5V', 'OD': 'OD', None: None}
self.output_mode = config.getchoice('set_output_mode', omodes, None)
Expand All @@ -65,19 +58,30 @@ def __init__(self, config):
self.get_steppers = self.mcu_endstop.get_steppers
self.home_wait = self.mcu_endstop.home_wait
self.query_endstop = self.mcu_endstop.query_endstop
# multi probes state
self.multi = 'OFF'
# Common probe implementation helpers
self.cmd_helper = probe.ProbeCommandHelper(
config, self, self.mcu_endstop.query_endstop)
self.probe_offsets = probe.ProbeOffsetsHelper(config)
self.probe_session = probe.ProbeSessionHelper(config, self)
# Register BLTOUCH_DEBUG command
self.gcode = self.printer.lookup_object('gcode')
self.gcode.register_command("BLTOUCH_DEBUG", self.cmd_BLTOUCH_DEBUG,
desc=self.cmd_BLTOUCH_DEBUG_help)
self.gcode.register_command("BLTOUCH_STORE", self.cmd_BLTOUCH_STORE,
desc=self.cmd_BLTOUCH_STORE_help)
# multi probes state
self.multi = 'OFF'
def handle_mcu_identify(self):
kin = self.printer.lookup_object('toolhead').get_kinematics()
for stepper in kin.get_steppers():
if stepper.is_active_axis('z'):
self.add_stepper(stepper)
# Register events
self.printer.register_event_handler("klippy:connect",
self.handle_connect)
def get_probe_params(self, gcmd=None):
return self.probe_session.get_probe_params(gcmd)
def get_offsets(self):
return self.probe_offsets.get_offsets()
def get_status(self, eventtime):
return self.cmd_helper.get_status(eventtime)
def start_probe_session(self, gcmd):
return self.probe_session.start_probe_session(gcmd)
def handle_connect(self):
self.sync_mcu_print_time()
self.next_cmd_time += 0.200
Expand Down Expand Up @@ -278,6 +282,6 @@ def cmd_BLTOUCH_STORE(self, gcmd):
self.sync_print_time()

def load_config(config):
blt = BLTouchEndstopWrapper(config)
config.get_printer().add_object('probe', probe.PrinterProbe(config, blt))
blt = BLTouchProbe(config)
config.get_printer().add_object('probe', blt)
return blt
2 changes: 1 addition & 1 deletion klippy/extras/bulk_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def get_time_translation(self):
inv_freq = clock_to_print_time(base_mcu + inv_cfreq) - base_time
return base_time, base_chip, inv_freq

MAX_BULK_MSG_SIZE = 52
MAX_BULK_MSG_SIZE = 51

# Read sensor_bulk_data and calculate timestamps for devices that take
# samples at a fixed frequency (and produce fixed data size samples).
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/ldc1612.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _build_config(self):
cmdqueue = self.i2c.get_command_queue()
self.query_ldc1612_cmd = self.mcu.lookup_command(
"query_ldc1612 oid=%c rest_ticks=%u", cq=cmdqueue)
self.ffreader.setup_query_command("query_ldc1612_status oid=%c",
self.ffreader.setup_query_command("query_status_ldc1612 oid=%c",
oid=self.oid, cq=cmdqueue)
self.ldc1612_setup_home_cmd = self.mcu.lookup_command(
"ldc1612_setup_home oid=%c clock=%u threshold=%u"
Expand Down
Loading

0 comments on commit 6c416fd

Please sign in to comment.