Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeanon committed Jan 2, 2025
1 parent ef3ffec commit 6b5555a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion shaketune/commands/axes_shaper_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def axes_shaper_calibration(gcmd, config, st_process: ShakeTuneProcess) -> None:
ConsoleOutput.print(f'{config["axis"].upper()} axis frequency profile generation...')
ConsoleOutput.print('This may take some time (1-3min)')
measurements_manager.wait_for_data_transfers(printer.get_reactor())
st_process.get_graph_creator().configure(scv, max_sm, test_params, max_scale)
st_process.get_graph_creator().configure(scv, max_sm, test_params, max_scale, include_smoothers)
st_process.run(measurements_manager)
st_process.wait_for_completion()
toolhead.dwell(1)
Expand Down
9 changes: 7 additions & 2 deletions shaketune/graph_creators/shaper_graph_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ def configure(
max_smoothing: Optional[float] = None,
test_params: Optional[testParams] = None,
max_scale: Optional[int] = None,
include_smoothers: Optional[bool] = None,
) -> None:
self._scv = scv
self._max_smoothing = max_smoothing
self._test_params = test_params
self._max_scale = max_scale
self._include_smoothers = include_smoothers

def create_graph(self, measurements_manager: MeasurementsManager) -> None:
computer = ShaperGraphComputation(
Expand Down Expand Up @@ -98,6 +100,7 @@ def __init__(
max_freq: float,
max_scale: Optional[int],
st_version: str,
include_smoothers: bool,
):
self.measurements = measurements
self.test_params = test_params
Expand All @@ -106,6 +109,7 @@ def __init__(
self.max_freq = max_freq
self.max_scale = max_scale
self.st_version = st_version
self.include_smoothers = include_smoothers

def compute(self):
if len(self.measurements) == 0:
Expand All @@ -124,7 +128,7 @@ def compute(self):
fr,
zeta,
compat,
) = self._calibrate_shaper(datas[0], self.max_smoothing, self.scv, self.max_freq)
) = self._calibrate_shaper(datas[0], self.max_smoothing, self.scv, self.max_freq, self.include_smoothers)
pdata, bins, t = compute_spectrogram(datas[0])
del datas

Expand Down Expand Up @@ -241,7 +245,7 @@ def compute(self):
# Find the best shaper parameters using Klipper's official algorithm selection with
# a proper precomputed damping ratio (zeta) and using the configured printer SQV value
# This function also sweep around the smoothing values to help you find the best compromise
def _calibrate_shaper(self, datas: List[np.ndarray], max_smoothing: Optional[float], scv: float, max_freq: float):
def _calibrate_shaper(self, datas: List[np.ndarray], max_smoothing: Optional[float], scv: float, max_freq: float, include_smoothers: bool):
shaper_calibrate, shaper_defs = get_shaper_calibrate_module()
calib_data = shaper_calibrate.process_accelerometer_data(datas)
calib_data.normalize_to_frequencies()
Expand All @@ -257,6 +261,7 @@ def _calibrate_shaper(self, datas: List[np.ndarray], max_smoothing: Optional[flo
k_shaper_choice, k_shapers = shaper_calibrate.find_best_shaper(
calib_data,
shapers=None,
include_smoothers=include_smoothers,
damping_ratio=zeta,
scv=scv,
shaper_freqs=None,
Expand Down

0 comments on commit 6b5555a

Please sign in to comment.