resonance_tester: Support CHIPS= parameter in SHAPER_CALIBRATE command
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
This commit is contained in:
parent
ec61f10f0f
commit
16c53992d6
|
@ -1018,7 +1018,7 @@ frequency response is calculated (across all probe points) and written into
|
||||||
|
|
||||||
#### SHAPER_CALIBRATE
|
#### SHAPER_CALIBRATE
|
||||||
`SHAPER_CALIBRATE [AXIS=<axis>] [NAME=<name>] [FREQ_START=<min_freq>]
|
`SHAPER_CALIBRATE [AXIS=<axis>] [NAME=<name>] [FREQ_START=<min_freq>]
|
||||||
[FREQ_END=<max_freq>] [HZ_PER_SEC=<hz_per_sec>]
|
[FREQ_END=<max_freq>] [HZ_PER_SEC=<hz_per_sec>] [CHIPS=<adxl345_chip_name>]
|
||||||
[MAX_SMOOTHING=<max_smoothing>]`: Similarly to `TEST_RESONANCES`, runs
|
[MAX_SMOOTHING=<max_smoothing>]`: Similarly to `TEST_RESONANCES`, runs
|
||||||
the resonance test as configured, and tries to find the optimal
|
the resonance test as configured, and tries to find the optimal
|
||||||
parameters for the input shaper for the requested axis (or both X and
|
parameters for the input shaper for the requested axis (or both X and
|
||||||
|
|
|
@ -207,11 +207,21 @@ class ResonanceTester:
|
||||||
else:
|
else:
|
||||||
calibration_data[axis].add_data(new_data)
|
calibration_data[axis].add_data(new_data)
|
||||||
return calibration_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")
|
cmd_TEST_RESONANCES_help = ("Runs the resonance test for a specifed axis")
|
||||||
def cmd_TEST_RESONANCES(self, gcmd):
|
def cmd_TEST_RESONANCES(self, gcmd):
|
||||||
# Parse parameters
|
# Parse parameters
|
||||||
axis = _parse_axis(gcmd, gcmd.get("AXIS").lower())
|
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)
|
test_point = gcmd.get("POINT", None)
|
||||||
|
|
||||||
if test_point:
|
if test_point:
|
||||||
|
@ -224,15 +234,7 @@ class ResonanceTester:
|
||||||
raise gcmd.error("Invalid POINT parameter, must be 'x,y,z'"
|
raise gcmd.error("Invalid POINT parameter, must be 'x,y,z'"
|
||||||
" where x, y and z are valid floating point numbers")
|
" where x, y and z are valid floating point numbers")
|
||||||
|
|
||||||
if accel_chips:
|
accel_chips = self._parse_chips(chips_str) if chips_str else None
|
||||||
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)
|
|
||||||
|
|
||||||
outputs = gcmd.get("OUTPUT", "resonances").lower().split(',')
|
outputs = gcmd.get("OUTPUT", "resonances").lower().split(',')
|
||||||
for output in outputs:
|
for output in outputs:
|
||||||
|
@ -257,8 +259,7 @@ class ResonanceTester:
|
||||||
data = self._run_test(
|
data = self._run_test(
|
||||||
gcmd, [axis], helper,
|
gcmd, [axis], helper,
|
||||||
raw_name_suffix=name_suffix if raw_output else None,
|
raw_name_suffix=name_suffix if raw_output else None,
|
||||||
accel_chips=parsed_chips if accel_chips else None,
|
accel_chips=accel_chips, test_point=test_point)[axis]
|
||||||
test_point=test_point)[axis]
|
|
||||||
if csv_output:
|
if csv_output:
|
||||||
csv_name = self.save_calibration_data('resonances', name_suffix,
|
csv_name = self.save_calibration_data('resonances', name_suffix,
|
||||||
helper, axis, data,
|
helper, axis, data,
|
||||||
|
@ -276,6 +277,8 @@ class ResonanceTester:
|
||||||
raise gcmd.error("Unsupported axis '%s'" % (axis,))
|
raise gcmd.error("Unsupported axis '%s'" % (axis,))
|
||||||
else:
|
else:
|
||||||
calibrate_axes = [TestAxis(axis.lower())]
|
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 = gcmd.get_float(
|
||||||
"MAX_SMOOTHING", self.max_smoothing, minval=0.05)
|
"MAX_SMOOTHING", self.max_smoothing, minval=0.05)
|
||||||
|
@ -287,7 +290,8 @@ class ResonanceTester:
|
||||||
# Setup shaper calibration
|
# Setup shaper calibration
|
||||||
helper = shaper_calibrate.ShaperCalibrate(self.printer)
|
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')
|
configfile = self.printer.lookup_object('configfile')
|
||||||
for axis in calibrate_axes:
|
for axis in calibrate_axes:
|
||||||
|
|
Loading…
Reference in New Issue