From 72bc227920c5598c1c8e758f460ec73e49d55f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Mon, 12 Jun 2023 13:30:13 +0000 Subject: [PATCH 01/11] system info now automatically printed at Klippain startup --- macros/miscs/startup.cfg | 8 +++ scripts/gcode_shell_command.py | 0 scripts/shell_commands.cfg | 5 ++ scripts/system_info.py | 124 +++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+) mode change 100644 => 100755 scripts/gcode_shell_command.py create mode 100755 scripts/system_info.py diff --git a/macros/miscs/startup.cfg b/macros/miscs/startup.cfg index d7c82c6b6..ea9e9d66a 100644 --- a/macros/miscs/startup.cfg +++ b/macros/miscs/startup.cfg @@ -4,6 +4,14 @@ [delayed_gcode KLIPPAIN_STARTUP] initial_duration: 1 gcode: + _KLIPPAIN_STARTUP + + +[gcode_macro _KLIPPAIN_STARTUP] +gcode: + # Print system information using the system_info.py script to log them in the klippy.log + RUN_SHELL_COMMAND CMD=system_info + # Dump the MCU version to the console for the Klippy log _INIT_MCU_VER diff --git a/scripts/gcode_shell_command.py b/scripts/gcode_shell_command.py old mode 100644 new mode 100755 diff --git a/scripts/shell_commands.cfg b/scripts/shell_commands.cfg index 1aade2af6..f25e9b234 100644 --- a/scripts/shell_commands.cfg +++ b/scripts/shell_commands.cfg @@ -5,3 +5,8 @@ command: bash /home/pi/printer_data/config/scripts/plot_graphs.sh timeout: 300.0 verbose: True + +[gcode_shell_command system_info] +command: python3 /home/pi/printer_data/config/scripts/system_info.py +timeout: 5.0 +verbose: True diff --git a/scripts/system_info.py b/scripts/system_info.py new file mode 100755 index 000000000..4493551bb --- /dev/null +++ b/scripts/system_info.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 + +###################################### +###### BASIC SYSTEM INFO SCRIPT ###### +###################################### +# Written by Frix_x#0161 # +# @version: 1.0 + +# CHANGELOG: +# v1.0: first version of the script to get some system info printed in the klippy.log + + +# Be sure to make this script executable using SSH: type 'chmod +x ./system_info.py' when in the folder ! + +##################################################################### +################ !!! DO NOT EDIT BELOW THIS LINE !!! ################ +##################################################################### + +import subprocess +import os +import platform +from datetime import datetime +import concurrent.futures + +def get_date_time(): + # Special note for power-user running Klipper inside a docker container: usually the timezone + # is not set and this result in a print of the UTC time (instead of local). Consider running + # the container like: "docker run -e TZ=America/New_York klipper_image" + # in order to get a proper timezone set and get the correct time read by this script + return datetime.now().strftime("%m/%d/%Y, %H:%M:%S") + +def check_docker(): + return os.path.exists('/.dockerenv') + +def check_wsl(): + try: + with open('/proc/version', 'r') as f: + if 'microsoft' in f.read().lower(): + return True + except Exception: + pass + return False + +def get_pi_model(): + if "arm" in platform.machine(): + try: + model_info = subprocess.check_output(['cat', '/sys/firmware/devicetree/base/model'], universal_newlines=True) + return model_info + except subprocess.CalledProcessError: + return None + else: + return None + +def get_unknown_board_info(): + try: + with open('/proc/cpuinfo', 'r') as f: + for line in f: + if line.startswith('Hardware') or line.startswith('Model name'): + return line.split(':')[1].strip() + with open('/etc/os-release', 'r') as f: + for line in f: + if line.startswith('PRETTY_NAME') or line.startswith('NAME'): + return line.split('=')[1].strip().strip('"') + except Exception: + pass + + return "no additional info..." + +def get_os_kernel_info(): + uname = os.uname() + return uname.sysname, uname.release, uname.machine + +def get_ram_info(): + try: + total_ram = subprocess.check_output(['free', '-m'], universal_newlines=True).split('\n')[1].split()[1] + available_ram = subprocess.check_output(['free', '-m'], universal_newlines=True).split('\n')[1].split()[6] + return total_ram, available_ram + except subprocess.CalledProcessError: + return None, None + + +def print_system_info(): + with concurrent.futures.ThreadPoolExecutor() as executor: + future_date_time = executor.submit(get_date_time) + future_docker = executor.submit(check_docker) + future_pi_model = executor.submit(get_pi_model) + future_wsl = executor.submit(check_wsl) + future_os_kernel = executor.submit(get_os_kernel_info) + future_ram_info = executor.submit(get_ram_info) + + + date_time = future_date_time.result() + print(f"Klippain started ({date_time})") + + sysname, release, machine = future_os_kernel.result() + print(f"Operating System: {sysname} - {release}") + + + is_docker = future_docker.result() + is_wsl = future_wsl.result() + pi_model = future_pi_model.result() + + if is_docker: + print(f"Machine: {machine} - in a docker container") + elif is_wsl: + print(f"Machine: {machine} - in Windows Subsystem for Linux") + elif pi_model is not None: + print(f"Machine: {machine} - in a {pi_model}") + else: + # This is the case where it is running on a unknown machine type + # so we use the specific function to try to gather more info... + print(f"Machine: {machine} - in an unknown machine") + print(f"Unknown system information: {get_unknown_board_info()}") + + + total_ram, available_ram = future_ram_info.result() + if total_ram is None or available_ram is None: + print("RAM information not found...") + else: + print(f"Used RAM: {available_ram}/{total_ram} MB") + + +if __name__ == "__main__": + print_system_info() From 10f1de6826444779e1905db99335ff97fa70238b Mon Sep 17 00:00:00 2001 From: Surion79 <102791900+Surion79@users.noreply.github.com> Date: Tue, 13 Jun 2023 10:19:06 +0200 Subject: [PATCH 02/11] added missing MCU_MOTORDRIVE_DIAG to sb2240 mcu (#234) --- config/mcu_definitions/toolhead/BTT_SB2240_v1.0.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/mcu_definitions/toolhead/BTT_SB2240_v1.0.cfg b/config/mcu_definitions/toolhead/BTT_SB2240_v1.0.cfg index 4674440b8..e5ddba6f5 100644 --- a/config/mcu_definitions/toolhead/BTT_SB2240_v1.0.cfg +++ b/config/mcu_definitions/toolhead/BTT_SB2240_v1.0.cfg @@ -1,7 +1,7 @@ [board_pins toolhead_manufacturer] mcu: toolhead aliases: - MCU_MOTORDRIVE_STEP=PD0 , MCU_MOTORDRIVE_DIR=PD1 , MCU_MOTORDRIVE_ENABLE=PD2 , + MCU_MOTORDRIVE_STEP=PD0 , MCU_MOTORDRIVE_DIR=PD1 , MCU_MOTORDRIVE_ENABLE=PD2 , MCU_MOTORDRIVE_DIAG=PB3 , MCU_MOTOR_SPI_NSS=PA15 , # CLK/MOSI/MISO are shared with SPI2 configuration MCU_STOP1=PB6 , MCU_STOP2=PB5 , MCU_STOP3=PB7 , From 5c01546814317f0ba1d189407a6371a132ed6087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Tue, 13 Jun 2023 20:34:12 +0200 Subject: [PATCH 03/11] raised the timeout on the plot graph script for slow file Pi alternatives --- scripts/shell_commands.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/shell_commands.cfg b/scripts/shell_commands.cfg index f25e9b234..e3e263948 100644 --- a/scripts/shell_commands.cfg +++ b/scripts/shell_commands.cfg @@ -3,7 +3,7 @@ [gcode_shell_command plot_graph] command: bash /home/pi/printer_data/config/scripts/plot_graphs.sh -timeout: 300.0 +timeout: 500.0 verbose: True [gcode_shell_command system_info] From 57ab6ed20a6b47619c4d37e5bf94ce67320ee964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Wed, 14 Jun 2023 23:37:16 +0200 Subject: [PATCH 04/11] simplified ADXL system and fixed a typo in Mellow Fly-SB2209 template --- .../hardware/accelerometers/adxl345_ebb.cfg | 18 ------------- ...l345_sht.cfg => adxl345_hardware_spi1.cfg} | 11 +++++++- ...l345_skr.cfg => adxl345_hardware_ssp1.cfg} | 10 +++++-- .../hardware/accelerometers/adxl345_rpi.cfg | 8 ++++-- .../accelerometers/adxl345_sb2040.cfg | 18 ------------- .../accelerometers/adxl345_software_spi.cfg | 26 +++++++++++++++++++ .../hardware/accelerometers/adxl345_usb.cfg | 11 +++++--- .../toolhead/BTT_EBB36-42_v1.0.cfg | 6 +++++ .../toolhead/BTT_EBB36-42_v1.1.cfg | 6 +++++ .../toolhead/BTT_EBB36-42_v1.2.cfg | 6 +++++ .../mcu_defaults/toolhead/BTT_SB2209_v1.0.cfg | 8 +++++- .../mcu_defaults/toolhead/BTT_SB2240_v1.0.cfg | 6 +++++ .../toolhead/Mellow_SB2040_v1.cfg | 6 +++++ .../toolhead/Mellow_SHT36-42_v1.x.cfg | 3 +++ .../toolhead/Mellow_SHT36_v2.x.cfg | 3 +++ user_templates/printer.cfg | 11 ++++---- 16 files changed, 106 insertions(+), 51 deletions(-) delete mode 100644 config/hardware/accelerometers/adxl345_ebb.cfg rename config/hardware/accelerometers/{adxl345_sht.cfg => adxl345_hardware_spi1.cfg} (55%) rename config/hardware/accelerometers/{adxl345_skr.cfg => adxl345_hardware_ssp1.cfg} (70%) delete mode 100644 config/hardware/accelerometers/adxl345_sb2040.cfg create mode 100644 config/hardware/accelerometers/adxl345_software_spi.cfg diff --git a/config/hardware/accelerometers/adxl345_ebb.cfg b/config/hardware/accelerometers/adxl345_ebb.cfg deleted file mode 100644 index 8491be932..000000000 --- a/config/hardware/accelerometers/adxl345_ebb.cfg +++ /dev/null @@ -1,18 +0,0 @@ -[adxl345] -cs_pin: toolhead:ADXL_CS -spi_software_sclk_pin: toolhead:ADXL_SCLK -spi_software_mosi_pin: toolhead:ADXL_MOSI -spi_software_miso_pin: toolhead:ADXL_MISO -axes_map: x,y,z - -[resonance_tester] -accel_chip: adxl345 -probe_points: - -1,-1,-1 - - -# Include the IS calibration macros to unlock them when -# an accelerometer is installed on the machine -[include ../../../macros/helpers/resonance_override.cfg] -[include ../../../macros/calibration/IS_shaper_calibrate.cfg] -[include ../../../macros/calibration/IS_vibrations_measurement.cfg] diff --git a/config/hardware/accelerometers/adxl345_sht.cfg b/config/hardware/accelerometers/adxl345_hardware_spi1.cfg similarity index 55% rename from config/hardware/accelerometers/adxl345_sht.cfg rename to config/hardware/accelerometers/adxl345_hardware_spi1.cfg index 91cafb3c3..963c60107 100644 --- a/config/hardware/accelerometers/adxl345_sht.cfg +++ b/config/hardware/accelerometers/adxl345_hardware_spi1.cfg @@ -1,5 +1,14 @@ +# This ADXL file is dedicated to be used with ADXL boards +# connected over the SPI bus of the MCU boards on "spi1" + +# This include most Mellow toolhead boards such as SHT boards, ... +# But also Octopus, etc... + +# If using a toolhead board, be sure to have the pin override in your mcu.cfg (toolhead:ADXL_CS) + + [adxl345] -cs_pin: toolhead:ADXL_CS +cs_pin: ADXL_CS spi_bus: spi1 axes_map: x,y,z diff --git a/config/hardware/accelerometers/adxl345_skr.cfg b/config/hardware/accelerometers/adxl345_hardware_ssp1.cfg similarity index 70% rename from config/hardware/accelerometers/adxl345_skr.cfg rename to config/hardware/accelerometers/adxl345_hardware_ssp1.cfg index 1770407b9..9276b532f 100644 --- a/config/hardware/accelerometers/adxl345_skr.cfg +++ b/config/hardware/accelerometers/adxl345_hardware_ssp1.cfg @@ -1,7 +1,13 @@ +# This ADXL file is dedicated to be used with ADXL boards +# connected over the SPI bus of the MCU boards on "ssp1" + +# This include BTT SKRv1.4, ... + + [adxl345] -spi_bus: ssp1 cs_pin: ADXL_CS -axes_map: -z,y,x +spi_bus: ssp1 +axes_map: x,y,z [resonance_tester] accel_chip: adxl345 diff --git a/config/hardware/accelerometers/adxl345_rpi.cfg b/config/hardware/accelerometers/adxl345_rpi.cfg index 8d7b67df4..e5b26a1c9 100644 --- a/config/hardware/accelerometers/adxl345_rpi.cfg +++ b/config/hardware/accelerometers/adxl345_rpi.cfg @@ -1,4 +1,8 @@ -# This file is the recommended way to get an accelerometer connected and used in Klipper +# This ADXL file is dedicated to be used with ADXL boards +# connected over the SPI bus of the RaspberryPi +# It is the official and recommended way to get an +# accelerometer connected and used in Klipper + # Do not forget to also flash the RPi with the Klipper firmware! [include ../../mcu_definitions/rpi.cfg] @@ -6,7 +10,7 @@ [adxl345] cs_pin: rpi:None -axes_map: -z,y,x +axes_map: x,y,z [resonance_tester] accel_chip: adxl345 diff --git a/config/hardware/accelerometers/adxl345_sb2040.cfg b/config/hardware/accelerometers/adxl345_sb2040.cfg deleted file mode 100644 index 8491be932..000000000 --- a/config/hardware/accelerometers/adxl345_sb2040.cfg +++ /dev/null @@ -1,18 +0,0 @@ -[adxl345] -cs_pin: toolhead:ADXL_CS -spi_software_sclk_pin: toolhead:ADXL_SCLK -spi_software_mosi_pin: toolhead:ADXL_MOSI -spi_software_miso_pin: toolhead:ADXL_MISO -axes_map: x,y,z - -[resonance_tester] -accel_chip: adxl345 -probe_points: - -1,-1,-1 - - -# Include the IS calibration macros to unlock them when -# an accelerometer is installed on the machine -[include ../../../macros/helpers/resonance_override.cfg] -[include ../../../macros/calibration/IS_shaper_calibrate.cfg] -[include ../../../macros/calibration/IS_vibrations_measurement.cfg] diff --git a/config/hardware/accelerometers/adxl345_software_spi.cfg b/config/hardware/accelerometers/adxl345_software_spi.cfg new file mode 100644 index 000000000..02884cfc1 --- /dev/null +++ b/config/hardware/accelerometers/adxl345_software_spi.cfg @@ -0,0 +1,26 @@ +# This ADXL file is dedicated to be used with ADXL boards +# connected over the software SPI bus of the MCU boards + +# This include most BTT toolhead boards such as EBB boards, SB2209, SB2240, +# but also some Mellow boards such as the Fly-SB2040, ... +# If using a toolhead board, be sure to have the pin override in your mcu.cfg (toolhead:ADXL_CS) + + +[adxl345] +cs_pin: ADXL_CS +spi_software_sclk_pin: ADXL_SCLK +spi_software_mosi_pin: ADXL_MOSI +spi_software_miso_pin: ADXL_MISO +axes_map: x,y,z + +[resonance_tester] +accel_chip: adxl345 +probe_points: + -1,-1,-1 + + +# Include the IS calibration macros to unlock them when +# an accelerometer is installed on the machine +[include ../../../macros/helpers/resonance_override.cfg] +[include ../../../macros/calibration/IS_shaper_calibrate.cfg] +[include ../../../macros/calibration/IS_vibrations_measurement.cfg] diff --git a/config/hardware/accelerometers/adxl345_usb.cfg b/config/hardware/accelerometers/adxl345_usb.cfg index b65915f83..f3ac0f1e7 100644 --- a/config/hardware/accelerometers/adxl345_usb.cfg +++ b/config/hardware/accelerometers/adxl345_usb.cfg @@ -1,12 +1,17 @@ -# USB support for RPi pico and KUSBA V2 -# Edit the serial line with the correct address. +# This ADXL file is dedicated to be used with ADXL boards +# connected over USB to the pi as dedicated and standalone ADXL-MCU boards + +# This include KUSBA, ... + + +# You need to override the following to be able to set the proper serial in your overrides.cfg file [mcu adxl] serial: /dev/serial/by-id/xxx [adxl345] cs_pin: adxl:gpio1 spi_bus: spi0a -axes_map: -z,y,x +axes_map: x,y,z [resonance_tester] accel_chip: adxl345 diff --git a/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.0.cfg b/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.0.cfg index 348a1dac3..a02592191 100644 --- a/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.0.cfg +++ b/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.0.cfg @@ -66,3 +66,9 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART +[adxl345] +cs_pin: toolhead:ADXL_CS +spi_software_sclk_pin: toolhead:ADXL_SCLK +spi_software_mosi_pin: toolhead:ADXL_MOSI +spi_software_miso_pin: toolhead:ADXL_MISO + diff --git a/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.1.cfg b/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.1.cfg index 8338e47df..3bfe66c1c 100644 --- a/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.1.cfg +++ b/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.1.cfg @@ -66,3 +66,9 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART +[adxl345] +cs_pin: toolhead:ADXL_CS +spi_software_sclk_pin: toolhead:ADXL_SCLK +spi_software_mosi_pin: toolhead:ADXL_MOSI +spi_software_miso_pin: toolhead:ADXL_MISO + diff --git a/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.2.cfg b/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.2.cfg index fb84e2ac4..bb924dde7 100644 --- a/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.2.cfg +++ b/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.2.cfg @@ -66,3 +66,9 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART +[adxl345] +cs_pin: toolhead:ADXL_CS +spi_software_sclk_pin: toolhead:ADXL_SCLK +spi_software_mosi_pin: toolhead:ADXL_MOSI +spi_software_miso_pin: toolhead:ADXL_MISO + diff --git a/user_templates/mcu_defaults/toolhead/BTT_SB2209_v1.0.cfg b/user_templates/mcu_defaults/toolhead/BTT_SB2209_v1.0.cfg index f5b72e8d3..c344532f0 100644 --- a/user_templates/mcu_defaults/toolhead/BTT_SB2209_v1.0.cfg +++ b/user_templates/mcu_defaults/toolhead/BTT_SB2209_v1.0.cfg @@ -28,7 +28,7 @@ aliases: STATUS_NEOPIXEL=MCU_RGB , - ADXL_CS=MCU_SPI2_CS , ADXL_SCLK=MCU_SPI2_CLK , ADXL_MISO=MCU_SPI2_MISO , ADXL_MOSI=MCU_SPI2_MOSI , + ADXL_CS=MCU_SPI2_NSS , ADXL_SCLK=MCU_SPI2_CLK , ADXL_MISO=MCU_SPI2_MISO , ADXL_MOSI=MCU_SPI2_MOSI , MAX31865_NSS=MCU_SPI1_NSS , MAX31865_CLK=MCU_SPI1_CLK , MAX31865_MOSI=MCU_SPI1_MOSI , MAX31865_MISO = MCU_SPI1_MISO , @@ -67,3 +67,9 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART +[adxl345] +cs_pin: toolhead:ADXL_CS +spi_software_sclk_pin: toolhead:ADXL_SCLK +spi_software_mosi_pin: toolhead:ADXL_MOSI +spi_software_miso_pin: toolhead:ADXL_MISO + diff --git a/user_templates/mcu_defaults/toolhead/BTT_SB2240_v1.0.cfg b/user_templates/mcu_defaults/toolhead/BTT_SB2240_v1.0.cfg index 867d0d561..c93aec612 100644 --- a/user_templates/mcu_defaults/toolhead/BTT_SB2240_v1.0.cfg +++ b/user_templates/mcu_defaults/toolhead/BTT_SB2240_v1.0.cfg @@ -89,3 +89,9 @@ driver_SGT: 30 driver_SEMIN: 2 driver_SEMAX: 8 +[adxl345] +cs_pin: toolhead:ADXL_CS +spi_software_sclk_pin: toolhead:ADXL_SCLK +spi_software_mosi_pin: toolhead:ADXL_MOSI +spi_software_miso_pin: toolhead:ADXL_MISO + diff --git a/user_templates/mcu_defaults/toolhead/Mellow_SB2040_v1.cfg b/user_templates/mcu_defaults/toolhead/Mellow_SB2040_v1.cfg index a5b92ea37..851639414 100644 --- a/user_templates/mcu_defaults/toolhead/Mellow_SB2040_v1.cfg +++ b/user_templates/mcu_defaults/toolhead/Mellow_SB2040_v1.cfg @@ -66,3 +66,9 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART +[adxl345] +cs_pin: toolhead:ADXL_CS +spi_software_sclk_pin: toolhead:ADXL_SCLK +spi_software_mosi_pin: toolhead:ADXL_MOSI +spi_software_miso_pin: toolhead:ADXL_MISO + diff --git a/user_templates/mcu_defaults/toolhead/Mellow_SHT36-42_v1.x.cfg b/user_templates/mcu_defaults/toolhead/Mellow_SHT36-42_v1.x.cfg index 6f85acea5..8acba97dd 100644 --- a/user_templates/mcu_defaults/toolhead/Mellow_SHT36-42_v1.x.cfg +++ b/user_templates/mcu_defaults/toolhead/Mellow_SHT36-42_v1.x.cfg @@ -67,3 +67,6 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART +[adxl345] +cs_pin: toolhead:ADXL_CS + diff --git a/user_templates/mcu_defaults/toolhead/Mellow_SHT36_v2.x.cfg b/user_templates/mcu_defaults/toolhead/Mellow_SHT36_v2.x.cfg index 343dc4c31..72a794bfa 100644 --- a/user_templates/mcu_defaults/toolhead/Mellow_SHT36_v2.x.cfg +++ b/user_templates/mcu_defaults/toolhead/Mellow_SHT36_v2.x.cfg @@ -66,3 +66,6 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART +[adxl345] +cs_pin: toolhead:ADXL_CS + diff --git a/user_templates/printer.cfg b/user_templates/printer.cfg index f4cbcbda2..9f1634320 100644 --- a/user_templates/printer.cfg +++ b/user_templates/printer.cfg @@ -159,12 +159,11 @@ # --------------------------------------------------------------------- ACCELEROMETER ----> Select only one line ### -------------------------------------------------------------------------------------- -# [include config/hardware/accelerometers/adxl345_rpi.cfg] -# [include config/hardware/accelerometers/adxl345_ebb.cfg] -# [include config/hardware/accelerometers/adxl345_sht.cfg] -# [include config/hardware/accelerometers/adxl345_sb2040.cfg] -# [include config/hardware/accelerometers/adxl345_skr.cfg] -# [include config/hardware/accelerometers/adxl345_usb.cfg] +# [include config/hardware/accelerometers/adxl345_rpi.cfg] # For ADXL plugged directly on the Pi (official and recommended way) +# [include config/hardware/accelerometers/adxl345_software_spi.cfg] # For ADXL plugged in boards such as BTT EBB, SB2209, SB2240, or Mellow Fly-SB2040, ... +# [include config/hardware/accelerometers/adxl345_hardware_spi1.cfg] # For ADXL plugged in Mellow SHT, Octopus, ... +# [include config/hardware/accelerometers/adxl345_hardware_ssp1.cfg] # For ADXL plugged in SKRv1.4, ... +# [include config/hardware/accelerometers/adxl345_usb.cfg] # For KUBSA, ... # ---------------------------------------------------------------------------------------- From 948ffffeefec9b59dea47200be7b7adc5c2ab67c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Fri, 16 Jun 2023 13:30:41 +0000 Subject: [PATCH 05/11] primeline is now also an independant macro --- config/machine.cfg | 1 + macros/base/start_print.cfg | 97 +------------------------------- macros/helpers/prime_line.cfg | 101 ++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 96 deletions(-) create mode 100644 macros/helpers/prime_line.cfg diff --git a/config/machine.cfg b/config/machine.cfg index 5b6ffba7f..87d0de761 100644 --- a/config/machine.cfg +++ b/config/machine.cfg @@ -38,6 +38,7 @@ resolution: 0.1 [include ../macros/helpers/filament_swap.cfg] [include ../macros/helpers/heatsoak.cfg] +[include ../macros/helpers/prime_line.cfg] [include ../macros/helpers/nozzle_cleaning.cfg] [include ../macros/helpers/temp_check.cfg] diff --git a/macros/base/start_print.cfg b/macros/base/start_print.cfg index 7e97f0e5e..e2072a368 100644 --- a/macros/base/start_print.cfg +++ b/macros/base/start_print.cfg @@ -160,102 +160,7 @@ gcode: [gcode_macro _MODULE_PRIMELINE] gcode: - # Set vars - {% set St = printer["gcode_macro _USER_VARIABLES"].travel_speed * 60 %} - {% set Sz = printer["gcode_macro _USER_VARIABLES"].z_drop_speed * 60 %} - {% set verbose = printer["gcode_macro _USER_VARIABLES"].verbose %} - - {% set prime_line_x, prime_line_y = printer["gcode_macro _USER_VARIABLES"].prime_line_xy|map('float') %} - {% set prime_line_direction = printer["gcode_macro _USER_VARIABLES"].prime_line_direction|string|upper %} - {% set prime_line_length = printer["gcode_macro _USER_VARIABLES"].prime_line_length|float %} - {% set prime_line_purge_distance = printer["gcode_macro _USER_VARIABLES"].prime_line_purge_distance|float %} - {% set prime_line_flowrate = printer["gcode_macro _USER_VARIABLES"].prime_line_flowrate|float %} - {% set klippain_ercf_enabled = printer["gcode_macro _USER_VARIABLES"].klippain_ercf_enabled %} - - {% set max_extrude_cross_section = printer["configfile"].config["extruder"]["max_extrude_cross_section"]|float %} - {% set filament_diameter = printer["configfile"].config["extruder"]["filament_diameter"]|float %} - - {% set line_height = 0.6 %} - - # We first compute the width of the prime line - {% set purge_volume = prime_line_purge_distance * 3.14159 * (filament_diameter / 2)**2 %} - {% set line_width = purge_volume / (line_height * prime_line_length) %} - - # Then we check that the prime line cross section will not be problematic (exceeding Klipper max_extrude_cross_section) - # or, if it's the case, we warn the user and add a correction to the length of filament to be purged - {% if (line_height * line_width) > max_extrude_cross_section %} - {% if verbose %} - {action_respond_info("The prime_line_purge_distance of %.4f mm is too high and will exceed the max_extrude_cross_section!" % prime_line_purge_distance)} - {% endif %} - {% set prime_line_purge_distance = 0.98 * (max_extrude_cross_section * prime_line_length) / (3.14159 * (filament_diameter / 2)**2) %} - {% set purge_volume = prime_line_purge_distance * 3.14159 * (filament_diameter / 2)**2 %} - {% set line_width = purge_volume / (line_height * prime_line_length) %} - {% if verbose %} - {action_respond_info("Klippain corrected the prime_line_purge_distance to %.4f mm" % prime_line_purge_distance)} - {% endif %} - {% endif %} - - # We then compute the height to width ratio and validate that the prime line will not be too thin - {% if (line_height / line_width) >= 0.5 %} # TODO: validate this 1/2 ratio is good for all - {% if verbose %} - {action_raise_error("The prime line will be too thin and will probably not stick properly to the bed. Increase its purge distance or decrease its length! Aborting...")} - {% endif %} - {% endif %} - - # Finally we compute the speed to get the correct flowrate for the prime line - {% set speed = (prime_line_flowrate / (line_height * line_width)) * 60 |float %} - - {% if klippain_ercf_enabled %} - {% if printer.ercf.enabled %} - {% if printer.ercf.clog_detection > 0 %} - {% if verbose %} - RESPOND MSG="ERCF clog detection deactivated for the prime line" - {% endif %} - ERCF_TEST_CONFIG enable_clog_detection=0 - {% endif %} - {% endif %} - {% endif %} - - G91 - M83 - G1 Z5 F{Sz} - - # Starting position - G90 - G0 X{prime_line_x} Y{prime_line_y} F{St} - G1 Z{line_height} F{Sz|int / 2} - - # Add pressure in the nozzle - G92 E0 - G1 E18 F300 - - # Prime line - G92 E0 - {% if prime_line_direction == "X" %} - G1 X{prime_line_x + prime_line_length} E{prime_line_purge_distance} F{speed} - {% elif prime_line_direction == "Y" %} - G1 Y{prime_line_y + prime_line_length} E{prime_line_purge_distance} F{speed} - {% else %} - { action_respond_error("Prime line direction is not valid. Choose either X or Y in the variables.cfg file!") } - {% endif %} - - # Retract and Z-hop - G92 E0 - G1 E-0.2 F2100 - G92 E0 - G1 Z3 F{Sz} - M400 - - {% if klippain_ercf_enabled %} - {% if printer.ercf.enabled %} - {% if printer.ercf.clog_detection > 0 %} - {% if verbose %} - RESPOND MSG="ERCF clog detection reactivated after the prime line" - {% endif %} - ERCF_TEST_CONFIG enable_clog_detection={printer.ercf.clog_detection} - {% endif %} - {% endif %} - {% endif %} + PRIMELINE [gcode_macro _MODULE_HEATSOAK_BED] diff --git a/macros/helpers/prime_line.cfg b/macros/helpers/prime_line.cfg new file mode 100644 index 000000000..d8ae9f0ce --- /dev/null +++ b/macros/helpers/prime_line.cfg @@ -0,0 +1,101 @@ +[gcode_macro PRIMELINE] +gcode: + # Macro parameters + {% set prime_line_length = params.LINE_LENGTH|default(printer["gcode_macro _USER_VARIABLES"].prime_line_length)|float %} + {% set prime_line_purge_distance = params.PURGE_LENGTH|default(printer["gcode_macro _USER_VARIABLES"].prime_line_purge_distance)|float %} + {% set prime_line_flowrate = params.FLOWRATE|default(printer["gcode_macro _USER_VARIABLES"].prime_line_flowrate)|float %} + + # Set internal macro vars + {% set prime_line_x, prime_line_y = printer["gcode_macro _USER_VARIABLES"].prime_line_xy|map('float') %} + {% set prime_line_direction = printer["gcode_macro _USER_VARIABLES"].prime_line_direction|string|upper %} + + {% set St = printer["gcode_macro _USER_VARIABLES"].travel_speed * 60 %} + {% set Sz = printer["gcode_macro _USER_VARIABLES"].z_drop_speed * 60 %} + {% set verbose = printer["gcode_macro _USER_VARIABLES"].verbose %} + + {% set klippain_ercf_enabled = printer["gcode_macro _USER_VARIABLES"].klippain_ercf_enabled %} + + {% set max_extrude_cross_section = printer["configfile"].config["extruder"]["max_extrude_cross_section"]|float %} + {% set filament_diameter = printer["configfile"].config["extruder"]["filament_diameter"]|float %} + + {% set line_height = 0.6 %} + + # We first compute the width of the prime line + {% set purge_volume = prime_line_purge_distance * 3.14159 * (filament_diameter / 2)**2 %} + {% set line_width = purge_volume / (line_height * prime_line_length) %} + + # Then we check that the prime line cross section will not be problematic (exceeding Klipper max_extrude_cross_section) + # or, if it's the case, we warn the user and add a correction to the length of filament to be purged + {% if (line_height * line_width) > max_extrude_cross_section %} + {% if verbose %} + {action_respond_info("The prime_line_purge_distance of %.4f mm is too high and will exceed the max_extrude_cross_section!" % prime_line_purge_distance)} + {% endif %} + {% set prime_line_purge_distance = 0.98 * (max_extrude_cross_section * prime_line_length) / (3.14159 * (filament_diameter / 2)**2) %} + {% set purge_volume = prime_line_purge_distance * 3.14159 * (filament_diameter / 2)**2 %} + {% set line_width = purge_volume / (line_height * prime_line_length) %} + {% if verbose %} + {action_respond_info("Klippain corrected the prime_line_purge_distance to %.4f mm" % prime_line_purge_distance)} + {% endif %} + {% endif %} + + # We then compute the height to width ratio and validate that the prime line will not be too thin + {% if (line_height / line_width) >= 0.5 %} # TODO: validate this 1/2 ratio is good for all + {% if verbose %} + {action_raise_error("The prime line will be too thin and will probably not stick properly to the bed. Increase its purge distance or decrease its length! Aborting...")} + {% endif %} + {% endif %} + + # Finally we compute the speed to get the correct flowrate for the prime line + {% set speed = (prime_line_flowrate / (line_height * line_width)) * 60 |float %} + + {% if klippain_ercf_enabled %} + {% if printer.ercf.enabled %} + {% if printer.ercf.clog_detection > 0 %} + {% if verbose %} + RESPOND MSG="ERCF clog detection deactivated for the prime line" + {% endif %} + ERCF_TEST_CONFIG enable_clog_detection=0 + {% endif %} + {% endif %} + {% endif %} + + G91 + M83 + G1 Z5 F{Sz} + + # Starting position + G90 + G0 X{prime_line_x} Y{prime_line_y} F{St} + G1 Z{line_height} F{Sz|int / 2} + + # Add pressure in the nozzle + G92 E0 + G1 E18 F300 + + # Prime line + G92 E0 + {% if prime_line_direction == "X" %} + G1 X{prime_line_x + prime_line_length} E{prime_line_purge_distance} F{speed} + {% elif prime_line_direction == "Y" %} + G1 Y{prime_line_y + prime_line_length} E{prime_line_purge_distance} F{speed} + {% else %} + { action_respond_error("Prime line direction is not valid. Choose either X or Y in the variables.cfg file!") } + {% endif %} + + # Retract and Z-hop + G92 E0 + G1 E-0.2 F2100 + G92 E0 + G1 Z3 F{Sz} + M400 + + {% if klippain_ercf_enabled %} + {% if printer.ercf.enabled %} + {% if printer.ercf.clog_detection > 0 %} + {% if verbose %} + RESPOND MSG="ERCF clog detection reactivated after the prime line" + {% endif %} + ERCF_TEST_CONFIG enable_clog_detection={printer.ercf.clog_detection} + {% endif %} + {% endif %} + {% endif %} From 55757a7576d43a72acdeca9a36fd314fe5b5c433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Fri, 16 Jun 2023 13:32:53 +0000 Subject: [PATCH 06/11] reverted the home Z after tilting in favor of the force_homing_before_brush variable --- macros/base/homing/tilting.cfg | 2 -- macros/base/start_print.cfg | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/macros/base/homing/tilting.cfg b/macros/base/homing/tilting.cfg index c269e1661..55ff4db01 100644 --- a/macros/base/homing/tilting.cfg +++ b/macros/base/homing/tilting.cfg @@ -21,7 +21,6 @@ gcode: RESPOND MSG="QGL..." {% endif %} QUAD_GANTRY_LEVEL - G28 Z {% endif %} {% elif conf_ztilt %} {% if printer.z_tilt.applied|lower == 'false' or FORCE_OPERATION %} @@ -29,7 +28,6 @@ gcode: RESPOND MSG="Z tilt adjust..." {% endif %} Z_TILT_ADJUST - G28 Z {% endif %} {% else %} {% if verbose %} diff --git a/macros/base/start_print.cfg b/macros/base/start_print.cfg index e2072a368..ea3458411 100644 --- a/macros/base/start_print.cfg +++ b/macros/base/start_print.cfg @@ -353,6 +353,7 @@ gcode: {% endif %} {% if zcalib_plugin_enabled %} + G28 Z CALIBRATE_Z {% else %} G28 Z From b664689d77642224235e3b97c5071d0a447d89a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Fri, 16 Jun 2023 17:57:51 +0000 Subject: [PATCH 07/11] reverted and optimized the ADXL changes --- config/hardware/accelerometers/adxl345_BTT_SB22xx.cfg | 8 ++++++++ config/hardware/accelerometers/adxl345_ebb.cfg | 8 ++++++++ config/hardware/accelerometers/adxl345_sb2040.cfg | 8 ++++++++ config/hardware/accelerometers/adxl345_sht.cfg | 5 +++++ config/hardware/accelerometers/adxl345_skr.cfg | 1 + .../{ => generics}/adxl345_hardware_spi1.cfg | 6 +++--- .../{ => generics}/adxl345_hardware_ssp1.cfg | 6 +++--- .../{ => generics}/adxl345_software_spi.cfg | 6 +++--- .../mcu_defaults/toolhead/BTT_EBB36-42_v1.0.cfg | 6 ------ .../mcu_defaults/toolhead/BTT_EBB36-42_v1.1.cfg | 6 ------ .../mcu_defaults/toolhead/BTT_EBB36-42_v1.2.cfg | 6 ------ user_templates/mcu_defaults/toolhead/BTT_SB2209_v1.0.cfg | 6 ------ user_templates/mcu_defaults/toolhead/BTT_SB2240_v1.0.cfg | 6 ------ .../mcu_defaults/toolhead/Mellow_SB2040_v1.cfg | 6 ------ .../mcu_defaults/toolhead/Mellow_SHT36-42_v1.x.cfg | 3 --- .../mcu_defaults/toolhead/Mellow_SHT36_v2.x.cfg | 3 --- user_templates/printer.cfg | 9 ++++++--- 17 files changed, 45 insertions(+), 54 deletions(-) create mode 100644 config/hardware/accelerometers/adxl345_BTT_SB22xx.cfg create mode 100644 config/hardware/accelerometers/adxl345_ebb.cfg create mode 100644 config/hardware/accelerometers/adxl345_sb2040.cfg create mode 100644 config/hardware/accelerometers/adxl345_sht.cfg create mode 100644 config/hardware/accelerometers/adxl345_skr.cfg rename config/hardware/accelerometers/{ => generics}/adxl345_hardware_spi1.cfg (73%) rename config/hardware/accelerometers/{ => generics}/adxl345_hardware_ssp1.cfg (65%) rename config/hardware/accelerometers/{ => generics}/adxl345_software_spi.cfg (77%) diff --git a/config/hardware/accelerometers/adxl345_BTT_SB22xx.cfg b/config/hardware/accelerometers/adxl345_BTT_SB22xx.cfg new file mode 100644 index 000000000..9f06e9d80 --- /dev/null +++ b/config/hardware/accelerometers/adxl345_BTT_SB22xx.cfg @@ -0,0 +1,8 @@ +[include generics/adxl345_software_spi.cfg] + +# As it's a toolhead ADXL, we add some default pins overrides from here +[adxl345] +cs_pin: toolhead:ADXL_CS +spi_software_sclk_pin: toolhead:ADXL_SCLK +spi_software_mosi_pin: toolhead:ADXL_MOSI +spi_software_miso_pin: toolhead:ADXL_MISO diff --git a/config/hardware/accelerometers/adxl345_ebb.cfg b/config/hardware/accelerometers/adxl345_ebb.cfg new file mode 100644 index 000000000..9f06e9d80 --- /dev/null +++ b/config/hardware/accelerometers/adxl345_ebb.cfg @@ -0,0 +1,8 @@ +[include generics/adxl345_software_spi.cfg] + +# As it's a toolhead ADXL, we add some default pins overrides from here +[adxl345] +cs_pin: toolhead:ADXL_CS +spi_software_sclk_pin: toolhead:ADXL_SCLK +spi_software_mosi_pin: toolhead:ADXL_MOSI +spi_software_miso_pin: toolhead:ADXL_MISO diff --git a/config/hardware/accelerometers/adxl345_sb2040.cfg b/config/hardware/accelerometers/adxl345_sb2040.cfg new file mode 100644 index 000000000..9f06e9d80 --- /dev/null +++ b/config/hardware/accelerometers/adxl345_sb2040.cfg @@ -0,0 +1,8 @@ +[include generics/adxl345_software_spi.cfg] + +# As it's a toolhead ADXL, we add some default pins overrides from here +[adxl345] +cs_pin: toolhead:ADXL_CS +spi_software_sclk_pin: toolhead:ADXL_SCLK +spi_software_mosi_pin: toolhead:ADXL_MOSI +spi_software_miso_pin: toolhead:ADXL_MISO diff --git a/config/hardware/accelerometers/adxl345_sht.cfg b/config/hardware/accelerometers/adxl345_sht.cfg new file mode 100644 index 000000000..df94c4a1f --- /dev/null +++ b/config/hardware/accelerometers/adxl345_sht.cfg @@ -0,0 +1,5 @@ +[include generics/adxl345_hardware_spi1.cfg] + +# As it's a toolhead ADXL, we add some default pins overrides from here +[adxl345] +cs_pin: toolhead:ADXL_CS diff --git a/config/hardware/accelerometers/adxl345_skr.cfg b/config/hardware/accelerometers/adxl345_skr.cfg new file mode 100644 index 000000000..cb4a6b335 --- /dev/null +++ b/config/hardware/accelerometers/adxl345_skr.cfg @@ -0,0 +1 @@ +[include generics/adxl345_hardware_ssp1.cfg] diff --git a/config/hardware/accelerometers/adxl345_hardware_spi1.cfg b/config/hardware/accelerometers/generics/adxl345_hardware_spi1.cfg similarity index 73% rename from config/hardware/accelerometers/adxl345_hardware_spi1.cfg rename to config/hardware/accelerometers/generics/adxl345_hardware_spi1.cfg index 963c60107..f0746898e 100644 --- a/config/hardware/accelerometers/adxl345_hardware_spi1.cfg +++ b/config/hardware/accelerometers/generics/adxl345_hardware_spi1.cfg @@ -20,6 +20,6 @@ probe_points: # Include the IS calibration macros to unlock them when # an accelerometer is installed on the machine -[include ../../../macros/helpers/resonance_override.cfg] -[include ../../../macros/calibration/IS_shaper_calibrate.cfg] -[include ../../../macros/calibration/IS_vibrations_measurement.cfg] +[include ../../../../macros/helpers/resonance_override.cfg] +[include ../../../../macros/calibration/IS_shaper_calibrate.cfg] +[include ../../../../macros/calibration/IS_vibrations_measurement.cfg] diff --git a/config/hardware/accelerometers/adxl345_hardware_ssp1.cfg b/config/hardware/accelerometers/generics/adxl345_hardware_ssp1.cfg similarity index 65% rename from config/hardware/accelerometers/adxl345_hardware_ssp1.cfg rename to config/hardware/accelerometers/generics/adxl345_hardware_ssp1.cfg index 9276b532f..165c905b1 100644 --- a/config/hardware/accelerometers/adxl345_hardware_ssp1.cfg +++ b/config/hardware/accelerometers/generics/adxl345_hardware_ssp1.cfg @@ -17,6 +17,6 @@ probe_points: # Include the IS calibration macros to unlock them when # an accelerometer is installed on the machine -[include ../../../macros/helpers/resonance_override.cfg] -[include ../../../macros/calibration/IS_shaper_calibrate.cfg] -[include ../../../macros/calibration/IS_vibrations_measurement.cfg] +[include ../../../../macros/helpers/resonance_override.cfg] +[include ../../../../macros/calibration/IS_shaper_calibrate.cfg] +[include ../../../../macros/calibration/IS_vibrations_measurement.cfg] diff --git a/config/hardware/accelerometers/adxl345_software_spi.cfg b/config/hardware/accelerometers/generics/adxl345_software_spi.cfg similarity index 77% rename from config/hardware/accelerometers/adxl345_software_spi.cfg rename to config/hardware/accelerometers/generics/adxl345_software_spi.cfg index 02884cfc1..480c21349 100644 --- a/config/hardware/accelerometers/adxl345_software_spi.cfg +++ b/config/hardware/accelerometers/generics/adxl345_software_spi.cfg @@ -21,6 +21,6 @@ probe_points: # Include the IS calibration macros to unlock them when # an accelerometer is installed on the machine -[include ../../../macros/helpers/resonance_override.cfg] -[include ../../../macros/calibration/IS_shaper_calibrate.cfg] -[include ../../../macros/calibration/IS_vibrations_measurement.cfg] +[include ../../../../macros/helpers/resonance_override.cfg] +[include ../../../../macros/calibration/IS_shaper_calibrate.cfg] +[include ../../../../macros/calibration/IS_vibrations_measurement.cfg] diff --git a/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.0.cfg b/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.0.cfg index a02592191..348a1dac3 100644 --- a/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.0.cfg +++ b/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.0.cfg @@ -66,9 +66,3 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART -[adxl345] -cs_pin: toolhead:ADXL_CS -spi_software_sclk_pin: toolhead:ADXL_SCLK -spi_software_mosi_pin: toolhead:ADXL_MOSI -spi_software_miso_pin: toolhead:ADXL_MISO - diff --git a/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.1.cfg b/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.1.cfg index 3bfe66c1c..8338e47df 100644 --- a/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.1.cfg +++ b/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.1.cfg @@ -66,9 +66,3 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART -[adxl345] -cs_pin: toolhead:ADXL_CS -spi_software_sclk_pin: toolhead:ADXL_SCLK -spi_software_mosi_pin: toolhead:ADXL_MOSI -spi_software_miso_pin: toolhead:ADXL_MISO - diff --git a/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.2.cfg b/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.2.cfg index bb924dde7..fb84e2ac4 100644 --- a/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.2.cfg +++ b/user_templates/mcu_defaults/toolhead/BTT_EBB36-42_v1.2.cfg @@ -66,9 +66,3 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART -[adxl345] -cs_pin: toolhead:ADXL_CS -spi_software_sclk_pin: toolhead:ADXL_SCLK -spi_software_mosi_pin: toolhead:ADXL_MOSI -spi_software_miso_pin: toolhead:ADXL_MISO - diff --git a/user_templates/mcu_defaults/toolhead/BTT_SB2209_v1.0.cfg b/user_templates/mcu_defaults/toolhead/BTT_SB2209_v1.0.cfg index c344532f0..48a805be8 100644 --- a/user_templates/mcu_defaults/toolhead/BTT_SB2209_v1.0.cfg +++ b/user_templates/mcu_defaults/toolhead/BTT_SB2209_v1.0.cfg @@ -67,9 +67,3 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART -[adxl345] -cs_pin: toolhead:ADXL_CS -spi_software_sclk_pin: toolhead:ADXL_SCLK -spi_software_mosi_pin: toolhead:ADXL_MOSI -spi_software_miso_pin: toolhead:ADXL_MISO - diff --git a/user_templates/mcu_defaults/toolhead/BTT_SB2240_v1.0.cfg b/user_templates/mcu_defaults/toolhead/BTT_SB2240_v1.0.cfg index c93aec612..867d0d561 100644 --- a/user_templates/mcu_defaults/toolhead/BTT_SB2240_v1.0.cfg +++ b/user_templates/mcu_defaults/toolhead/BTT_SB2240_v1.0.cfg @@ -89,9 +89,3 @@ driver_SGT: 30 driver_SEMIN: 2 driver_SEMAX: 8 -[adxl345] -cs_pin: toolhead:ADXL_CS -spi_software_sclk_pin: toolhead:ADXL_SCLK -spi_software_mosi_pin: toolhead:ADXL_MOSI -spi_software_miso_pin: toolhead:ADXL_MISO - diff --git a/user_templates/mcu_defaults/toolhead/Mellow_SB2040_v1.cfg b/user_templates/mcu_defaults/toolhead/Mellow_SB2040_v1.cfg index 851639414..a5b92ea37 100644 --- a/user_templates/mcu_defaults/toolhead/Mellow_SB2040_v1.cfg +++ b/user_templates/mcu_defaults/toolhead/Mellow_SB2040_v1.cfg @@ -66,9 +66,3 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART -[adxl345] -cs_pin: toolhead:ADXL_CS -spi_software_sclk_pin: toolhead:ADXL_SCLK -spi_software_mosi_pin: toolhead:ADXL_MOSI -spi_software_miso_pin: toolhead:ADXL_MISO - diff --git a/user_templates/mcu_defaults/toolhead/Mellow_SHT36-42_v1.x.cfg b/user_templates/mcu_defaults/toolhead/Mellow_SHT36-42_v1.x.cfg index 8acba97dd..6f85acea5 100644 --- a/user_templates/mcu_defaults/toolhead/Mellow_SHT36-42_v1.x.cfg +++ b/user_templates/mcu_defaults/toolhead/Mellow_SHT36-42_v1.x.cfg @@ -67,6 +67,3 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART -[adxl345] -cs_pin: toolhead:ADXL_CS - diff --git a/user_templates/mcu_defaults/toolhead/Mellow_SHT36_v2.x.cfg b/user_templates/mcu_defaults/toolhead/Mellow_SHT36_v2.x.cfg index 72a794bfa..343dc4c31 100644 --- a/user_templates/mcu_defaults/toolhead/Mellow_SHT36_v2.x.cfg +++ b/user_templates/mcu_defaults/toolhead/Mellow_SHT36_v2.x.cfg @@ -66,6 +66,3 @@ pin: toolhead:STATUS_NEOPIXEL [tmc2209 extruder] uart_pin: toolhead:E_TMCUART -[adxl345] -cs_pin: toolhead:ADXL_CS - diff --git a/user_templates/printer.cfg b/user_templates/printer.cfg index 9f1634320..74ac1a9e7 100644 --- a/user_templates/printer.cfg +++ b/user_templates/printer.cfg @@ -160,10 +160,13 @@ # --------------------------------------------------------------------- ACCELEROMETER ----> Select only one line ### -------------------------------------------------------------------------------------- # [include config/hardware/accelerometers/adxl345_rpi.cfg] # For ADXL plugged directly on the Pi (official and recommended way) -# [include config/hardware/accelerometers/adxl345_software_spi.cfg] # For ADXL plugged in boards such as BTT EBB, SB2209, SB2240, or Mellow Fly-SB2040, ... -# [include config/hardware/accelerometers/adxl345_hardware_spi1.cfg] # For ADXL plugged in Mellow SHT, Octopus, ... -# [include config/hardware/accelerometers/adxl345_hardware_ssp1.cfg] # For ADXL plugged in SKRv1.4, ... # [include config/hardware/accelerometers/adxl345_usb.cfg] # For KUBSA, ... +# [include config/hardware/accelerometers/adxl345_skr.cfg] # For ADXL plugged in SKRv1.4 (not a conventional way) + +# [include config/hardware/accelerometers/adxl345_sb2040.cfg] # For ADXL plugged in Mellow Fly-SB2040 boards +# [include config/hardware/accelerometers/adxl345_ebb.cfg] # For ADXL plugged in BTT EBB36 or EBB42 boards +# [include config/hardware/accelerometers/adxl345_sht.cfg] # For ADXL plugged in Mellow SHT36 or SHT42 boards +# [include config/hardware/accelerometers/adxl345_BTT_SB22xx.cfg] # For ADXL plugged in BTT SB2209 or SB2240 boards # ---------------------------------------------------------------------------------------- From b2d57a21e45fb00e062a0c2ce8c1b2bd4c550d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Fri, 16 Jun 2023 18:22:57 +0000 Subject: [PATCH 08/11] simplified the flow calibration macro standalone install --- docs/features/flow_calibration.md | 4 +--- macros/calibration/calibrate_flow.cfg | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/features/flow_calibration.md b/docs/features/flow_calibration.md index bd6837222..d26107a5a 100644 --- a/docs/features/flow_calibration.md +++ b/docs/features/flow_calibration.md @@ -15,9 +15,7 @@ This macro is parametric and most of the values can be adjusted with their respe If you installed and use the full config folder of this github repository, this is already enabled by default and should work out of the box. -If you want to install it to your own custom config, here is the way to go: - 1. Copy the [calibrate_flow.cfg](./../../macros/calibration/calibrate_flow.cfg) macro file directly into your own config. - 2. **IMPORTANT STEP**: Add and activate (if not already the case) a `[gcode_arcs]` section in your config as it's used for the round corners. Don't hesitate to change the resolution to something like 0.1 or 0.2 to get a better surface finish in the corner radius. +If you want to install it to your own custom config, just copy the [calibrate_flow.cfg](./../../macros/calibration/calibrate_flow.cfg) macro file directly into your own config and include it. Do not forget to issue a firmware restart. ## Usage diff --git a/macros/calibration/calibrate_flow.cfg b/macros/calibration/calibrate_flow.cfg index 854772f0f..871f28f04 100644 --- a/macros/calibration/calibrate_flow.cfg +++ b/macros/calibration/calibrate_flow.cfg @@ -2,9 +2,10 @@ ###### FLOW MULTIPLIER CALIBRATION ###### ######################################### # Written by Frix_x#0161 # -# @version: 1.5 +# @version: 1.6 # CHANGELOG: +# v1.6: directly added the [gcode_arcs] definition in this file to simplify installation # v1.5: moved the install notes into a proper markdown file in: docs > features > flow_calibration.md # v1.4: fix issue when extrude_factor is != 1 # v1.3: fix the logging @@ -34,6 +35,9 @@ variable_last_shell_thickness: 0.0 variable_last_evalue: 0.0 gcode: +[gcode_arcs] +resolution: 0.1 + [gcode_macro FLOW_MULTIPLIER_CALIBRATION] description: Print a small tower to calibrate the extrusion flow multiplier by measuring the shell gcode: From cf101ca21835dd6b295b851b448d979fdcc67123 Mon Sep 17 00:00:00 2001 From: Surion79 <102791900+Surion79@users.noreply.github.com> Date: Sat, 17 Jun 2023 12:44:38 +0200 Subject: [PATCH 09/11] Prime line params (#237) Prime line parameters for position and direction added --- macros/helpers/prime_line.cfg | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/macros/helpers/prime_line.cfg b/macros/helpers/prime_line.cfg index d8ae9f0ce..032654927 100644 --- a/macros/helpers/prime_line.cfg +++ b/macros/helpers/prime_line.cfg @@ -20,6 +20,11 @@ gcode: {% set line_height = 0.6 %} + # some more Macro parameters after retrieving defaults + {% set prime_line_x = params.START_X|default(prime_line_x)|float %} + {% set prime_line_y = params.START_Y|default(prime_line_y)|float %} + {% set prime_line_direction = params.LINE_DIRECTION|default(printer["gcode_macro _USER_VARIABLES"].prime_line_direction)|string|upper %} + # We first compute the width of the prime line {% set purge_volume = prime_line_purge_distance * 3.14159 * (filament_diameter / 2)**2 %} {% set line_width = purge_volume / (line_height * prime_line_length) %} From e070cde4ecb3580449ca0ae7008d0f4cf190da77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Sun, 18 Jun 2023 15:43:01 +0200 Subject: [PATCH 10/11] reduced corexy default Z max speed and fixed a typo in homing_override.cfg --- config/kinematics/corexy.cfg | 2 +- macros/base/homing/{homing_overide.cfg => homing_override.cfg} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename macros/base/homing/{homing_overide.cfg => homing_override.cfg} (100%) diff --git a/config/kinematics/corexy.cfg b/config/kinematics/corexy.cfg index 99fccd892..1a5fb2863 100644 --- a/config/kinematics/corexy.cfg +++ b/config/kinematics/corexy.cfg @@ -2,6 +2,6 @@ kinematics: corexy max_velocity: 400 max_accel: 8000 -max_z_velocity: 50 +max_z_velocity: 30 max_z_accel: 500 square_corner_velocity: 5.0 diff --git a/macros/base/homing/homing_overide.cfg b/macros/base/homing/homing_override.cfg similarity index 100% rename from macros/base/homing/homing_overide.cfg rename to macros/base/homing/homing_override.cfg From 6195dccf25bd9a992bb0bf8b588d0bebca8b9181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Sun, 18 Jun 2023 17:39:03 +0200 Subject: [PATCH 11/11] small improvements to the IS and vibration docs --- docs/features/is_workflow.md | 18 ++++++++++++------ docs/features/vibr_measurements.md | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/docs/features/is_workflow.md b/docs/features/is_workflow.md index 814a1a1e3..08d4cc7d8 100644 --- a/docs/features/is_workflow.md +++ b/docs/features/is_workflow.md @@ -19,26 +19,32 @@ Results can be found in the [ADXL results folder](./../../adxl_results/) that is ## Installation 1. Copy the [IS_shaper_calibrate.cfg](./../../macros/calibration/IS_shaper_calibrate.cfg) macro file directly into your own config. - 2. Be sure to have the `gcode_shell_command.py` Klipper extension installed. Easiest way to install it is to use the advanced section of KIAUH. + 2. Be sure to have the `gcode_shell_command.py` Klipper extension installed. Easiest way to install it is to use the advanced section of KIAUH. This is done automatically when running Klippain. 3. Add my [scripts](./../../scripts/) folder at the root of your own config (ie. in your `~/printer_data/config/` directory). Note: if using Windows to do the copy/paste of the files, be careful with the line endings for the `plot_graphs.sh` file and the `graph_vibrations.py` file: **Linux line endings (LF or \n) are mandatory!** If the file are using Windows line endings, you will get errors like `\r : unknown command` when running the script. If you're not confident regarding your text editor behavior, the best way is to directly download the files on the pi by using for example wget over SSH: - ``` + ```bash wget -P ~/printer_data/config/scripts https://raw.githubusercontent.com/Frix-x/klippain/main/scripts/plot_graphs.sh wget -P ~/printer_data/config/scripts https://raw.githubusercontent.com/Frix-x/klippain/main/scripts/graph_vibrations.py ``` - 4. Make the scripts executable using SSH. When in the folder, use: + 4. Make the scripts executable using SSH. When in the folder (`cd ~/printer_data/config/scripts`), use: - ``` + ```bash chmod +x ./plot_graphs.sh chmod +x ./graph_vibrations.py ``` - 5. Include the `shell_commands.cfg` to your config to be able to call the plot_graphs script. You can either copy/paste its content to your own `printer.cfg` file or just include it using `[include path/to/shell_commands.cfg]`. + 5. Add this new section at the end of your `printer.cfg` file: + ``` + [gcode_shell_command plot_graph] + command: bash /home/pi/printer_data/config/scripts/plot_graphs.sh + timeout: 500.0 + verbose: True + ``` - Note: if your user is not `pi`, please correct it in the `[gcode_shell_command plot_graph]` command accordingly. + Note: if your user is not `pi`, please correct the path in the command accordingly. 6. (Optional) You can modify the first lines of the `plot_graphs.sh` script to configure where you want to store the results. Default: `~/printer_data/config/adxl_results` diff --git a/docs/features/vibr_measurements.md b/docs/features/vibr_measurements.md index 1ba23c0d3..d4071ccb5 100644 --- a/docs/features/vibr_measurements.md +++ b/docs/features/vibr_measurements.md @@ -22,26 +22,32 @@ Results can be found in the [ADXL results folder](./../../adxl_results/) that is ## Installation 1. Copy the [IS_vibrations_measurement.cfg](./../../macros/calibration/IS_vibrations_measurement.cfg) macro file directly into your own config. - 2. Be sure to have the `gcode_shell_command.py` Klipper extension installed. Easiest way to install it is to use the advanced section of KIAUH. + 2. Be sure to have the `gcode_shell_command.py` Klipper extension installed. Easiest way to install it is to use the advanced section of KIAUH. This is done automatically when running Klippain. 3. Add my [scripts](./../../scripts/) folder at the root of your own config (ie. in your `~/printer_data/config/` directory). Note: if using Windows to do the copy/paste of the files, be careful with the line endings for the `plot_graphs.sh` file and the `graph_vibrations.py` file: **Linux line endings (LF or \n) are mandatory!** If the file are using Windows line endings, you will get errors like `\r : unknown command` when running the script. If you're not confident regarding your text editor behavior, the best way is to directly download the files on the pi by using for example wget over SSH: - ``` + ```bash wget -P ~/printer_data/config/scripts https://raw.githubusercontent.com/Frix-x/klippain/main/scripts/plot_graphs.sh wget -P ~/printer_data/config/scripts https://raw.githubusercontent.com/Frix-x/klippain/main/scripts/graph_vibrations.py ``` - 4. Make the scripts executable using SSH. When in the folder, use: + 4. Make the scripts executable using SSH. When in the folder (`cd ~/printer_data/config/scripts`), use: - ``` + ```bash chmod +x ./plot_graphs.sh chmod +x ./graph_vibrations.py ``` - 5. Include the `shell_commands.cfg` to your config to be able to call the plot_graphs script. You can either copy/paste its content to your own `printer.cfg` file or just include it using `[include path/to/shell_commands.cfg]`. + 5. Add this new section at the end of your `printer.cfg` file: + ``` + [gcode_shell_command plot_graph] + command: bash /home/pi/printer_data/config/scripts/plot_graphs.sh + timeout: 500.0 + verbose: True + ``` - Note: if your user is not `pi`, please correct it in the `[gcode_shell_command plot_graph]` command accordingly. + Note: if your user is not `pi`, please correct the path in the command accordingly. 6. (Optional) You can modify the first lines of the `plot_graphs.sh` script to configure where you want to store the results. Default: `~/printer_data/config/adxl_results`