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

@@ -109,7 +109,8 @@ def axesmap_calibration(lognames, accel=None):
axes_map = ','.join([f'{spike[0][0]}{spike[1]}' for spike in spikes_sorted])
# alignment_error, sensitivity_error = compute_errors(filtered_data, spikes_sorted, accel, NUM_POINTS)
results = f'Detected axes_map:\n {axes_map}\n'
results = f'Be aware that this macro is experimental and has been known to sometimes produce incorrect results. Use it with caution and always check the results!\n'
results += f'Detected axes_map:\n {axes_map}\n'
# TODO: work on this function that is currently not giving good results...
# results += "Accelerometer angle deviation:\n"

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import abc
import re
import shutil
import tarfile
from datetime import datetime
@@ -189,6 +190,7 @@ class VibrationsGraphCreator(GraphCreator):
with tarfile.open(tar_path, 'w:gz') as tar:
for csv_file in lognames:
tar.add(csv_file, arcname=csv_file.name, recursive=False)
csv_file.unlink()
def create_graph(self) -> None:
if not self._accel or not self._kinematics:
@@ -197,7 +199,7 @@ class VibrationsGraphCreator(GraphCreator):
lognames = self._move_and_prepare_files(
glob_pattern='shaketune-vib_*.csv',
min_files_required=None,
custom_name_func=lambda f: f.name,
custom_name_func=lambda f: re.search(r'shaketune-vib_(.*?)_\d{8}_\d{6}', f.name).group(1),
)
fig = vibrations_profile(
lognames=[str(path) for path in lognames],

View File

@@ -564,23 +564,23 @@ def plot_motor_config_txt(fig, motors, differences):
motor_details = [(motors[0], 'X motor'), (motors[1], 'Y motor')]
distance = 0.12
if motors[0].get_property('autotune_enabled'):
distance = 0.24
if motors[0].get_config('autotune_enabled'):
distance = 0.27
config_blocks = [
f"| {lbl}: {mot.get_property('motor').upper()} on {mot.get_property('tmc').upper()} @ {mot.get_property('voltage')}V {mot.get_property('run_current')}A"
f"| {lbl}: {mot.get_config('motor').upper()} on {mot.get_config('tmc').upper()} @ {mot.get_config('voltage'):0.1f}V {mot.get_config('run_current'):0.2f}A - {mot.get_config('microsteps')}usteps"
for mot, lbl in motor_details
]
config_blocks.append('| TMC Autotune enabled')
else:
config_blocks = [
f"| {lbl}: {mot.get_property('tmc').upper()} @ {mot.get_property('run_current')}A"
f"| {lbl}: {mot.get_config('tmc').upper()} @ {mot.get_config('run_current'):0.2f}A - {mot.get_config('microsteps')}usteps"
for mot, lbl in motor_details
]
config_blocks.append('| TMC Autotune not detected')
for idx, block in enumerate(config_blocks):
fig.text(
0.40, 0.990 - 0.015 * idx, block, ha='left', va='top', fontsize=10, color=KLIPPAIN_COLORS['dark_purple']
0.41, 0.990 - 0.015 * idx, block, ha='left', va='top', fontsize=10, color=KLIPPAIN_COLORS['dark_purple']
)
tmc_registers = motors[0].get_registers()
@@ -589,7 +589,7 @@ def plot_motor_config_txt(fig, motors, differences):
settings_str = ' '.join(f'{k}={v}' for k, v in settings.items())
tmc_block = f'| {register.upper()}: {settings_str}'
fig.text(
0.40 + distance,
0.41 + distance,
0.990 - 0.015 * idx,
tmc_block,
ha='left',
@@ -601,7 +601,7 @@ def plot_motor_config_txt(fig, motors, differences):
if differences is not None:
differences_text = f'| Y motor diff: {differences}'
fig.text(
0.40 + distance,
0.41 + distance,
0.990 - 0.015 * (idx + 1),
differences_text,
ha='left',