Beispiel #1
0
 def __init__(self, config, bedmesh):
     self.printer = config.get_printer()
     self.name = config.get_name()
     self.bedmesh = bedmesh
     self.probed_z_table = None
     self.build_map = False
     self.probe_params = collections.OrderedDict()
     points = self._generate_points(config)
     self._init_probe_params(config, points)
     self.probe_helper = probe.ProbePointsHelper(config,
                                                 self.probe_finalize,
                                                 points)
     # setup persistent storage
     self.profiles = {}
     self._load_storage(config)
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command('BED_MESH_CALIBRATE',
                                 self.cmd_BED_MESH_CALIBRATE,
                                 desc=self.cmd_BED_MESH_CALIBRATE_help)
     self.gcode.register_command('BED_MESH_MAP',
                                 self.cmd_BED_MESH_MAP,
                                 desc=self.cmd_BED_MESH_MAP_help)
     self.gcode.register_command('BED_MESH_PROFILE',
                                 self.cmd_BED_MESH_PROFILE,
                                 desc=self.cmd_BED_MESH_PROFILE_help)
Beispiel #2
0
 def __init__(self, config):
     self.printer = config.get_printer()
     self.probe_helper = probe.ProbePointsHelper(config, self)
     probe_location = config.get('probe_location').split(',')
     gantry_corners = config.get('gantry_corners').split('\n')
     try:
         gantry_corners = [
             line.split(',', 1) for line in gantry_corners if line.strip()
         ]
         self.gantry_corners = [(float(zp[0].strip()), float(zp[1].strip()))
                                for zp in gantry_corners]
     except:
         raise config.error("Unable to parse gantry_corners in %s" %
                            (config.get_name()))
     if len(gantry_corners) < 2:
         raise config.error(
             "ganry_level requires at least two gantry_corners")
     self.probe_location = [
         float(probe_location[0].strip()),
         float(probe_location[1].strip())
     ]
     self.z_steppers = []
     # Register GANTRY_LEVEL command
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command('GANTRY_LEVEL',
                                 self.cmd_GANTRY_LEVEL,
                                 desc=self.cmd_GANTRY_LEVEL_help)
Beispiel #3
0
 def __init__(self, config):
     self.printer = config.get_printer()
     self.retry_helper = z_tilt.RetryHelper(
         config, "Possibly Z motor numbering is wrong")
     self.max_adjust = config.getfloat("max_adjust", 4, above=0)
     self.horizontal_move_z = config.getfloat("horizontal_move_z", 5.0)
     self.probe_helper = probe.ProbePointsHelper(config,
                                                 self.probe_finalize)
     if len(self.probe_helper.probe_points) != 4:
         raise config.error(
             "Need exactly 4 probe points for quad_gantry_level")
     self.z_helper = z_tilt.ZAdjustHelper(config, 4)
     gantry_corners = config.get('gantry_corners').split('\n')
     try:
         gantry_corners = [
             line.split(',', 1) for line in gantry_corners if line.strip()
         ]
         self.gantry_corners = [(float(zp[0].strip()), float(zp[1].strip()))
                                for zp in gantry_corners]
     except:
         raise config.error("Unable to parse gantry_corners in %s" %
                            (config.get_name()))
     if len(self.gantry_corners) < 2:
         raise config.error(
             "quad_gantry_level requires at least two gantry_corners")
     # Register QUAD_GANTRY_LEVEL command
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command('QUAD_GANTRY_LEVEL',
                                 self.cmd_QUAD_GANTRY_LEVEL,
                                 desc=self.cmd_QUAD_GANTRY_LEVEL_help)
Beispiel #4
0
 def __init__(self, config, bedmesh):
     self.printer = config.get_printer()
     self.name = config.get_name()
     self.radius = self.origin = None
     self.relative_reference_index = config.getint(
         'relative_reference_index', None)
     self.bedmesh = bedmesh
     self.probed_matrix = None
     self.mesh_params = collections.OrderedDict()
     self.points = self._generate_points(config)
     self._init_mesh_params(config, self.points)
     self.probe_helper = probe.ProbePointsHelper(config,
                                                 self.probe_finalize,
                                                 self.points)
     self.probe_helper.minimum_points(3)
     self.probe_helper.use_xy_offsets(True)
     # setup persistent storage
     self.profiles = {}
     self.incompatible_profiles = []
     self._load_storage(config)
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command('BED_MESH_CALIBRATE',
                                 self.cmd_BED_MESH_CALIBRATE,
                                 desc=self.cmd_BED_MESH_CALIBRATE_help)
     self.gcode.register_command('BED_MESH_PROFILE',
                                 self.cmd_BED_MESH_PROFILE,
                                 desc=self.cmd_BED_MESH_PROFILE_help)
