diff options
author | Dmitry Butyugin <dmbutyugin@google.com> | 2023-04-19 23:22:44 +0200 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2023-05-25 12:48:17 -0400 |
commit | 16c53992d62e17a6dcdef7a8a0a5fbfb57ea7111 (patch) | |
tree | f829edbea0c13db6aadb18ba12c689123c75949e /klippy | |
parent | ec61f10f0f103bad9c754e4b97c57196581ed369 (diff) | |
download | kutter-16c53992d62e17a6dcdef7a8a0a5fbfb57ea7111.tar.gz kutter-16c53992d62e17a6dcdef7a8a0a5fbfb57ea7111.tar.xz kutter-16c53992d62e17a6dcdef7a8a0a5fbfb57ea7111.zip |
resonance_tester: Support CHIPS= parameter in SHAPER_CALIBRATE command
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Diffstat (limited to 'klippy')
-rw-r--r-- | klippy/extras/resonance_tester.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/klippy/extras/resonance_tester.py b/klippy/extras/resonance_tester.py index db03e320..819d8155 100644 --- a/klippy/extras/resonance_tester.py +++ b/klippy/extras/resonance_tester.py @@ -207,11 +207,21 @@ class ResonanceTester: else: calibration_data[axis].add_data(new_data) return calibration_data + def _parse_chips(self, accel_chips): + parsed_chips = [] + for chip_name in accel_chips.split(','): + if "adxl345" in chip_name: + chip_lookup_name = chip_name.strip() + else: + chip_lookup_name = "adxl345 " + chip_name.strip(); + chip = self.printer.lookup_object(chip_lookup_name) + parsed_chips.append(chip) + return parsed_chips cmd_TEST_RESONANCES_help = ("Runs the resonance test for a specifed axis") def cmd_TEST_RESONANCES(self, gcmd): # Parse parameters axis = _parse_axis(gcmd, gcmd.get("AXIS").lower()) - accel_chips = gcmd.get("CHIPS", None) + chips_str = gcmd.get("CHIPS", None) test_point = gcmd.get("POINT", None) if test_point: @@ -224,15 +234,7 @@ class ResonanceTester: raise gcmd.error("Invalid POINT parameter, must be 'x,y,z'" " where x, y and z are valid floating point numbers") - if accel_chips: - parsed_chips = [] - for chip_name in accel_chips.split(','): - if "adxl345" in chip_name: - chip_lookup_name = chip_name.strip() - else: - chip_lookup_name = "adxl345 " + chip_name.strip(); - chip = self.printer.lookup_object(chip_lookup_name) - parsed_chips.append(chip) + accel_chips = self._parse_chips(chips_str) if chips_str else None outputs = gcmd.get("OUTPUT", "resonances").lower().split(',') for output in outputs: @@ -257,8 +259,7 @@ class ResonanceTester: data = self._run_test( gcmd, [axis], helper, raw_name_suffix=name_suffix if raw_output else None, - accel_chips=parsed_chips if accel_chips else None, - test_point=test_point)[axis] + accel_chips=accel_chips, test_point=test_point)[axis] if csv_output: csv_name = self.save_calibration_data('resonances', name_suffix, helper, axis, data, @@ -276,6 +277,8 @@ class ResonanceTester: raise gcmd.error("Unsupported axis '%s'" % (axis,)) else: calibrate_axes = [TestAxis(axis.lower())] + chips_str = gcmd.get("CHIPS", None) + accel_chips = self._parse_chips(chips_str) if chips_str else None max_smoothing = gcmd.get_float( "MAX_SMOOTHING", self.max_smoothing, minval=0.05) @@ -287,7 +290,8 @@ class ResonanceTester: # Setup shaper calibration helper = shaper_calibrate.ShaperCalibrate(self.printer) - calibration_data = self._run_test(gcmd, calibrate_axes, helper) + calibration_data = self._run_test(gcmd, calibrate_axes, helper, + accel_chips=accel_chips) configfile = self.printer.lookup_object('configfile') for axis in calibrate_axes: |