diff --git a/shaketune/__init__.py b/shaketune/__init__.py index 5c97c20..41bb0e2 100644 --- a/shaketune/__init__.py +++ b/shaketune/__init__.py @@ -1,12 +1,15 @@ -############################################ -###### INPUT SHAPER KLIPPAIN WORKFLOW ###### -############################################ -# Written by Frix_x#0161 # - -# This module functions as a plugin within Klipper, aimed at enhancing printer diagnostics. It serves multiple purposes: -# 1. Diagnosing and pinpointing vibration sources in the printer. -# 2. Conducting standard axis input shaper tests on the XY axes to determine the optimal input shaper filter. -# 3. Executing a specialized half-axis test for CoreXY printers to analyze and compare the frequency profiles of individual belts. +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: __init__.py +# Description: Functions as a plugin within Klipper to enhance printer diagnostics by: +# 1. Diagnosing and pinpointing vibration sources in the printer. +# 2. Conducting standard axis input shaper tests on the machine axes. +# 3. Executing a specialized half-axis test for CoreXY/CoreXZ printers to analyze +# and compare the frequency profiles of individual belts. +# 4. ... from .shaketune import ShakeTune as ShakeTune diff --git a/shaketune/commands/__init__.py b/shaketune/commands/__init__.py index 7565318..33b08bb 100644 --- a/shaketune/commands/__init__.py +++ b/shaketune/commands/__init__.py @@ -1,3 +1,12 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: __init__.py +# Description: Imports various commands function (to run and record the tests) for the Shake&Tune package. + + from .axes_map_calibration import axes_map_calibration as axes_map_calibration from .axes_shaper_calibration import axes_shaper_calibration as axes_shaper_calibration from .compare_belts_responses import compare_belts_responses as compare_belts_responses diff --git a/shaketune/commands/accelerometer.py b/shaketune/commands/accelerometer.py index f8d55a1..a745199 100644 --- a/shaketune/commands/accelerometer.py +++ b/shaketune/commands/accelerometer.py @@ -1,6 +1,13 @@ -# This file provides a custom and internal Shake&Tune Accelerometer helper that is -# an interface to Klipper's own accelerometer classes. It is used to start and -# stop accelerometer measurements and write the data to a file in a blocking manner. +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: accelerometer.py +# Description: Provides a custom and internal Shake&Tune Accelerometer helper that interfaces +# with Klipper's accelerometer classes. It includes functions to start and stop +# accelerometer measurements and write the data to a file in a blocking manner. + import time diff --git a/shaketune/commands/axes_map_calibration.py b/shaketune/commands/axes_map_calibration.py index c55a4fe..f89d60b 100644 --- a/shaketune/commands/axes_map_calibration.py +++ b/shaketune/commands/axes_map_calibration.py @@ -1,3 +1,14 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: axes_map_calibration.py +# Description: Provides a command for calibrating the axes map of a 3D printer using an accelerometer. +# The script moves the printer head along specified axes, starts and stops measurements, +# and performs post-processing to analyze the collected data. + + from ..helpers.console_output import ConsoleOutput from ..shaketune_process import ShakeTuneProcess from .accelerometer import Accelerometer diff --git a/shaketune/commands/axes_shaper_calibration.py b/shaketune/commands/axes_shaper_calibration.py index 2579480..8a2eb3d 100644 --- a/shaketune/commands/axes_shaper_calibration.py +++ b/shaketune/commands/axes_shaper_calibration.py @@ -1,3 +1,14 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: axes_shaper_calibration.py +# Description: Provides a command for calibrating the input shaper of a 3D printer's axes using an accelerometer. +# The script performs resonance tests along specified axes, starts and stops measurements, +# and generates graphs for each axis to analyze the collected data. + + from ..helpers.common_func import AXIS_CONFIG from ..helpers.console_output import ConsoleOutput from ..helpers.resonance_test import vibrate_axis diff --git a/shaketune/commands/compare_belts_responses.py b/shaketune/commands/compare_belts_responses.py index fe6eb39..92375c7 100644 --- a/shaketune/commands/compare_belts_responses.py +++ b/shaketune/commands/compare_belts_responses.py @@ -1,3 +1,14 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: compare_belts_responses.py +# Description: Provides a command for comparing the frequency response of belts in CoreXY and CoreXZ kinematics 3D printers. +# The script performs resonance tests along specified axes, starts and stops measurements, and generates graphs +# for each axis to analyze the collected data. + + from ..helpers.common_func import AXIS_CONFIG from ..helpers.console_output import ConsoleOutput from ..helpers.motors_config_parser import MotorsConfigParser diff --git a/shaketune/commands/create_vibrations_profile.py b/shaketune/commands/create_vibrations_profile.py index 47b429b..bcac671 100644 --- a/shaketune/commands/create_vibrations_profile.py +++ b/shaketune/commands/create_vibrations_profile.py @@ -1,3 +1,14 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: vibrations_profile.py +# Description: Provides a command to measure the vibrations generated by the kinematics and motors of a 3D printers +# at different speeds and angles increments. The data is collected from the accelerometer and used +# to generate a comprehensive vibration analysis graph. + + import math from ..helpers.console_output import ConsoleOutput diff --git a/shaketune/commands/excitate_axis_at_freq.py b/shaketune/commands/excitate_axis_at_freq.py index fdf9b7c..d1ecd63 100644 --- a/shaketune/commands/excitate_axis_at_freq.py +++ b/shaketune/commands/excitate_axis_at_freq.py @@ -1,3 +1,13 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: excitate_axis_at_freq.py +# Description: Provide a command to excites a specified axis at a given frequency for a duration +# and optionally creates a graph of the vibration data collected by the accelerometer. + + from ..helpers.common_func import AXIS_CONFIG from ..helpers.console_output import ConsoleOutput from ..helpers.resonance_test import vibrate_axis_at_static_freq diff --git a/shaketune/dummy_macros.cfg b/shaketune/dummy_macros.cfg index a8d7f8c..5ee0185 100644 --- a/shaketune/dummy_macros.cfg +++ b/shaketune/dummy_macros.cfg @@ -1,7 +1,11 @@ -# This file contains dummy gcode macros to inject them at Klipper startup -# by the Shake&Tune plugin in order to make them available in the UI. -# Indeed, system macros in Klipper are not available as buttons in Mainsail/Fluidd -# and this is a workaround to have a good and friendly UX when using Shake&Tune. +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: dummy_macros.cfg +# Description: Contains dummy gcode macros to inject at Klipper startup for +# availability in the UI, improving user experience with Shake&Tune. [gcode_macro EXCITATE_AXIS_AT_FREQ] diff --git a/shaketune/graph_creators/__init__.py b/shaketune/graph_creators/__init__.py index c433ba0..ad8b19f 100644 --- a/shaketune/graph_creators/__init__.py +++ b/shaketune/graph_creators/__init__.py @@ -1,3 +1,12 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: __init__.py +# Description: Imports various graph creator classes for the Shake&Tune package. + + from .axes_map_graph_creator import AxesMapGraphCreator as AxesMapGraphCreator from .belts_graph_creator import BeltsGraphCreator as BeltsGraphCreator from .graph_creator import GraphCreator as GraphCreator diff --git a/shaketune/graph_creators/axes_map_graph_creator.py b/shaketune/graph_creators/axes_map_graph_creator.py index c128c14..d2b2542 100644 --- a/shaketune/graph_creators/axes_map_graph_creator.py +++ b/shaketune/graph_creators/axes_map_graph_creator.py @@ -1,7 +1,12 @@ -###################################### -###### AXE_MAP DETECTION SCRIPT ###### -###################################### -# Written by Frix_x#0161 # +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: axes_map_graph_creator.py +# Description: Implements the axes map detection script for Shake&Tune, including +# calibration tools and graph creation for 3D printer vibration analysis. + import optparse import os diff --git a/shaketune/graph_creators/belts_graph_creator.py b/shaketune/graph_creators/belts_graph_creator.py index 7da6ef3..84c1e08 100644 --- a/shaketune/graph_creators/belts_graph_creator.py +++ b/shaketune/graph_creators/belts_graph_creator.py @@ -1,7 +1,12 @@ -################################################# -######## CoreXY BELTS CALIBRATION SCRIPT ######## -################################################# -# Written by Frix_x#0161 # +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2022 - 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: belts_graph_creator.py +# Description: Implements the CoreXY/CoreXZ belts calibration script for Shake&Tune, +# including computation and graphing functions for 3D printer belt paths analysis. + import optparse import os diff --git a/shaketune/graph_creators/graph_creator.py b/shaketune/graph_creators/graph_creator.py index d3ed4f5..f89b9ce 100644 --- a/shaketune/graph_creators/graph_creator.py +++ b/shaketune/graph_creators/graph_creator.py @@ -1,3 +1,15 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: graph_creator.py +# Description: Abstract base class for creating various types of graphs in Shake&Tune, +# including methods for moving, preparing, saving, and cleaning up files. +# This class is inherited by the AxesMapGraphCreator, BeltsGraphCreator, +# ShaperGraphCreator, VibrationsGraphCreator, StaticGraphCreator + + import abc import shutil from datetime import datetime diff --git a/shaketune/graph_creators/shaper_graph_creator.py b/shaketune/graph_creators/shaper_graph_creator.py index 8733c8e..10475c0 100644 --- a/shaketune/graph_creators/shaper_graph_creator.py +++ b/shaketune/graph_creators/shaper_graph_creator.py @@ -1,3 +1,16 @@ +# Shake&Tune: 3D printer analysis tools +# +# Derived from the calibrate_shaper.py official Klipper script +# Copyright (C) 2020 Dmitry Butyugin +# Copyright (C) 2020 Kevin O'Connor +# Copyright (C) 2022 - 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: shaper_graph_creator.py +# Description: Implements the input shaper calibration script for Shake&Tune, +# including computation and graphing functions for 3D printer vibration analysis. + + ################################################# ######## INPUT SHAPER CALIBRATION SCRIPT ######## ################################################# diff --git a/shaketune/graph_creators/static_graph_creator.py b/shaketune/graph_creators/static_graph_creator.py index 4903f6f..e0c9dd0 100644 --- a/shaketune/graph_creators/static_graph_creator.py +++ b/shaketune/graph_creators/static_graph_creator.py @@ -1,3 +1,13 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: static_graph_creator.py +# Description: Implements a static frequency profile measurement script for Shake&Tune to diagnose mechanical +# issues, including computation and graphing functions for 3D printer vibration analysis. + + import optparse import os from datetime import datetime diff --git a/shaketune/graph_creators/vibrations_graph_creator.py b/shaketune/graph_creators/vibrations_graph_creator.py index 39ade9f..3fc0034 100644 --- a/shaketune/graph_creators/vibrations_graph_creator.py +++ b/shaketune/graph_creators/vibrations_graph_creator.py @@ -1,7 +1,12 @@ -################################################## -#### DIRECTIONAL VIBRATIONS PLOTTING SCRIPT ###### -################################################## -# Written by Frix_x#0161 # +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: vibrations_graph_creator.py +# Description: Implements the directional vibrations plotting script for Shake&Tune, +# including computation and graphing functions for analyzing 3D printer vibration profiles. + import math import optparse diff --git a/shaketune/helpers/__init__.py b/shaketune/helpers/__init__.py index e69de29..89ffb56 100644 --- a/shaketune/helpers/__init__.py +++ b/shaketune/helpers/__init__.py @@ -0,0 +1,6 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: __init__.py diff --git a/shaketune/helpers/common_func.py b/shaketune/helpers/common_func.py index 67c9aeb..49df45a 100644 --- a/shaketune/helpers/common_func.py +++ b/shaketune/helpers/common_func.py @@ -1,5 +1,12 @@ -# Common functions for the Shake&Tune package -# Written by Frix_x#0161 # +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: common_func.py +# Description: Contains common functions and constants used across the Shake&Tune +# package for 3D printer vibration analysis and diagnostics. + import math import os diff --git a/shaketune/helpers/console_output.py b/shaketune/helpers/console_output.py index c8c72d7..e4b6a9f 100644 --- a/shaketune/helpers/console_output.py +++ b/shaketune/helpers/console_output.py @@ -1,3 +1,13 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: console_output.py +# Description: Defines the ConsoleOutput class for printing output to stdout or an alternative +# callback function, such as the Klipper console. + + import io from typing import Callable, Optional diff --git a/shaketune/helpers/motors_config_parser.py b/shaketune/helpers/motors_config_parser.py index 4b224f4..a3f4cca 100644 --- a/shaketune/helpers/motors_config_parser.py +++ b/shaketune/helpers/motors_config_parser.py @@ -1,6 +1,12 @@ -# Classes to retrieve a couple of motors infos and extract the relevant information -# from the Klipper configuration and the TMC registers -# Written by Frix_x#0161 # +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: motors_config_parser.py +# Description: Contains classes to retrieve motor information and extract relevant data +# from the Klipper configuration and TMC registers. + from typing import Any, Dict, List, Optional diff --git a/shaketune/helpers/resonance_test.py b/shaketune/helpers/resonance_test.py index e828f14..8b6d703 100644 --- a/shaketune/helpers/resonance_test.py +++ b/shaketune/helpers/resonance_test.py @@ -1,11 +1,20 @@ -# The logic in this file was "extracted" from Klipper's orignal resonance_tester.py file -# Courtesy of Dmitry Butyugin for the original implementation +# Shake&Tune: 3D printer analysis tools +# +# Adapted from Klipper's original resonance_tester.py file by Dmitry Butyugin +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: resonance_test.py +# Description: Contains functions to test the resonance frequency of the printer and its components +# by vibrating the toolhead in specific axis directions. This derive a bit from Klipper's +# implementation as there are two main changes: +# 1. Original code doesn't use euclidean distance with projection for the coordinates calculation. +# The new approach implemented here ensures that the vector's total length remains constant (= L), +# regardless of the direction components. It's especially important when the direction vector +# involves combinations of movements along multiple axes like for the diagonal belt tests. +# 2. Original code doesn't allow Z axis movements that was added in order to test the Z axis resonance +# or CoreXZ belts frequency profiles as well. -# This derive a bit from Klipper's implementation as there are two main changes: -# 1. Original code doesn't use euclidean distance for the moves calculation with projection. The new approach implemented here -# ensures that the vector's total length remains constant (= L), regardless of the direction components. It's especially -# important when the direction vector involves combinations of movements along multiple axes like for the diagonal belt tests. -# 2. Original code doesn't allow Z axis movement that was added here for later use import math diff --git a/shaketune/shaketune.py b/shaketune/shaketune.py index 98d1ca3..c710198 100644 --- a/shaketune/shaketune.py +++ b/shaketune/shaketune.py @@ -1,3 +1,13 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: shaketune.py +# Description: Main class implementation for Shake&Tune, handling Klipper initialization and +# loading of the plugin, and the registration of the tuning commands + + import os from pathlib import Path diff --git a/shaketune/shaketune_config.py b/shaketune/shaketune_config.py index e029f51..57b19a8 100644 --- a/shaketune/shaketune_config.py +++ b/shaketune/shaketune_config.py @@ -1,3 +1,13 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: shaketune_config.py +# Description: Defines the ShakeTuneConfig class for handling configuration settings +# and file paths related to Shake&Tune operations. + + from pathlib import Path from .helpers.console_output import ConsoleOutput diff --git a/shaketune/shaketune_process.py b/shaketune/shaketune_process.py index 4fc9e6b..a6ff401 100644 --- a/shaketune/shaketune_process.py +++ b/shaketune/shaketune_process.py @@ -1,3 +1,13 @@ +# Shake&Tune: 3D printer analysis tools +# +# Copyright (C) 2024 Félix Boisselier (Frix_x on Discord) +# Licensed under the GNU General Public License v3.0 (GPL-3.0) +# +# File: shaketune_process.py +# Description: Implements the ShakeTuneProcess class for managing the execution of +# vibration analysis processes in separate system processes. + + import multiprocessing import os import threading