Beispiel #5
0
 def __init__(self, config):
     self.printer = config.get_printer()
     self.printer.register_event_handler("klippy:connect",
                                         self.handle_connect)
     self.probe_helper = probe.ProbePointsHelper(config,
                                                 self.probe_finalize)
     gantry_corners = config.get('gantry_corners').split('\n')
     try:
         gantry_corners = [
             line.split(',', 1) for line in gantry_corners if line.strip()
         ]
         self.gantry_corners = [(float(zp[0].strip()), float(zp[1].strip()))
                                for zp in gantry_corners]
     except:
         raise config.error("Unable to parse gantry_corners in %s" %
                            (config.get_name()))
     if len(self.gantry_corners) < 2:
         raise config.error(
             "quad_gantry_level requires at least two gantry_corners")
     self.z_steppers = []
     # Register QUAD_GANTRY_LEVEL command
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command('QUAD_GANTRY_LEVEL',
                                 self.cmd_QUAD_GANTRY_LEVEL,
                                 desc=self.cmd_QUAD_GANTRY_LEVEL_help)
Beispiel #6
0
 def __init__(self, config):
     self.config = config
     self.printer = config.get_printer()
     self.screws = []
     # Read config
     for i in range(99):
         prefix = "screw%d" % (i + 1,)
         if config.get(prefix, None) is None:
             break
         screw_coord = parse_coord(config, prefix)
         screw_name = "screw at %.3f,%.3f" % screw_coord
         screw_name = config.get(prefix + "_name", screw_name)
         self.screws.append((screw_coord, screw_name))
     if len(self.screws) < 3:
         raise config.error("screws_tilt_adjust: Must have "
                            "at least three screws")
     self.threads = {'CW-M3': 0, 'CCW-M3': 1, 'CW-M4': 2, 'CCW-M4': 3,
                     'CW-M5': 4, 'CCW-M5': 5}
     self.thread = config.getchoice('screw_thread', self.threads,
                                    default='CW-M3')
     # Initialize ProbePointsHelper
     points = [coord for coord, name in self.screws]
     self.probe_helper = probe.ProbePointsHelper(self.config,
                                                 self.probe_finalize,
                                                 default_points=points)
     self.probe_helper.minimum_points(3)
     # Register command
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command("SCREWS_TILT_CALCULATE",
                                 self.cmd_SCREWS_TILT_CALCULATE,
                                 desc=self.cmd_SCREWS_TILT_CALCULATE_help)
Beispiel #7
0
 def __init__(self, config, bedtilt):
     self.printer = config.get_printer()
     self.bedtilt = bedtilt
     self.probe_helper = probe.ProbePointsHelper(config,
                                                 self.probe_finalize)
     # Register BED_TILT_CALIBRATE command
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command('BED_TILT_CALIBRATE',
                                 self.cmd_BED_TILT_CALIBRATE,
                                 desc=self.cmd_BED_TILT_CALIBRATE_help)
Beispiel #8
0
 def cmd_DELTA_CALIBRATE(self, params):
     # Setup probe points
     points = [(0., 0.)]
     scatter = [.95, .90, .85, .70, .75, .80]
     for i in range(6):
         r = math.radians(90. + 60. * i)
         dist = self.radius * scatter[i]
         points.append((math.cos(r) * dist, math.sin(r) * dist))
     # Probe them
     self.gcode.run_script("G28")
     probe.ProbePointsHelper(self.printer, points, self.horizontal_move_z,
                             self.speed, self.manual_probe, self)
