fixed most of the bugs now as a Klipper plugin

This commit is contained in:
Félix Boisselier
2024-05-16 23:33:49 +02:00
parent dd08162616
commit 55895c1507
13 changed files with 116 additions and 106 deletions

View File

@@ -18,8 +18,9 @@ from .shaketune_thread import ShakeTuneThread
class ShakeTune:
def __init__(self, config) -> None:
self._pconfig = config
self._printer = config.get_printer()
self._gcode = self._printer.lookup_object('gcode')
gcode = self._printer.lookup_object('gcode')
res_tester = self._printer.lookup_object('resonance_tester')
if res_tester is None:
@@ -34,29 +35,29 @@ class ShakeTune:
dpi = config.getint('dpi', default=150, minval=100, maxval=500)
self._config = ShakeTuneConfig(result_folder_path, keep_n_results, keep_csv, dpi)
ConsoleOutput.register_output_callback(self._gcode.respond_info)
ConsoleOutput.register_output_callback(gcode.respond_info)
self._gcode.register_command(
gcode.register_command(
'EXCITATE_AXIS_AT_FREQ',
self.cmd_EXCITATE_AXIS_AT_FREQ,
desc=self.cmd_EXCITATE_AXIS_AT_FREQ_help,
)
self._gcode.register_command(
gcode.register_command(
'AXES_MAP_CALIBRATION',
self.cmd_AXES_MAP_CALIBRATION,
desc=self.cmd_AXES_MAP_CALIBRATION_help,
)
self._gcode.register_command(
gcode.register_command(
'COMPARE_BELTS_RESPONSES',
self.cmd_COMPARE_BELTS_RESPONSES,
desc=self.cmd_COMPARE_BELTS_RESPONSES_help,
)
self._gcode.register_command(
gcode.register_command(
'AXES_SHAPER_CALIBRATION',
self.cmd_AXES_SHAPER_CALIBRATION,
desc=self.cmd_AXES_SHAPER_CALIBRATION_help,
)
self._gcode.register_command(
gcode.register_command(
'CREATE_VIBRATIONS_PROFILE',
self.cmd_CREATE_VIBRATIONS_PROFILE,
desc=self.cmd_CREATE_VIBRATIONS_PROFILE_help,
@@ -68,7 +69,7 @@ class ShakeTune:
def cmd_EXCITATE_AXIS_AT_FREQ(self, gcmd) -> None:
ConsoleOutput.print(f'Shake&Tune version: {ShakeTuneConfig.get_git_version()}')
excitate_axis_at_freq(gcmd, self._gcode, self._printer)
excitate_axis_at_freq(gcmd, self._pconfig)
cmd_AXES_MAP_CALIBRATION_help = 'Perform a set of movements to measure the orientation of the accelerometer and help you set the best axes_map configuration for your printer'
@@ -76,7 +77,7 @@ class ShakeTune:
ConsoleOutput.print(f'Shake&Tune version: {ShakeTuneConfig.get_git_version()}')
axes_map_finder = AxesMapFinder(self._config)
st_thread = ShakeTuneThread(self._config, axes_map_finder, self._printer.get_reactor(), self.timeout)
axes_map_calibration(gcmd, self._gcode, self._printer, st_thread)
axes_map_calibration(gcmd, self._pconfig, st_thread)
cmd_COMPARE_BELTS_RESPONSES_help = 'Perform a custom half-axis test to analyze and compare the frequency profiles of individual belts on CoreXY printers'
@@ -84,7 +85,7 @@ class ShakeTune:
ConsoleOutput.print(f'Shake&Tune version: {ShakeTuneConfig.get_git_version()}')
belt_graph_creator = BeltsGraphCreator(self._config)
st_thread = ShakeTuneThread(self._config, belt_graph_creator, self._printer.get_reactor(), self.timeout)
compare_belts_responses(gcmd, self._gcode, self._printer, st_thread)
compare_belts_responses(gcmd, self._pconfig, st_thread)
cmd_AXES_SHAPER_CALIBRATION_help = (
'Perform standard axis input shaper tests on one or both XY axes to select the best input shaper filter'
@@ -94,7 +95,7 @@ class ShakeTune:
ConsoleOutput.print(f'Shake&Tune version: {ShakeTuneConfig.get_git_version()}')
shaper_graph_creator = ShaperGraphCreator(self._config)
st_thread = ShakeTuneThread(self._config, shaper_graph_creator, self._printer.get_reactor(), self.timeout)
axes_shaper_calibration(gcmd, self._gcode, self._printer, st_thread)
axes_shaper_calibration(gcmd, self._pconfig, st_thread)
cmd_CREATE_VIBRATIONS_PROFILE_help = 'Perform a set of movements to measure the orientation of the accelerometer and help you set the best axes_map configuration for your printer'
@@ -102,4 +103,4 @@ class ShakeTune:
ConsoleOutput.print(f'Shake&Tune version: {ShakeTuneConfig.get_git_version()}')
vibration_profile_creator = VibrationsGraphCreator(self._config)
st_thread = ShakeTuneThread(self._config, vibration_profile_creator, self._printer.get_reactor(), self.timeout)
create_vibrations_profile(gcmd, self._gcode, self._printer, st_thread)
create_vibrations_profile(gcmd, self._pconfig, st_thread)