Beispiel #9
0
 def __init__(self, config):
     self.printer = config.get_printer()
     self.printer.register_event_handler("klippy:connect",
                                         self.handle_connect)
     # Calculate default probing points
     radius = config.getfloat('radius', above=0.)
     points = [(0., 0.)]
     scatter = [.95, .90, .85, .70, .75, .80]
     for i in range(6):
         r = math.radians(90. + 60. * i)
         dist = radius * scatter[i]
         points.append((math.cos(r) * dist, math.sin(r) * dist))
     self.probe_helper = probe.ProbePointsHelper(config,
                                                 self.probe_finalize,
                                                 default_points=points)
     self.probe_helper.minimum_points(3)
     # Restore probe stable positions
     self.last_probe_positions = []
     for i in range(999):
         height = config.getfloat("height%d" % (i, ), None)
         if height is None:
             break
         height_pos = load_config_stable(config, "height%d_pos" % (i, ))
         self.last_probe_positions.append((height, height_pos))
     # Restore manually entered heights
     self.manual_heights = []
     for i in range(999):
         height = config.getfloat("manual_height%d" % (i, ), None)
         if height is None:
             break
         height_pos = load_config_stable(config,
                                         "manual_height%d_pos" % (i, ))
         self.manual_heights.append((height, height_pos))
     # Restore distance measurements
     self.delta_analyze_entry = {'SCALE': (1., )}
     self.last_distances = []
     for i in range(999):
         dist = config.getfloat("distance%d" % (i, ), None)
         if dist is None:
             break
         distance_pos1 = load_config_stable(config,
                                            "distance%d_pos1" % (i, ))
         distance_pos2 = load_config_stable(config,
                                            "distance%d_pos2" % (i, ))
         self.last_distances.append((dist, distance_pos1, distance_pos2))
     # Register gcode commands
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command('DELTA_CALIBRATE',
                                 self.cmd_DELTA_CALIBRATE,
                                 desc=self.cmd_DELTA_CALIBRATE_help)
     self.gcode.register_command('DELTA_ANALYZE',
                                 self.cmd_DELTA_ANALYZE,
                                 desc=self.cmd_DELTA_ANALYZE_help)
Beispiel #10
0
 def __init__(self, config, bedtilt):
     self.printer = config.get_printer()
     self.bedtilt = bedtilt
     self.probe_helper = probe.ProbePointsHelper(config, self)
     # Automatic probe:z_virtual_endstop XY detection
     self.z_position_endstop = None
     if config.has_section('stepper_z'):
         zconfig = config.getsection('stepper_z')
         self.z_position_endstop = zconfig.getfloat('position_endstop', None)
     # Register BED_TILT_CALIBRATE command
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command(
         'BED_TILT_CALIBRATE', self.cmd_BED_TILT_CALIBRATE,
         desc=self.cmd_BED_TILT_CALIBRATE_help)
Beispiel #11
0
 def __init__(self, config):
     self.printer = config.get_printer()
     if config.getsection('printer').get('kinematics') != 'delta':
         raise config.error("Delta calibrate is only for delta printers")
     # Calculate default probing points
     radius = config.getfloat('radius', above=0.)
     points = [(0., 0.)]
     scatter = [.95, .90, .85, .70, .75, .80]
     for i in range(6):
         r = math.radians(90. + 60. * i)
         dist = radius * scatter[i]
         points.append((math.cos(r) * dist, math.sin(r) * dist))
     self.probe_helper = probe.ProbePointsHelper(
         config, self, default_points=points)
     # Register DELTA_CALIBRATE command
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command(
         'DELTA_CALIBRATE', self.cmd_DELTA_CALIBRATE,
         desc=self.cmd_DELTA_CALIBRATE_help)
 def __init__(self, config):
     self.printer = config.get_printer()
     z_positions = config.get('z_positions').split('\n')
     try:
         z_positions = [line.split(',', 1)
                        for line in z_positions if line.strip()]
         self.z_positions = [(float(zp[0].strip()), float(zp[1].strip()))
                             for zp in z_positions]
     except:
         raise config.error("Unable to parse z_positions in %s" % (
             config.get_name()))
     self.retry_helper = RetryHelper(config)
     self.probe_helper = probe.ProbePointsHelper(config, self.probe_finalize)
     self.probe_helper.minimum_points(2)
     self.z_helper = ZAdjustHelper(config, len(self.z_positions))
     # Register Z_TILT_ADJUST command
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command('Z_TILT_ADJUST', self.cmd_Z_TILT_ADJUST,
                                 desc=self.cmd_Z_TILT_ADJUST_help)
Beispiel #13
0
 def __init__(self, config):
     self.printer = config.get_printer()
     if config.getsection('printer').get('kinematics') != 'delta':
         raise config.error("Delta calibrate is only for delta printers")
     # Calculate default probing points
     radius = config.getfloat('radius', above=0.)
     points = [(0., 0.)]
     scatter = [.95, .90, .85, .70, .75, .80]
     for i in range(6):
         r = math.radians(90. + 60. * i)
         dist = radius * scatter[i]
         points.append((math.cos(r) * dist, math.sin(r) * dist))
     self.probe_helper = probe.ProbePointsHelper(config,
                                                 self,
                                                 default_points=points)
     # Restore probe stable positions
     self.last_probe_positions = []
     for i in range(999):
         height = config.getfloat("height%d" % (i, ), None)
         if height is None:
             break
         height_pos = load_config_stable(config, "height%d_pos" % (i, ))
         self.last_probe_positions.append((height, height_pos))
     # Restore distance measurements
     self.delta_analyze_entry = {'SCALE': (1., )}
     self.last_distances = []
     for i in range(999):
         dist = config.getfloat("distance%d" % (i, ), None)
         if dist is None:
             break
         distance_pos1 = load_config_stable(config,
                                            "distance%d_pos1" % (i, ))
         distance_pos2 = load_config_stable(config,
                                            "distance%d_pos2" % (i, ))
         self.last_distances.append((dist, distance_pos1, distance_pos2))
     # Register gcode commands
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command('DELTA_CALIBRATE',
                                 self.cmd_DELTA_CALIBRATE,
                                 desc=self.cmd_DELTA_CALIBRATE_help)
     self.gcode.register_command('DELTA_ANALYZE',
                                 self.cmd_DELTA_ANALYZE,
                                 desc=self.cmd_DELTA_ANALYZE_help)
Beispiel #14
0
 def __init__(self, config):
     self.printer = config.get_printer()
     z_positions = config.get('z_positions').split('\n')
     try:
         z_positions = [line.split(',', 1)
                        for line in z_positions if line.strip()]
         self.z_positions = [(float(zp[0].strip()), float(zp[1].strip()))
                             for zp in z_positions]
     except:
         raise config.error("Unable to parse z_positions in %s" % (
             config.get_name()))
     if len(z_positions) < 2:
         raise config.error("z_tilt requires at least two z_positions")
     self.probe_helper = probe.ProbePointsHelper(config, self.probe_finalize)
     self.z_steppers = []
     # Register Z_TILT_ADJUST command
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command(
         'Z_TILT_ADJUST', self.cmd_Z_TILT_ADJUST,
         desc=self.cmd_Z_TILT_ADJUST_help)
Beispiel #15
0
 def __init__(self, config, bedmesh):
     self.printer = config.get_printer()
     self.bedmesh = bedmesh
     self.probed_z_table = None
     self.build_map = False
     self.probe_params = {}
     points = self._generate_points(config)
     self._init_probe_params(config, points)
     self.probe_helper = probe.ProbePointsHelper(config, self, points)
     self.z_endstop_pos = None
     if config.has_section('stepper_z'):
         zconfig = config.getsection('stepper_z')
         self.z_endstop_pos = zconfig.getfloat('position_endstop', None)
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command('BED_MESH_CALIBRATE',
                                 self.cmd_BED_MESH_CALIBRATE,
                                 desc=self.cmd_BED_MESH_CALIBRATE_help)
     self.gcode.register_command('BED_MESH_MAP',
                                 self.cmd_BED_MESH_MAP,
                                 desc=self.cmd_BED_MESH_MAP_help)
Beispiel #16
0
 def __init__(self, config, bedmesh):
     self.printer = config.get_printer()
     self.bedmesh = bedmesh
     #TODO: Instead of calculating probe points, add them to config
     self.probe_helper = probe.ProbePointsHelper(
         config, self, self.calculate_probe_points())
     # Automatic probe:z_virtual_endstop XY detection
     self.z_position_endstop = None
     if config.has_section('stepper_z'):
         zconfig = config.getsection('stepper_z')
         self.z_position_endstop = zconfig.getfloat('position_endstop',
                                                    None)
     # Register MESH_BED_LEVING command
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_command('BED_MESH_CALIBRATE',
                                 self.cmd_BED_MESH_CALIBRATE,
                                 desc=self.cmd_BED_MESH_CALIBRATE_help)
     # Register G80 as alias
     self.gcode.register_command('G80',
                                 self.cmd_BED_MESH_CALIBRATE,
                                 desc=self.cmd_BED_MESH_CALIBRATE_help)
Beispiel #17
0
 def cmd_BED_TILT_CALIBRATE(self, params):
     self.gcode.run_script("G28")
     probe.ProbePointsHelper(
         self.printer, self.points, self.horizontal_move_z,
         self.speed, self.manual_probe, self)
    def __init__(self, config):
        self.printer = config.get_printer()
        self.printer.register_event_handler("klippy:ready", self.handle_ready)
        self.retry_helper = z_tilt.RetryHelper(
            config, "Possibly Z motor numbering is wrong")
        self.max_adjust = config.getfloat("max_adjust", 4, above=0)
        self.horizontal_move_z = config.getfloat("horizontal_move_z", 5.0)
        self.probe_helper = probe.ProbePointsHelper(config,
                                                    self.probe_finalize)
        if len(self.probe_helper.probe_points) != 4:
            raise config.error(
                "Need exactly 4 probe points for quad_gantry_level")
        self.default_adjust = [Decimal(0), Decimal(0), Decimal(0), Decimal(0)]
        self.z_mesh_matrix = None
        self.last_position = [0., 0., 0., 0.]
        self.load_custom_data()
        gantry_corners = config.get('gantry_corners').split('\n')
        try:
            gantry_corners = [
                line.split(',', 1) for line in gantry_corners if line.strip()
            ]
            self.gantry_corners = [(Decimal(zp[0].strip()),
                                    Decimal(zp[1].strip()))
                                   for zp in gantry_corners]
        except:
            raise config.error("Unable to parse gantry_corners in %s" %
                               (config.get_name()))
        if len(self.gantry_corners) < 2:
            raise config.error(
                "quad_gantry_level requires at least two gantry_corners")
        # Register QUAD_GANTRY_LEVEL command
        self.gcode = self.printer.lookup_object('gcode')
        self.gcode.register_command('QUAD_GANTRY_LEVEL',
                                    self.cmd_QUAD_GANTRY_LEVEL,
                                    desc=self.cmd_QUAD_GANTRY_LEVEL_help)
        self.gcode.register_command('QUAD_GANTRY_MANUAL',
                                    self.cmd_QUAD_GANTRY_MANUAL,
                                    desc=self.cmd_QUAD_GANTRY_MANUAL_help)
        self.gcode.register_command('QUAD_GANTRY_ADJUST',
                                    self.cmd_QUAD_GANTRY_ADJUST,
                                    desc=self.cmd_QUAD_GANTRY_ADJUST_help)

        self.tool_head = None
        self.z_mesh = None
        self.use_additional_z_mesh = config.getboolean("use_additional_z_mesh",
                                                       False)
        if self.use_additional_z_mesh:
            self.gcode.register_command(
                'QUAD_BED_MESH_ADJUST',
                self.cmd_QUAD_BED_MESH_ADJUST,
                desc=self.cmd_cmd_QUAD_BED_MESH_ADJUST_help)
            self.gcode.register_command('QUAD_BED_MESH_CLEAR',
                                        self.cmd_QUAD_BED_MESH_CLEAR,
                                        desc=self.cmd_QUAD_BED_MESH_CLEAR_help)
            self.gcode.register_command('QUAD_PRINT_BED_MESH',
                                        self.cmd_QUAD_PRINT_BED_MESH,
                                        desc=self.cmd_QUAD_PRINT_BED_MESH_help)

            self.mesh_params = collections.OrderedDict()
            self.mesh_params['algo'] = 'direct'

            size = bed_mesh.parse_pair(config, ('probe_count', '3'),
                                       check=False,
                                       cast=int,
                                       minval=3)
            # rectangular
            min = bed_mesh.parse_pair(config, ('mesh_min', ))
            max = bed_mesh.parse_pair(config, ('mesh_max', ))
            # pps = bed_mesh.parse_pair(config, ('mesh_pps', '2'), check=False, cast=int, minval=0)

            x_cnt, y_cnt = size
            min_x, min_y = min
            max_x, max_y = max
            pps = [0, 0]

            if self.z_mesh_matrix is not None:
                row_count = len(self.z_mesh_matrix)
                column_count = len(self.z_mesh_matrix[0])
                if row_count * column_count != x_cnt * y_cnt:
                    self.z_mesh_matrix = None

            if max_x <= min_x or max_y <= min_y:
                raise config.error('bed_mesh: invalid min/max points')

            self.mesh_params['x_count'] = x_cnt
            self.mesh_params['y_count'] = y_cnt
            self.mesh_params['min_x'] = min_x
            self.mesh_params['max_x'] = max_x
            self.mesh_params['min_y'] = min_y
            self.mesh_params['max_y'] = max_y
            self.mesh_params['mesh_x_pps'] = pps[0]
            self.mesh_params['mesh_y_pps'] = pps[1]

            try:
                self.points = self._generate_points(size, min, max)
            except Exception as e:
                raise config.error(str(e))
            self.fade_start = config.getfloat('fade_start', 1.)
            self.fade_end = config.getfloat('fade_end', 0.)
            self.fade_dist = self.fade_end - self.fade_start
            if self.fade_dist <= 0.:
                self.fade_start = self.fade_end = self.FADE_DISABLE

            self.log_fade_complete = False
            self.base_fade_target = config.getfloat('fade_target', None)
            self.fade_target = 0.
            self.splitter = bed_mesh.MoveSplitter(config, self.gcode)
            self.gcode.set_move_transform(self)