From d7b2063c10e9afbd5528ea0c77e3eacaa9153076 Mon Sep 17 00:00:00 2001 From: Bogdan <31422391+Atomique13@users.noreply.github.com> Date: Fri, 15 May 2026 02:14:39 +0000 Subject: [PATCH 1/5] Add client configuration file and update installation scripts - Introduced a new configuration file `client.cfg` containing client klipper macro definitions and customization options. - Updated `kalico_2026.02.00.bb` to include `client.cfg` in the source URI and installation process. - Modified the installation script to copy `client.cfg` to the readonly configuration directory. - Updated the list of configuration files in `CONFFILES` to include `client.cfg`. --- .../recipes-apps/klipper/files/client.cfg | 319 ++++++++ .../recipes-apps/klipper/files/machine.cfg | 371 +++++----- .../recipes-apps/klipper/files/macros.cfg | 695 ++++++++++++------ .../recipes-apps/klipper/kalico_2026.02.00.bb | 4 +- 4 files changed, 994 insertions(+), 395 deletions(-) create mode 100644 meta-opencentauri/recipes-apps/klipper/files/client.cfg diff --git a/meta-opencentauri/recipes-apps/klipper/files/client.cfg b/meta-opencentauri/recipes-apps/klipper/files/client.cfg new file mode 100644 index 00000000..a75c4d20 --- /dev/null +++ b/meta-opencentauri/recipes-apps/klipper/files/client.cfg @@ -0,0 +1,319 @@ +# ----- +# PLEASE DO NOT EDIT THIS FILE. EDIT printer.cfg INSTEAD. +# EDITING THIS FILE WILL EXCLUDE YOUR CHANGES FROM FUTURE UPDATES. +# ----- + +## Client klipper macro definitions +## +## Copyright (C) 2022 Alex Zellner +## +## This file may be distributed under the terms of the GNU GPLv3 license +## +## !!! This file is read-only. Maybe the used editor indicates that. !!! +## +## Customization: +## 1) copy the gcode_macro _CLIENT_VARIABLE (see below) to your printer.cfg +## 2) remove the comment mark (#) from all lines +## 3) change any value in there to your needs +## +## Use the PAUSE macro direct in your M600: +## e.g. with a different park position front left and a minimal height of 50 +## [gcode_macro M600] +## description: Filament change +## gcode: PAUSE X=10 Y=10 Z_MIN=50 +## Z_MIN will park the toolhead at a minimum of 50 mm above to bed to make it easier for you to swap filament. +## +## Client variable macro for your printer.cfg +#[gcode_macro _CLIENT_VARIABLE] +#variable_use_custom_pos : False ; use custom park coordinates for x,y [True/False] +#variable_custom_park_x : 0.0 ; custom x position; value must be within your defined min and max of X +#variable_custom_park_y : 0.0 ; custom y position; value must be within your defined min and max of Y +#variable_custom_park_dz : 2.0 ; custom dz value; the value in mm to lift the nozzle when move to park position +#variable_retract : 1.0 ; the value to retract while PAUSE +#variable_cancel_retract : 5.0 ; the value to retract while CANCEL_PRINT +#variable_speed_retract : 35.0 ; retract speed in mm/s +#variable_unretract : 1.0 ; the value to unretract while RESUME +#variable_speed_unretract : 35.0 ; unretract speed in mm/s +#variable_speed_hop : 15.0 ; z move speed in mm/s +#variable_speed_move : 100.0 ; move speed in mm/s +#variable_park_at_cancel : False ; allow to move the toolhead to park while execute CANCEL_PRINT [True/False] +#variable_park_at_cancel_x : None ; different park position during CANCEL_PRINT [None/Position as Float]; park_at_cancel must be True +#variable_park_at_cancel_y : None ; different park position during CANCEL_PRINT [None/Position as Float]; park_at_cancel must be True +## !!! Caution [firmware_retraction] must be defined in the printer.cfg if you set use_fw_retract: True !!! +#variable_use_fw_retract : False ; use fw_retraction instead of the manual version [True/False] +#variable_idle_timeout : 0 ; time in sec until idle_timeout kicks in. Value 0 means that no value will be set or restored +#variable_runout_sensor : "" ; If a sensor is defined, it will be used to cancel the execution of RESUME in case no filament is detected. +## Specify the config name of the runout sensor e.g "filament_switch_sensor runout". Hint use the same as in your printer.cfg +## !!! Custom macros, please use with care and review the section of the corresponding macro. +## These macros are for simple operations like setting a status LED. Please make sure your macro does not interfere with the basic macro functions. +## Only single line commands are supported, please create a macro if you need more than one command. +#variable_user_pause_macro : "" ; Everything inside the "" will be executed after the klipper base pause (PAUSE_BASE) function +#variable_user_resume_macro: "" ; Everything inside the "" will be executed before the klipper base resume (RESUME_BASE) function +#variable_user_cancel_macro: "" ; Everything inside the "" will be executed before the klipper base cancel (CANCEL_PRINT_BASE) function +#gcode: + +[virtual_sdcard] +path: /etc/klipper/gcodes +on_error_gcode: CANCEL_PRINT + +[pause_resume] +#recover_velocity: 50. +# When capture/restore is enabled, the speed at which to return to +# the captured position (in mm/s). Default is 50.0 mm/s. + +[display_status] + +[respond] + +[gcode_macro CANCEL_PRINT] +description: Cancel the actual running print +rename_existing: CANCEL_PRINT_BASE +gcode: + ##### get user parameters or use default ##### + {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} + {% set allow_park = client.park_at_cancel|default(false)|lower == 'true' %} + {% set retract = client.cancel_retract|default(5.0)|abs %} + ##### define park position ##### + {% set park_x = "" if (client.park_at_cancel_x|default(none) is none) + else "X=" ~ client.park_at_cancel_x %} + {% set park_y = "" if (client.park_at_cancel_y|default(none) is none) + else "Y=" ~ client.park_at_cancel_y %} + {% set custom_park = park_x|length > 0 or park_y|length > 0 %} + ##### end of definitions ##### + # restore idle_timeout time if needed + {% if printer['gcode_macro RESUME'].restore_idle_timeout > 0 %} + SET_IDLE_TIMEOUT TIMEOUT={printer['gcode_macro RESUME'].restore_idle_timeout} + {% endif %} + {% if (custom_park or not printer.pause_resume.is_paused) and allow_park %} _TOOLHEAD_PARK_PAUSE_CANCEL {park_x} {park_y} {% endif %} + _CLIENT_RETRACT LENGTH={retract} + TURN_OFF_HEATERS + M106 S0 + {client.user_cancel_macro|default("")} + SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=idle_state VALUE=False + # clear pause_next_layer and pause_at_layer as preparation for next print + SET_PAUSE_NEXT_LAYER ENABLE=0 + SET_PAUSE_AT_LAYER ENABLE=0 LAYER=0 + CANCEL_PRINT_BASE + +[gcode_macro PAUSE] +description: Pause the actual running print +rename_existing: PAUSE_BASE +gcode: + ##### get user parameters or use default ##### + {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} + {% set idle_timeout = client.idle_timeout|default(0) %} + {% set temp = printer[printer.toolhead.extruder].target if printer.toolhead.extruder != '' else 0 %} + {% set restore = False if printer.toolhead.extruder == '' + else True if params.RESTORE|default(1)|int == 1 else False %} + ##### end of definitions ##### + SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=last_extruder_temp VALUE="{{'restore': restore, 'temp': temp}}" + # set a new idle_timeout value + {% if idle_timeout > 0 %} + SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=restore_idle_timeout VALUE={printer.configfile.settings.idle_timeout.timeout} + SET_IDLE_TIMEOUT TIMEOUT={idle_timeout} + {% endif %} + PAUSE_BASE + {client.user_pause_macro|default("")} + _TOOLHEAD_PARK_PAUSE_CANCEL {rawparams} + +[gcode_macro RESUME] +description: Resume the actual running print +rename_existing: RESUME_BASE +variable_last_extruder_temp: {'restore': False, 'temp': 0} +variable_restore_idle_timeout: 0 +variable_idle_state: False +gcode: + ##### get user parameters or use default ##### + {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} + {% set velocity = printer.configfile.settings.pause_resume.recover_velocity %} + {% set sp_move = client.speed_move|default(velocity) %} + {% set runout_resume = True if client.runout_sensor|default("") == "" # no runout + else True if not printer[client.runout_sensor].enabled # sensor is disabled + else printer[client.runout_sensor].filament_detected %} # sensor status + {% set can_extrude = True if printer.toolhead.extruder == '' # no extruder defined in config + else printer[printer.toolhead.extruder].can_extrude %} # status of active extruder + {% set do_resume = False %} + {% set prompt_txt = [] %} + ##### end of definitions ##### + #### Printer comming from timeout idle state #### + {% if printer.idle_timeout.state|upper == "IDLE" or idle_state %} + SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=idle_state VALUE=False + {% if last_extruder_temp.restore %} + # we need to use the unicode (\u00B0) for the ° as py2 env's would throw an error otherwise + RESPOND TYPE=echo MSG='{"Restoring \"%s\" temperature to %3.1f\u00B0C, this may take some time" % (printer.toolhead.extruder, last_extruder_temp.temp) }' + M109 S{last_extruder_temp.temp} + {% set do_resume = True %} + {% elif can_extrude %} + {% set do_resume = True %} + {% else %} + RESPOND TYPE=error MSG='{"Resume aborted !!! \"%s\" not hot enough, please heat up again and press RESUME" % printer.toolhead.extruder}' + {% set _d = prompt_txt.append("\"%s\" not hot enough, please heat up again and press RESUME" % printer.toolhead.extruder) %} + {% endif %} + #### Printer comming out of regular PAUSE state #### + {% elif can_extrude %} + {% set do_resume = True %} + {% else %} + RESPOND TYPE=error MSG='{"Resume aborted !!! \"%s\" not hot enough, please heat up again and press RESUME" % printer.toolhead.extruder}' + {% set _d = prompt_txt.append("\"%s\" not hot enough, please heat up again and press RESUME" % printer.toolhead.extruder) %} + {% endif %} + {% if runout_resume %} + {% if do_resume %} + {% if restore_idle_timeout > 0 %} SET_IDLE_TIMEOUT TIMEOUT={restore_idle_timeout} {% endif %} # restore idle_timeout time + {client.user_resume_macro|default("")} + _CLIENT_EXTRUDE + RESUME_BASE VELOCITY={params.VELOCITY|default(sp_move)} + {% endif %} + {% else %} + RESPOND TYPE=error MSG='{"Resume aborted !!! \"%s\" detects no filament, please load filament and press RESUME" % (client.runout_sensor.split(" "))[1]}' + {% set _d = prompt_txt.append("\"%s\" detects no filament, please load filament and press RESUME" % (client.runout_sensor.split(" "))[1]) %} + {% endif %} + ##### Generate User Information box in case of abort ##### + {% if not (runout_resume and do_resume) %} + RESPOND TYPE=command MSG="action:prompt_begin RESUME aborted !!!" + {% for element in prompt_txt %} + RESPOND TYPE=command MSG='{"action:prompt_text %s" % element}' + {% endfor %} + RESPOND TYPE=command MSG="action:prompt_footer_button Ok|RESPOND TYPE=command MSG=action:prompt_end|info" + RESPOND TYPE=command MSG="action:prompt_show" + {% endif %} + +# Usage: SET_PAUSE_NEXT_LAYER [ENABLE=[0|1]] [MACRO=] +[gcode_macro SET_PAUSE_NEXT_LAYER] +description: Enable a pause if the next layer is reached +gcode: + {% set pause_next_layer = printer['gcode_macro SET_PRINT_STATS_INFO'].pause_next_layer %} + {% set ENABLE = params.ENABLE|default(1)|int != 0 %} + {% set MACRO = params.MACRO|default(pause_next_layer.call, True) %} + SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_next_layer VALUE="{{ 'enable': ENABLE, 'call': MACRO }}" + +# Usage: SET_PAUSE_AT_LAYER [ENABLE=[0|1]] [LAYER=] [MACRO=] +[gcode_macro SET_PAUSE_AT_LAYER] +description: Enable/disable a pause if a given layer number is reached +gcode: + {% set pause_at_layer = printer['gcode_macro SET_PRINT_STATS_INFO'].pause_at_layer %} + {% set ENABLE = params.ENABLE|int != 0 if params.ENABLE is defined + else params.LAYER is defined %} + {% set LAYER = params.LAYER|default(pause_at_layer.layer)|int %} + {% set MACRO = params.MACRO|default(pause_at_layer.call, True) %} + SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_at_layer VALUE="{{ 'enable': ENABLE, 'layer': LAYER, 'call': MACRO }}" + +# Usage: SET_PRINT_STATS_INFO [TOTAL_LAYER=] [CURRENT_LAYER= ] +[gcode_macro SET_PRINT_STATS_INFO] +rename_existing: SET_PRINT_STATS_INFO_BASE +description: Overwrite, to get pause_next_layer and pause_at_layer feature +variable_pause_next_layer: { 'enable': False, 'call': "PAUSE" } +variable_pause_at_layer : { 'enable': False, 'layer': 0, 'call': "PAUSE" } +gcode: + {% if pause_next_layer.enable %} + RESPOND TYPE=echo MSG='{"%s, forced by pause_next_layer" % pause_next_layer.call}' + {pause_next_layer.call} ; execute the given gcode to pause, should be either M600 or PAUSE + SET_PAUSE_NEXT_LAYER ENABLE=0 + {% elif pause_at_layer.enable and params.CURRENT_LAYER is defined and params.CURRENT_LAYER|int == pause_at_layer.layer %} + RESPOND TYPE=echo MSG='{"%s, forced by pause_at_layer [%d]" % (pause_at_layer.call, pause_at_layer.layer)}' + {pause_at_layer.call} ; execute the given gcode to pause, should be either M600 or PAUSE + SET_PAUSE_AT_LAYER ENABLE=0 + {% endif %} + SET_PRINT_STATS_INFO_BASE {rawparams} + +##### internal use ##### +[gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL] +description: Helper: park toolhead used in PAUSE and CANCEL_PRINT +gcode: + ##### get user parameters or use default ##### + {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} + {% set velocity = printer.configfile.settings.pause_resume.recover_velocity %} + {% set use_custom = client.use_custom_pos|default(false)|lower == 'true' %} + {% set custom_park_x = client.custom_park_x|default(0.0) %} + {% set custom_park_y = client.custom_park_y|default(0.0) %} + {% set park_dz = client.custom_park_dz|default(2.0)|abs %} + {% set sp_hop = client.speed_hop|default(15) * 60 %} + {% set sp_move = client.speed_move|default(velocity) * 60 %} + ##### get config and toolhead values ##### + {% set origin = printer.gcode_move.homing_origin %} + {% set act = printer.gcode_move.gcode_position %} + {% set max = printer.toolhead.axis_maximum %} + {% set cone = printer.toolhead.cone_start_z|default(max.z) %} ; height as long the toolhead can reach max and min of an delta + {% set round_bed = True if printer.configfile.settings.printer.kinematics is in ['delta','polar','rotary_delta','winch'] + else False %} + ##### define park position ##### + {% set z_min = params.Z_MIN|default(0)|float %} + {% set z_park = [[(act.z + park_dz), z_min]|max, (max.z - origin.z)]|min %} + {% set x_park = params.X if params.X is defined + else custom_park_x if use_custom + else 0.0 if round_bed + else (max.x - 5.0) %} + {% set y_park = params.Y if params.Y is defined + else custom_park_y if use_custom + else (max.y - 5.0) if round_bed and z_park < cone + else 0.0 if round_bed + else (max.y - 5.0) %} + ##### end of definitions ##### + _CLIENT_RETRACT + {% if "xyz" in printer.toolhead.homed_axes %} + G90 + G1 Z{z_park} F{sp_hop} + G1 X{x_park} F{sp_move} + G1 X{x_park} Y{y_park} F{sp_move} + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} + {% else %} + RESPOND TYPE=echo MSG='Printer not homed' + {% endif %} + +[gcode_macro _CLIENT_EXTRUDE] +description: Extrudes, if the extruder is hot enough +gcode: + ##### get user parameters or use default ##### + {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} + {% set use_fw_retract = (client.use_fw_retract|default(false)|lower == 'true') and (printer.firmware_retraction is defined) %} + {% set length = params.LENGTH|default(client.unretract)|default(1.0)|float %} + {% set speed = params.SPEED|default(client.speed_unretract)|default(35) %} + {% set absolute_extrude = printer.gcode_move.absolute_extrude %} + ##### end of definitions ##### + {% if printer.toolhead.extruder != '' %} + {% if printer[printer.toolhead.extruder].can_extrude %} + {% if use_fw_retract %} + {% if length < 0 %} + G10 + {% else %} + G11 + {% endif %} + {% else %} + M83 + G1 E{length} F{(speed|float|abs) * 60} + {% if absolute_extrude %} + M82 + {% endif %} + {% endif %} + {% else %} + RESPOND TYPE=echo MSG='{"\"%s\" not hot enough" % printer.toolhead.extruder}' + {% endif %} + {% endif %} + +[gcode_macro _CLIENT_RETRACT] +description: Retracts, if the extruder is hot enough +gcode: + {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} + {% set length = params.LENGTH|default(client.retract)|default(1.0)|float %} + {% set speed = params.SPEED|default(client.speed_retract)|default(35) %} + + _CLIENT_EXTRUDE LENGTH=-{length|float|abs} SPEED={speed|float|abs} + +[gcode_macro _CLIENT_LINEAR_MOVE] +description: Linear move with save and restore of the gcode state +gcode: + {% set x_move = "X" ~ params.X if params.X is defined else "" %} + {% set y_move = "Y" ~ params.Y if params.Y is defined else "" %} + {% set z_move = "Z" ~ params.Z if params.Z is defined else "" %} + {% set e_move = "E" ~ params.E if params.E is defined else "" %} + {% set rate = "F" ~ params.F if params.F is defined else "" %} + {% set ABSOLUTE = params.ABSOLUTE | default(0) | int != 0 %} + {% set ABSOLUTE_E = params.ABSOLUTE_E | default(0) | int != 0 %} + SAVE_GCODE_STATE NAME=_client_movement + {% if x_move or y_move or z_move %} + G9{ 0 if ABSOLUTE else 1 } + {% endif %} + {% if e_move %} + M8{ 2 if ABSOLUTE_E else 3 } + {% endif %} + G1 { x_move } { y_move } { z_move } { e_move } { rate } + RESTORE_GCODE_STATE NAME=_client_movement diff --git a/meta-opencentauri/recipes-apps/klipper/files/machine.cfg b/meta-opencentauri/recipes-apps/klipper/files/machine.cfg index a9c5e7fd..d951c7ab 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/machine.cfg +++ b/meta-opencentauri/recipes-apps/klipper/files/machine.cfg @@ -17,6 +17,31 @@ is_non_critical: true serial: /dev/serial/by-path/platform-4101400.usb-usb-0:1:1.0 restart_method: command + +[printer] +kinematics: limited_corexy +max_x_accel:10000 +max_y_accel:5000 +max_velocity: 500 +max_accel: 20000 +max_z_velocity: 20 +max_z_accel: 500 + + +[gcode_arcs] +resolution: 0.5 + +[pause_resume] + +[exclude_object] + +[idle_timeout] +gcode: _IDLE_TIMEOUT +timeout: 1800 + +[virtual_sdcard] +path: /etc/klipper/gcodes + [danger_options] multi_mcu_trsync_timeout: 0.03 @@ -27,13 +52,25 @@ enable_pin: !PE10 endstop_pin: tmc2209_stepper_x:virtual_endstop microsteps: 16 full_steps_per_rotation: 200 -position_endstop: 256.5 -position_max: 256.5 -position_min: -2.01 +position_endstop: 256 +position_max: 256 +position_min: -2 homing_speed: 80 -homing_retract_dist: 0 +homing_retract_dist: 20 rotation_distance: 39.872 +[tmc2209 stepper_x] +tx_pin: PE9 +uart_pin: PE6 +uart_address: 0 +interpolate: true +run_current: 1 +home_current: 0.8 +sense_resistor: 0.1 +driver_sgthrs: 130 +diag_pin: !PG4 + + [stepper_y] step_pin: PE14 dir_pin: !PE13 @@ -41,28 +78,52 @@ enable_pin: !PE15 endstop_pin: tmc2209_stepper_y:virtual_endstop microsteps: 16 full_steps_per_rotation: 200 -position_endstop: -2.5 -position_max: 270.000000 -position_min: -2.5 +position_endstop: -2 +position_max: 265 +position_min: -2 homing_speed: 80 -homing_retract_dist: 0 +homing_retract_dist: 30 rotation_distance: 39.872 +[tmc2209 stepper_y] +tx_pin: PE9 +uart_pin: PE6 +interpolate: 1 +run_current: 1.0 +home_current: 0.8 +uart_address: 3 +sense_resistor: 0.1 +driver_sgthrs: 130 +diag_pin: !PF6 + + [stepper_z] step_pin: PG3 dir_pin: !PG2 enable_pin: !PG1 endstop_pin: PG8 +rotation_distance: 8 microsteps: 16 full_steps_per_rotation: 200 -position_endstop: 4.5 -position_max: 258.000000 -position_min: -5 -homing_speed: 8.000000 +position_endstop: 4 +position_max: 258 +position_min: -4 +homing_speed: 8 homing_retract_dist: 10 homing_retract_speed: 6 -second_homing_speed: 3.000000 -rotation_distance: 8 +second_homing_speed: 3 + + +[tmc2209 stepper_z] +tx_pin: PE9 +uart_pin: PE6 +interpolate: true +run_current: 0.8 +uart_address: 1 +sense_resistor: 0.1 +driver_sgthrs: 130 +stealthchop_threshold: 99999 + [extruder] step_pin: hotend:PC13 @@ -73,132 +134,96 @@ sensor_pin: hotend:PA3 microsteps: 16 full_steps_per_rotation: 200 gear_ratio: 52:10 -rotation_distance: 28.8 -nozzle_diameter: 0.400000 -filament_diameter: 1.750000 +rotation_distance: 27.3 #could be 27.3 needs more testing +nozzle_diameter: 0.4 +filament_diameter: 1.75 sensor_type: hotend_termistor -min_temp: -200 +min_temp: 5 max_temp: 335 -min_extrude_temp: 170 +min_extrude_temp: 180 pressure_advance: 0.04 pressure_advance_smooth_time: 0.04 -max_extrude_only_velocity: 60 -max_extrude_only_accel: 5000 -max_extrude_only_distance: 120 -control: pid -pid_Kp: 24.860427 -pid_Ki: 2.702253 -pid_Kd: 57.178292 - -[tmc2209 stepper_x] -tx_pin: PE9 -uart_pin: PE6 -uart_address: 0 -interpolate: 1 -run_current: 1.0 -home_current: 0.8 -sense_resistor: 0.1 -driver_sgthrs: 120 -stealthchop_threshold: 0 -diag_pin: !PG4 - -[tmc2209 stepper_y] -tx_pin: PE9 -uart_pin: PE6 -interpolate: 1 -run_current: 1.0 -home_current: 0.8 -uart_address: 3 -sense_resistor: 0.1 -driver_sgthrs: 120 -stealthchop_threshold: 0 -diag_pin: !PF6 - -[tmc2209 stepper_z] -tx_pin: PE9 -uart_pin: PE6 -interpolate: 1 -run_current: 0.8 -uart_address: 1 -sense_resistor: 0.1 -driver_sgthrs: 120 -stealthchop_threshold: 99999 +max_extrude_only_distance: 150 +max_extrude_cross_section: 5 [tmc2209 extruder] tx_pin: hotend:PC6 uart_pin: hotend:PC7 -interpolate: 1 -run_current: 0.8 -hold_current: 0.5 +interpolate: true +run_current: 0.7 uart_address: 3 sense_resistor: 0.1 -driver_sgthrs: 10 -stealthchop_threshold: 0 -[led case] -white_pin: PG15 -initial_WHITE: 1 +[verify_heater extruder] -[led hotend] -white_pin: hotend:PC9 +[thermistor hotend_termistor] +temperature1: 25 +resistance1: 100000 +beta: 4300 -[heater_bed] -heater_pin: PG13 -sensor_pin: PB14 -sensor_type: Generic 3950 -min_temp: -200 -max_temp: 125 -control: pid -pid_Kp: 46.504839 -pid_Ki: 1.453276 -pid_Kd: 372.038710 +[heater_fan extruder] +pin: hotend:PC8 +tachometer_pin: hotend:PA1 +tachometer_poll_interval: 0.001 -[verify_heater heater_bed] -max_error: 120 -check_gain_time: 120 -hysteresis: 5 -heating_gain: 2 +[fan] +pin: hotend:PB5 +tachometer_pin: hotend:PA0 -[verify_heater extruder] -max_error: 120 -check_gain_time: 20 -hysteresis: 5 -heating_gain: 2 -[temperature_sensor box] -sensor_pin: PB13 -sensor_type: Generic 3950 -min_temp: -200 -max_temp: 125 +[lis2dw] +spi_speed: 5000000 +cs_pin: hotend:PA4 +spi_bus: spi1 +axes_map: x,z,-y -[fan_generic model_helper_fan] -pin: PG17 +[input_shaper] +damping_ratio_x: 0.06 +damping_ratio_y: 0.082 -[fan_generic box_fan] -pin: PG18 +[resonance_tester] +probe_points: 128,128,20 +accel_chip: lis2dw +min_freq: 10 +max_freq: 100 +accel_per_hz: 100 +hz_per_sec: 2 -[temperature_fan mainboard] -pin: PG16 -tachometer_pin: PG6 + +[heater_bed] +heater_pin: PG13 +sensor_pin: PB14 +sensor_type: Generic 3950 min_temp: 5 -max_temp: 85 -target_temp: 65 -min_speed: 0 -sensor_type: temperature_host -control: pid -pid_Kp: 2 -pid_Ki: 5 -pid_Kd: 0.5 +max_temp: 125 + +[verify_heater heater_bed] [bed_mesh] -speed: 150.0 -horizontal_move_z: 2.0 -mesh_min: 20,20 +speed: 150 +horizontal_move_z: 2 +mesh_min: 10,10 mesh_max: 246,246 -probe_count: 11,11 +probe_count: 9,9 mesh_pps: 3,3 algorithm: bicubic -adaptive_margin: 5.0 +adaptive_margin: 3 +zero_reference_position: 128, 128 + +[load_cell_probe] +sensor_type: load_cell_fusion +sensors: hx71x sg0, hx71x sg1, hx71x sg2, hx71x sg3 +samples: 2 +samples_tolerance_retries: 3 +speed: 2 +sample_retract_dist: 1 +lift_speed: 5 +counts_per_gram: 29.11 +reference_tare_counts: 71000 +z_offset: -0.15 +samples_result: median +trigger_force: 50 +drop_first_result: true [hx71x sg0] chip: hx711 @@ -228,77 +253,40 @@ sclk_pin: bed:PC9 sample_rate: 80 gain: A-128 -[load_cell_probe] -sensor_type: load_cell_fusion -sensors: hx71x sg0, hx71x sg1, hx71x sg2, hx71x sg3 -samples: 2 -samples_tolerance_retries: 2 -speed: 2.0 -sample_retract_dist: 1.0 -lift_speed: 5.0 -counts_per_gram: 29.11 -reference_tare_counts: 71000 -z_offset: -0.15 -trigger_force: 50 - -[printer] -kinematics: corexy -max_velocity: 500.000000 -max_accel: 20000.000000 -max_z_velocity: 20.000000 -max_z_accel: 500.000000 -square_corner_velocity: 9.000000 - -[gcode_arcs] -resolution: 0.5 - -[pause_resume] -[exclude_object] +[filament_switch_sensor filament_sensor] +switch_pin: PC0 +pause_on_runout: false +debounce_delay: 1 +runout_distance: 800 +runout_gcode: + RESPOND TYPE=echo MSG="Refill filament" + PAUSE STATE=runout +immediate_runout_gcode: + RESPOND TYPE=echo MSG="Ran out of filament" +insert_gcode: + RESPOND TYPE=echo MSG="Filament is inserted" -[input_shaper] -damping_ratio_x: 0.06 -damping_ratio_y: 0.082 -[resonance_tester] -probe_points: 128,128,5 -accel_chip: lis2dw -min_freq: 5.000000 -max_freq: 75.000000 -accel_per_hz: 100.000000 -hz_per_sec: 1.000000 +[led case] +white_pin: PG15 +initial_WHITE: 1 -[screws_tilt_adjust] -screw1: 28.5, 28.5 -screw1_name: front left screw -screw2: 228.5, 28.5 -screw2_name: front right screw -screw3: 228.5, 228.5 -screw3_name: rear right screw -screw4: 28.5, 228.5 -screw4_name: rear left screw -horizontal_move_z: 5 -speed: 350 -screw_thread: CW-M3 +# [led hotend] +# white_pin: hotend:PC9 -[thermistor hotend_termistor] -temperature1: 25 -resistance1: 100000 -beta: 4300 +[temperature_sensor chamber] +sensor_pin: PB13 +sensor_type: Generic 3950 +min_temp: 5 +max_temp: 125 -[lis2dw] -spi_speed: 5000000 -cs_pin: hotend:PA4 -spi_bus: spi1 -axes_map: x,z,-y +[fan_generic aux_fan] +pin: PG17 -[heater_fan extruder] -pin: hotend:PC8 -tachometer_pin: hotend:PA1 +[fan_generic case_fan] +pin: PG18 -[fan] -pin: hotend:PB5 -tachometer_pin: hotend:PA0 [temperature_sensor mcu_toolhead] sensor_type: temperature_mcu @@ -307,3 +295,30 @@ sensor_mcu: hotend [temperature_sensor mcu_bed] sensor_type: temperature_mcu sensor_mcu: bed + +[temperature_fan mainboard] +pin: PG16 +tachometer_pin: PG6 +min_temp: 5 +max_temp: 85 +target_temp: 60 +min_speed: 0 +sensor_type: temperature_host +control: pid +pid_Kp: 2 +pid_Ki: 5 +pid_Kd: 0.5 + + +[screws_tilt_adjust] +screw1: 231, 25 +screw1_name: front right screw +screw2: 231, 225 +screw2_name: rear right screw +screw3: 31, 225 +screw3_name: rear left screw +screw4: 31, 25 +screw4_name: front left screw +horizontal_move_z: 5 +speed: 300 +screw_thread: CCW-M3 \ No newline at end of file diff --git a/meta-opencentauri/recipes-apps/klipper/files/macros.cfg b/meta-opencentauri/recipes-apps/klipper/files/macros.cfg index 856ddb90..19587e5f 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/macros.cfg +++ b/meta-opencentauri/recipes-apps/klipper/files/macros.cfg @@ -3,105 +3,416 @@ # EDITING THIS FILE WILL EXCLUDE YOUR CHANGES FROM FUTURE UPDATES. # ----- -[gcode_macro _GLOBAL_VARS] -variable_extruder_target: 230 + + +[gcode_macro _global_var] +variable_pause_park:{'x': 10, 'y': 240, 'z': 10, 'e': 2} +variable_cancel_park:{'x': 240, 'y': 240, 'z': 10, 'e': 5} +variable_extruder_temp:{'probing': 140, 'cleaning': 180, 'loading': 230, 'purging': 250} +variable_z_maximum_lifting_distance: 250 +variable_pause_resume_travel_speed: 150 +variable_heatsoak: 1 +variable_adaptive_mesh: True +variable_adaptive_purge: True +gcode: + +[gcode_macro ALL_FANS_OFF] gcode: + M107 + SET_FAN_SPEED FAN=aux_fan SPEED=0 + SET_FAN_SPEED FAN=case_fan SPEED=0 + SET_DISPLAY_TEXT MSG="ALL FANS OFF!" + +[gcode_macro _IDLE_TIMEOUT] +gcode: + {% if printer.print_stats.state == "paused" %} + SET_DISPLAY_TEXT MSG="PAUSED" + {% else %} + M84 + TURN_OFF_HEATERS + ALL_FANS_OFF + SET_DISPLAY_TEXT MSG="No operations in 30mins!" + {% endif %} + +[gcode_macro M600] +gcode: + PAUSE STATE=filament_change [gcode_macro PRINT_START] gcode: - SET_GCODE_VARIABLE MACRO=_GLOBAL_VARS VARIABLE=extruder_target VALUE={params.EXTRUDER_TEMP} + {% set target_bed = params.BED|int %} + {% set target_extruder = params.EXTRUDER|int %} + {% set target_chamber = params.CHAMBER|int %} + {% set sensor = printer['filament_switch_sensor filament_sensor'] %} + {% set svar = printer['gcode_macro _global_var'] %} + ALL_FANS_OFF + BED_MESH_CLEAR + CLEAR_PAUSE + G90 + SET_DISPLAY_TEXT MSG="Bed: {target_bed}c" + M140 S{target_bed} + G28 + {% if sensor.enabled and not sensor.filament_detected %} + SET_DISPLAY_TEXT MSG="NO FILAMENT LOADED!" + CANCEL_PRINT + RETURN + {% endif %} + CLEAN_NOZZLE + + {% if target_chamber > 0 %} + SET_DISPLAY_TEXT MSG="Chamber: {target_chamber}c" + M106 S255 + G0 X128 Y128 Z10 F9000 + TEMPERATURE_WAIT SENSOR="temperature_sensor chamber" MINIMUM={target_chamber} + M107 + {% endif %} + M190 S{target_bed} + + # rehome after thermal expansion + SET_DISPLAY_TEXT MSG="Heatsoak: {svar.heatsoak}m" + G4 P{svar.heatsoak*1000*60} + LOADCELL_Z_HOME + {% if svar.adaptive_mesh %} + M109 S{svar.extruder_temp.probing} + SET_DISPLAY_TEXT MSG="Bed mesh adaptive" + BED_MESH_CALIBRATE ADAPTIVE=1 + {% else %} + {% if "default" in printer.bed_mesh.profiles %} + SET_DISPLAY_TEXT MSG="Bed mesh default" + BED_MESH_PROFILE LOAD=default + {% else %} + SET_DISPLAY_TEXT MSG="NO BED MESH!" + CANCEL_PRINT + RETURN + {% endif %} + {% endif %} -# Home Z with Strain Gauge, ends up with the nozzle 2mm above bed -[gcode_macro STRAINGAUGE_Z_HOME] + {% if svar.adaptive_purge %} + SMART_PARK + {% endif %} + + SET_DISPLAY_TEXT MSG="Hotend: {target_extruder}c" + M109 S{target_extruder} + {% if svar.adaptive_purge %} + LINE_PURGE + {% endif %} + SET_DISPLAY_TEXT MSG="Printer goes brr" + G90 + +[gcode_macro PRINT_END] gcode: - SAVE_GCODE_STATE NAME=straingauge_z_home_state + {% set svar = printer['gcode_macro _global_var'] %} + {% set z_max = svar.z_maximum_lifting_distance|int %} + {% set e_mintemp = printer.configfile.settings['extruder'].min_extrude_temp %} + {% set sensor = printer['filament_switch_sensor filament_sensor'] %} + + {% if printer.toolhead.homed_axes|lower == "xyz" %} + G91 + {% if sensor.enabled and sensor.filament_detected %} + {% if (printer.extruder.target != 0 and printer.extruder.temperature >= printer.extruder.target and printer.extruder.temperature >= e_mintemp) %} + G1 E-5 F2700 + G1 E-2 Z0.2 F2400 + {% endif %} + {% endif %} - # TODO: Clear bed mesh + {% if (printer.gcode_move.position.z + 10) < z_max %} + G1 Z+10 F3000 + {% else %} + G1 Z+{(z_max - printer.gcode_move.position.z)} F3000 + {% endif %} + G90 + G1 X240 Y240 F9000 + {% endif %} + ALL_FANS_OFF + TURN_OFF_HEATERS + M220 S100 + M221 S100 + CLEAR_PAUSE + M84 + SET_DISPLAY_TEXT MSG="Finish Print!" + + +[gcode_macro CANCEL_PRINT] +description: +rename_existing: CANCEL_PRINT_BASE +gcode: + {% set svar = printer['gcode_macro _global_var'] %} + {% set x_park = svar.cancel_park.x %} + {% set y_park = svar.cancel_park.y %} + {% set z_park = svar.cancel_park.z %} + {% set z_lift_max = svar.z_maximum_lifting_distance %} + {% set e_restract = svar.cancel_park.e %} + {% set e_mintemp = printer.configfile.settings['extruder'].min_extrude_temp %} + {% set sensor = printer['filament_switch_sensor filament_sensor'] %} + + CANCEL_PRINT_BASE + {% if printer.toolhead.homed_axes|lower == "xyz" %} + G91 + {% if sensor.enabled and sensor.filament_detected %} + {% if (printer.extruder.target != 0 and printer.extruder.temperature >= printer.extruder.target and printer.extruder.temperature >= e_mintemp) %} + G1 E-{e_restract} F2700 + {% else %} + RESPOND TYPE=command MSG="Nozzle not hot enough" + {% endif %} + {% endif %} - # Move down a Z to get some clearance - G91 ; Relative positioning - G1 Z2 F600 ; Move up 2mm + {%if (printer.gcode_move.position.z + 10) < z_lift_max %} + G1 Z+10 F3000 + {% else %} + G1 Z+{(z_lift_max - printer.gcode_move.position.z)} F3000 + {% endif %} + G90 + G1 X{x_park} Y{y_park} F9000 + {% endif %} + ALL_FANS_OFF + TURN_OFF_HEATERS + M220 S100 + M221 S100 + CLEAR_PAUSE + M84 + SET_DISPLAY_TEXT MSG="Cancel Print Success!" + +[gcode_macro PAUSE] +rename_existing: PAUSE_BASE +variable_state: 'normal' +gcode: + {% set svar = printer['gcode_macro _global_var'] %} + {% set state = params.STATE|default('normal') %} + {% set x_park = svar.pause_park.x|float %} + {% set y_park = svar.pause_park.y|float %} + {% set e_retract = svar.pause_park.e|float %} + {% set z_lift_max = svar.z_maximum_lifting_distance|int %} + {% set sensor = printer['filament_switch_sensor filament_sensor'] %} + {% set pos = printer.gcode_move.position %} + + {% if printer.pause_resume.is_paused == False %} + SET_DISPLAY_TEXT MSG="Pausing" + + PAUSE_BASE + G91 + + {% if printer.toolhead.homed_axes|lower == "xyz" %} + {% set zpos = printer.gcode_move.position.z %} + {% if (zpos + 5) < z_lift_max %} + G1 Z+5 F3000 + {% else %} + G1 Z+{(z_lift_max - zpos)} F3000 + {% endif %} + + G90 + + {% if pos.x != x_park or pos.y != y_park %} + G1 X{x_park} Y{y_park} F{svar.pause_resume_travel_speed * 60} + {% endif %} + {% endif %} + + # Keep heater on so resume can prime quickly + M104 S{printer.extruder.target} + + {% if state == 'normal' %} + {% if (printer.extruder.temperature + 5 >= printer.extruder.target) and extruder.can_extrude %} + {% if sensor.enabled and sensor.filament_detected %} + G91 + G1 E-{e_retract} F300 + G90 + {% endif %} + {% endif %} + SET_DISPLAY_TEXT MSG="Paused normal" + + {% elif state == 'filament_change' %} + # Ensure nozzle is up to temp for filament change/unload + {% if printer.extruder.temperature + 5 < printer.extruder.target %} + M109 S{printer.extruder.target} + {% endif %} + UNLOAD_FILAMENT + SET_DISPLAY_TEXT MSG="Paused for filament change" + + {% elif state == 'runout' %} + # Runout pause: keep heater on and prompt user to insert filament + SET_DISPLAY_TEXT MSG="Paused for runout" + PURGE + LOAD_FILAMENT + + {% endif %} + + {% else %} + SET_DISPLAY_TEXT MSG="Printer already paused" + {% endif %} + + + +[delayed_gcode _resume_wait] +gcode: + {% if printer['gcode_macro RESUME'].execute|lower != 'false' %} + RESUME + {% endif %} + +[gcode_macro RESUME] +rename_existing: RESUME_BASE +variable_state: 'normal' +gcode: + {% set svar = printer['gcode_macro _global_var'] %} + {% set e_retract = svar.pause_park.e|float %} + {% set extruder_target_temp = printer.extruder.target|int %} + {% set sensor = printer['filament_switch_sensor filament_sensor'] %} + + # If filament sensor is enabled require filament present before resuming + {% if sensor.enabled and not sensor.filament_detected %} + RESPOND TYPE=command MSG="Please insert filament before resuming." + RETURN + {% endif %} + + # Ensure nozzle heated to target before attempting to prime/extrude + # {% if printer.extruder.temperature + 5 < extruder_target_temp %} + # SET_DISPLAY_TEXT MSG="Heating nozzle to {extruder_target_temp}C" + M109 S{extruder_target_temp} + # {% endif %} + G91 + G1 E{e_retract} F300 G90 + SET_DISPLAY_TEXT MSG="Resuming" + RESUME_BASE - PROBE ; Probe with strain gauge - M400 ; Wait for moves to finish +[gcode_macro PURGE] +gcode: + {% set svar = printer['gcode_macro _global_var'] %} + + {% if "xyz" not in printer.toolhead.homed_axes %} + G28 ; Home if necessary + {% endif %} + # Move to purge position + MOVE_TO_TRAY + M104 S{svar.extruder_temp.purging} ; Heat nozzle to purging temp + TEMPERATURE_WAIT SENSOR=extruder MINIMUM={svar.extruder_temp.purging} + ; Heat nozzle to 250°C and wait + + # Purge filament (8 cycles) + G92 E0 ; Reset extruder position + M106 S0 ; Turn on part cooling fan (full speed) + {% for purge in range(4) %} + G1 E25 F300 ; Extrude 13mm at medium speed + G1 E10 F150 ; Extrude 2mm slowly (ensure flow) + M400 ; Wait for completion + {% endfor %} + M104 S{svar.extruder_temp.loading} + TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={svar.extruder_temp.loading} + {% for purge in range(4) %} + G1 E25 F300 ; Extrude 13mm at medium speed + G1 E10 F150 ; Extrude 2mm slowly (ensure flow) + M400 ; Wait for completion + {% endfor %} + G1 E-2 F1800 ; Retract 2mm to prevent oozing + M104 S0 + M106 S255 + TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={svar.extruder_temp.cleaning} + M107 + G0 X170 + G0 Y250 + G4 P1000 + MOVE_TO_TRAY + G0 X170 + G0 Y250 + +# Home Z with Strain Gauge, ends up with the nozzle 2mm above bed + + + +[gcode_macro LOADCELL_Z_HOME] +gcode: + {% set svar = printer['gcode_macro _global_var'] %} + + M104 S{svar.extruder_temp.probing} + {% if "xyz" not in printer.toolhead.homed_axes %} + G28 ; Home if necessary + {% endif %} + BED_MESH_CLEAR + # Move down a Z to get some clearance + G91 ; Relative positioning + G1 Z5 F600 + G90 + G0 X128 Y128 F9000 ; Move up 2mm + M109 S{svar.extruder_temp.probing} + PROBE ; Probe with strain gauge + M400 ; Wait for moves to finish # Store the end position as new Z=0 SET_KINEMATIC_POSITION Z=0 SET_HOMED=Z ; Set current Z as 0 - # Move up 2mm from the probed position + M104 S0 G91 ; Relative positioning - G1 Z2 F600 ; Move up 2mm - M400 ; Wait for moves to finish + G1 Z5 F600 ; Move up 2mm G90 ; Absolute positioning - - # TODO: Restore bed mesh - - RESTORE_GCODE_STATE NAME=straingauge_z_home_state - # Wipe Nozzle, see auto_leveling.cpp:443 -[gcode_macro M729] +[gcode_macro CLEAN_NOZZLE] gcode: - SAVE_GCODE_STATE NAME=m729_saved_state - + {% set svar = printer['gcode_macro _global_var'] %} + BED_MESH_CLEAR + M104 S{svar.extruder_temp.cleaning} + {% if printer.toolhead.homed_axes != "xyz" %} + G28 + {% endif %} G90 # Move to tray - G1 X202 F6000 - G1 Y264.5 F6000 - + MOVE_TO_TRAY + SET_DISPLAY_TEXT MSG="Cleaning nozzle: {svar.extruder_temp.cleaning}c" + M104 S{svar.extruder_temp.cleaning} + TEMPERATURE_WAIT SENSOR=extruder MINIMUM={svar.extruder_temp.cleaning} + M104 S{svar.extruder_temp.probing} + M106 S255 # Wipe - G1 X173 F8000 - G1 X187 - G1 X173 - G1 X187 - G1 X173 - + G1 F9000 + {% for wipes in range(4) %} + {% for i in range(8) %} + {% set x = 187 - (i * 2) %} + {% set y = 265 if i % 2 == 0 else 263 %} + G1 X{x} Y{y} + {% endfor %} + G1 X187 + {% endfor %} # Move a 2mm on Y - G1 Y262.5 - - # Wipe - G1 X187 F8000 - G1 X173 - G1 X187 - G1 X173 - G1 X187 - G1 X173 - + G1 Y263 + TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={svar.extruder_temp.probing} + M104 S0 + + G1 F9000 + {% for wipes in range(4) %} + {% for i in range(8) %} + {% set x = 187 - (i * 2) %} + {% set y = 263 if i % 2 == 0 else 265 %} + G1 X{x} Y{y} + {% endfor %} + G1 X187 + {% endfor %} # Add some clearance G1 Y250 - # Move back to tray - G1 X202 - G1 Y264.5 F1200 - # Clear command queue - M400 - RESTORE_GCODE_STATE NAME=m729_saved_state + M107 + M400 [gcode_macro WIPE_NOZZLE] gcode: - {% set bed_temp = params.BED_TEMP|default(60)|float %} + {% set bed_temp = params.BED_TEMP|default(60)|int %} G28 ; Home M204 S5000 ; Set acceleration to 5000 mm/s M400 ; Wait for moves to finish G90 ; Absolute positioning M106 S0 ; Turn off part cooling fan - SET_FAN_SPEED FAN=model_helper_fan SPEED=0 ; Turn off auxiliary fan + SET_FAN_SPEED FAN=aux_fan SPEED=0 ; Turn off auxiliary fan M83 ; Relative extrusion mode # Move to purge position - G1 X202 Y250 F20000 ; Rapid move to purge area - G1 Y264.5 F1200 ; Move to exact purge Y position + MOVE_TO_TRAY M109 S250 ; Heat nozzle to 250°C and wait # Purge filament (8 cycles) G92 E0 ; Reset extruder position M106 S255 ; Turn on part cooling fan (full speed) - SET_FAN_SPEED FAN=model_helper_fan SPEED=1 ; Turn on auxiliary fan (full speed) + SET_FAN_SPEED FAN=aux_fan SPEED=1 ; Turn on auxiliary fan (full speed) G1 E13 F523 ; Extrude 13mm at medium speed G1 E2 F150 ; Extrude 2mm slowly (ensure flow) M400 ; Wait for completion @@ -132,11 +443,11 @@ gcode: M109 S180 ; Cool to 180°C and wait M400 ; Wait for moves M104 S140 ; Start cooling to final temp (140°C) - G4 S4 ; Dwell 4 seconds + G4 P4000 ; Dwell 4 seconds - # Wipe nozzle using M729 pattern + # Wipe nozzle using CLEAN_NOZZLE pattern M204 S15000 ; Set high acceleration for wipe - M729 ; Execute wipe pattern (moves across wiper) + CLEAN_NOZZLE ; Execute wipe pattern (moves across wiper) M204 S5000 ; Restore normal acceleration # --- ADDITIONAL NOZZLE CLEANING --- @@ -191,43 +502,13 @@ gcode: M109 S140 ; Heat nozzle to 140°C and wait M400 ; Wait for stability M106 S0 ; Turn off part cooling fan - SET_FAN_SPEED FAN=model_helper_fan SPEED=0 ; Turn off auxiliary fan + SET_FAN_SPEED FAN=aux_fan SPEED=0 ; Turn off auxiliary fan # Final positioning before probe calibration G91 ; Relative positioning G1 Z2 F600 ; Lift Z by 2mm G90 ; Absolute positioning -# Bed Mesh Calibration Macro with temperature and wipe -[gcode_macro BED_MESH_CALIBRATE_WITH_WIPE] -gcode: - {% set bed_temp = params.BED_TEMP|default(60)|float %} - - M104 S140 ; Set nozzle temp to 140°C - M140 S{bed_temp} ; Set bed temp - M106 S0 ; Turn off part cooling fan - SET_FAN_SPEED FAN=model_helper_fan SPEED=0 ; Turn off auxiliary fan - SET_FAN_SPEED FAN=box_fan SPEED=0 ; Turn off box fan - - WIPE_NOZZLE BED_TEMP={bed_temp} ; Clean nozzle before probing - - M140 S{bed_temp} ; Set bed temp - M104 S140 ; Set nozzle temp to 140°C - - SET_GCODE_OFFSET Z=0 MOVE=0 ; Reset Z offset - - G28 Z0 ; Home Z only using photoelectric sensor - - M109 S140 ; Ensure nozzle at 140°C - M190 S{bed_temp} ; Ensure bed temp - - BED_MESH_CALIBRATE ; Start bed mesh calibration - - MOVE_TO_TRAY ; Move to tray after calibration - M106 S0 ; Turn off part cooling fan - SET_FAN_SPEED FAN=model_helper_fan SPEED=0 ; Turn off auxiliary fan - M104 S0 ; Turn off nozzle heater - M140 S0 ; Turn off bed heater # Move the toolhead to the tray [gcode_macro MOVE_TO_TRAY] @@ -237,8 +518,9 @@ gcode: {% endif %} G90 ; Absolute positioning - G0 X202 Y250 F12000 ; Move near to the try - G0 Y264.5 F1200 ; Move slowly back to the tray + G0 X202 F12000 + G0 Y250 F12000 ; Move near to the try + G0 Y265 F1200 ; Move slowly back to the tray M400 ; Wait for movements to complete @@ -247,8 +529,8 @@ gcode: _CLOSE_PROMPT ; Close any existing prompt M83 ; Relative extrusion mode G92 E0 ; Reset extruder position - G1 E120 F240 ; Move filament into the extruder (120mm at 4mm/s) - M729 ; Wipe nozzle after loading + G1 E60 F420 ; Move filament into the extruder (120mm at 4mm/s) + #CLEAN_NOZZLE ; Wipe nozzle after loading RESPOND TYPE=command MSG="action:prompt_begin Loading Filament" RESPOND TYPE=command MSG="action:prompt_text Load completed. Do you want to purge more?" @@ -258,152 +540,111 @@ gcode: [gcode_macro _LOAD_FILAMENT_STEP_DONE] gcode: - M729 ; Wipe nozzle after loading - M104 S0 ; Turn off nozzle heater - M106 S0 ; Turn off part cooling fan _CLOSE_PROMPT ; Close the loading prompt + CLEAN_NOZZLE ; Wipe nozzle after loading + M104 S0 ; Turn off nozzle heater + #M106 S0 ; Turn off part cooling fan + [gcode_macro LOAD_FILAMENT] gcode: - {% set extruder_temp = params.EXTRUDER_TEMP|default(250)|float %} + _CLOSE_PROMPT + {% set extruder_temp = params.EXTRUDER_TEMP|default(250) %} + + {% if "xyz" not in printer.toolhead.homed_axes %} + G28 ; Home if necessary + {% endif %} M104 S{extruder_temp} ; Start heating the nozzle MOVE_TO_TRAY ; Move to the tray + RESPOND TYPE=command MSG="action:prompt_begin Load Filament" + RESPOND TYPE=command MSG="action:prompt_text Insert filament all the way into extruder before continuing" + RESPOND TYPE=command MSG="action:prompt_footer_button LOAD|_LOAD_FILAMENT_STEP_PUSH" + RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RETURN" + RESPOND TYPE=command MSG="action:prompt_show" + M109 S{extruder_temp} ; Wait for nozzle to reach temp - M106 S255 ; Turn on part cooling fan (full speed) + M107 ; Turn on part cooling fan (full speed) _LOAD_FILAMENT_STEP_PUSH ; Push filament into extruder and wipe + # Cuts the tip of the filament and ejects it from the extruder -[gcode_macro UNLOAD_FILAMENT] + +[gcode_macro CUT_FILAMENT] gcode: {% if "xyz" not in printer.toolhead.homed_axes %} G28 ; Home if necessary {% endif %} - G90 ; Absolute positioning - G0 Z14.5 F600 ; Ensure we have some Z clearance - G0 Y30 F15000 ; Get some clearance for Y - G0 X255 F8000 ; Move to cutting position - G0 Y3 F1200 ; Cut - G0 Y30 F8000 ; Retract from cutting - M400 ; Wait for movements to complete - - MOVE_TO_TRAY ; Move to the tray - FORCE_MOVE STEPPER=extruder DISTANCE=-30 VELOCITY=4 ; Move the filament out of the extruder - - M400 ; Wait for movements to complete - -[gcode_macro _HOME_X] -gcode: - # Home X - G28 X - M400 - - # Move away - G91 - G1 X-20 F4800 G90 - -[gcode_macro _HOME_Y] -gcode: - # Home Y - G28 Y + G0 Y20 F8000 + G0 X255 F8000 + G0 Y4 F1200 + G0 Y20 F1200 M400 - # Move away - G91 - G1 Y30 F4800 - G90 -[delayed_gcode startup] -initial_duration: 1 +[gcode_macro UNLOAD_FILAMENT] gcode: - {% set settings = printer["gcode_macro _COSMOS_SETTINGS"]|default({}) %} - {% set camera_led_on = settings.camera_led_default_on|default(false)|lower == 'true' %} - - {% if camera_led_on %} - RUN_SHELL_COMMAND CMD=CAMERA_LIGHT_ON - {% endif %} - - BED_MESH_PROFILE LOAD=default + {% if "xyz" not in printer.toolhead.homed_axes %} + G28 ; Home if necessary + {% endif %} + ; Absolute positioning + CUT_FILAMENT ; Wait for movements to complete + + MOVE_TO_TRAY + COLD_EXTRUDE HEATER=extruder ENABLE=1 ; Move to the tray + G1 E-30 F600 + COLD_EXTRUDE HEATER=extruder ENABLE=0 + G0 Y250 + M400 ; Wait for movements to complete +[gcode_macro BED_MESH_CALIBRATE] +rename_existing: BED_MESH_CALIBRATE_BASE +gcode: + {% set svar = printer['gcode_macro _global_var'] %} + {% set bed_temp = params.BED_TEMP|default(60)|float %} + M140 S{bed_temp} + G28 + CLEAN_NOZZLE + M190 S{bed_temp} + M104 S{svar.extruder_temp.probing} + G4 S60000 + LOADCELL_Z_HOME + M109 S{svar.extruder_temp.probing} + ALL_FANS_OFF + BED_MESH_CALIBRATE_BASE [homing_override] -axes: yxz +axes: xyz # This forces the z position to be at 0 when we start homing, so we can move the Z up before homing. +set_position_z: 0 gcode: - {% set bed_mesh = printer.bed_mesh.profile_name %} - {% set home_all = 'X' not in params and 'Y' not in params and 'Z' not in params %} - # On the Centauri Carbon 1, 8mm is the requested minimum Z clearance before XY homing. - {% set safe_z = 8.0 %} - {% set safe_z_feedrate = 1500 %} - {% set RUN_CURRENT_X = printer.configfile.settings['tmc2209 stepper_x'].run_current|float %} - {% set RUN_CURRENT_Y = printer.configfile.settings['tmc2209 stepper_y'].run_current|float %} - {% set HOME_CURRENT_X = printer.configfile.settings['tmc2209 stepper_x'].home_current|float %} - {% set HOME_CURRENT_Y = printer.configfile.settings['tmc2209 stepper_y'].home_current|float %} - BED_MESH_CLEAR - - # Set lower current for homing - SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOME_CURRENT_X} - SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOME_CURRENT_Y} - - # Pause to ensure driver stall flag is clear - G4 P500 - - # Ensure Z clearance before XY homing when Z homing is requested - {% if home_all or 'Z' in params %} - {% if 'z' in printer.toolhead.homed_axes %} - {% if printer.gcode_move.gcode_position.z|float < safe_z %} - G90 - G0 Z{safe_z} F{safe_z_feedrate} + G90 + G0 Z5 F1200 ; 5 up zhop + {% if not rawparams %} + G28 X + G28 Y + G28 X + G0 X128 Y128 F4800 + G28 Z + {% else %} + {% if 'X' in rawparams %} + G28 X + {% endif %} + {% if 'Y' in rawparams %} + G28 Y + {% endif %} + {% if 'Z' in rawparams %} + G28 Z {% endif %} - {% else %} - # When Z is unhomed, normal G0/G1 moves are unavailable, so use a short - # positive force move to create the requested minimum clearance first. - # WARNING: This intentionally assumes the printer is in a state where a - # +8mm Z move is safe and that Z is not already at its positive travel limit - # before continuing with the requested Z homing sequence. - FORCE_MOVE STEPPER=stepper_z DISTANCE={safe_z} VELOCITY={safe_z_feedrate / 60} - {% endif %} - # Wait for the Z clearance move to finish before starting XY homing moves. - M400 - {% endif %} - - # First X home. Note this may crash into the back steppers. - {% if home_all or 'X' in params %} - _HOME_X - {% endif %} - - # First Y Home. - {% if home_all or 'Y' in params %} - _HOME_Y - {% endif %} - - # Second X home (if homing both X and Y) to home x at a known good position for sensorless homing - {% if home_all or ('X' in params and 'Y' in params) %} - _HOME_X {% endif %} - # Second Y home just in case the X home caused a jump in Y - {% if home_all or ('X' in params and 'Y' in params) %} - _HOME_Y + {% if "default" in printer.bed_mesh.profiles %} + BED_MESH_PROFILE LOAD=default {% endif %} - - # Restore running current after homing - SET_TMC_CURRENT STEPPER=stepper_x CURRENT={RUN_CURRENT_X} - SET_TMC_CURRENT STEPPER=stepper_y CURRENT={RUN_CURRENT_Y} - {% if home_all or 'Z' in params %} - G90 # Absolute positioning - G1 X125 Y125 F15000 # Move to center of the bed for Z homing - G28 Z # Home Z - G0 Z10 F1500 # Move down after homing - {% endif %} - {% if bed_mesh != "" %} - BED_MESH_PROFILE LOAD="{bed_mesh}" - {% endif %} - [gcode_macro _SHOW_PROMPT] gcode: {% set title = params.TITLE|default('Please wait') %} @@ -432,19 +673,41 @@ gcode: SET_DISPLAY_TEXT_BASE MSG="{message}" -[gcode_macro _CLIENT_VARIABLE] -variable_use_custom_pos: True -variable_custom_park_x: 202 -variable_custom_park_y: 264.5 +[gcode_macro SCREWS_TILT_CALCULATE] +rename_existing: SCREWS_TILT_CALCULATE_BASE gcode: + {% set svar = printer['gcode_macro _global_var'] %} + {% set bed_temp = params.BED_TEMP|default(60)|int %} -[gcode_macro Bed_Level_Screws_Tune] -gcode: - {% set bed_temp = params.BED_TEMP|default(60)|float %} + {% if "xyz" not in printer.toolhead.homed_axes %} + G28 ; Home if necessary + {% endif %} + BED_MESH_CLEAR - M104 S140 + M190 S{bed_temp} + M109 S{svar.extruder_temp.probing} M400 G28 - M109 S140 - M729 - SCREWS_TILT_CALCULATE \ No newline at end of file + CLEAN_NOZZLE + SCREWS_TILT_CALCULATE_BASE +[gcode_macro TEST] +gcode: + {% set svar = printer['gcode_macro _global_var'] %} + + {% if svar.adaptive_purge %} + SET_DISPLAY_TEXT MSG="purgeLINE_PURGE" + {% endif %} + + {% if svar.adaptive_mesh %} + SET_DISPLAY_TEXT MSG="meshSMART_PARK" + {% endif %} + +[gcode_macro M729] +gcode: + SET_DISPLAY_TEXT MSG="USE COSMOS GCODE!" + M112 + +[gcode_macro M8213] +gcode: + SET_DISPLAY_TEXT MSG="USE COSMOS GCODE!" + M112 \ No newline at end of file diff --git a/meta-opencentauri/recipes-apps/klipper/kalico_2026.02.00.bb b/meta-opencentauri/recipes-apps/klipper/kalico_2026.02.00.bb index 895dc27c..a6e4d54e 100644 --- a/meta-opencentauri/recipes-apps/klipper/kalico_2026.02.00.bb +++ b/meta-opencentauri/recipes-apps/klipper/kalico_2026.02.00.bb @@ -13,6 +13,7 @@ SRC_URI += " \ file://shell.cfg \ file://screen.cfg \ file://calibration.cfg \ + file://client.cfg \ " inherit python3-dir update-rc.d @@ -96,7 +97,7 @@ do_install() { # Copy non-printer .cfg files to readonly folder install -d ${D}${sysconfdir}/klipper/config/klipper-readonly - install -m 0644 ${WORKDIR}/machine.cfg ${WORKDIR}/shell.cfg ${WORKDIR}/macros.cfg ${WORKDIR}/calibration.cfg ${WORKDIR}/screen.cfg ${D}${sysconfdir}/klipper/config/klipper-readonly + install -m 0644 ${WORKDIR}/machine.cfg ${WORKDIR}/shell.cfg ${WORKDIR}/macros.cfg ${WORKDIR}/calibration.cfg ${WORKDIR}/screen.cfg ${WORKDIR}/client.cfg ${D}${sysconfdir}/klipper/config/klipper-readonly # Install SysVinit script install -d ${D}${sysconfdir}/init.d @@ -116,4 +117,5 @@ CONFFILES:${PN} = " \ ${sysconfdir}/klipper/config/klipper-readonly/shell.cfg \ ${sysconfdir}/klipper/config/klipper-readonly/screen.cfg \ ${sysconfdir}/klipper/config/klipper-readonly/calibration.cfg \ + ${sysconfdir}/klipper/config/klipper-readonly/client.cfg \ " From b70cb99542a39db19fdab39ec86e918e70828008 Mon Sep 17 00:00:00 2001 From: Atomique13 Date: Thu, 21 May 2026 05:26:39 -0400 Subject: [PATCH 2/5] Update Klipper configuration files and add KAMP settings - Renamed client.cfg to kamp.cfg in the recipe to reflect new configuration. - Updated installation script to copy kamp.cfg to the readonly configuration directory. - Modified configuration files to include KAMP (Klipper Adaptive Meshing Purging) settings. - Added new kamp.cfg file containing macros for KAMP settings, LINE_PURGE, ELEGOO_PURGE, and SMART_PARK. - Implemented logic for adaptive purging based on object dimensions and printer settings. --- .../grumyscreen/files/grumpyscreen.cfg | 18 +- .../recipes-apps/klipper/files/kamp.cfg | 351 ++++++++++++++++ .../recipes-apps/klipper/files/klipper-init-d | 2 +- .../recipes-apps/klipper/files/machine.cfg | 59 ++- .../recipes-apps/klipper/files/macros.cfg | 393 ++++++------------ .../recipes-apps/klipper/kalico_2026.02.00.bb | 6 +- 6 files changed, 540 insertions(+), 289 deletions(-) create mode 100644 meta-opencentauri/recipes-apps/klipper/files/kamp.cfg diff --git a/meta-opencentauri/recipes-apps/grumyscreen/files/grumpyscreen.cfg b/meta-opencentauri/recipes-apps/grumyscreen/files/grumpyscreen.cfg index 6924b0f2..beaecd40 100644 --- a/meta-opencentauri/recipes-apps/grumyscreen/files/grumpyscreen.cfg +++ b/meta-opencentauri/recipes-apps/grumyscreen/files/grumpyscreen.cfg @@ -28,20 +28,20 @@ switch_to_stock_cmd: /usr/bin/switch-to-oc-patched support_zip_cmd: [fan "fan"] -display_name: Toolhead +display_name: Part_Cooling -[fan "fan_generic model_helper_fan"] -display_name: Model Helper +[fan "fan_generic aux_fan"] +display_name: Aux_Cooling -[fan "fan_generic box_fan"] -display_name: Chamber +[fan "fan_generic case_fan"] +display_name: Case_Exhaust [led "led hotend"] -display_name: Toolhead +display_name: Led_Hotend pwm: true [led "led case"] -display_name: Case +display_name: Led_Case pwm: true [monitored_sensor "extruder"] @@ -54,7 +54,7 @@ display_name: Bed color: purple controllable: true -[monitored_sensor "temperature_sensor box"] +[monitored_sensor "temperature_sensor chamber"] display_name: Chamber color: blue -controllable: true +controllable: false diff --git a/meta-opencentauri/recipes-apps/klipper/files/kamp.cfg b/meta-opencentauri/recipes-apps/klipper/files/kamp.cfg new file mode 100644 index 00000000..14df7c4e --- /dev/null +++ b/meta-opencentauri/recipes-apps/klipper/files/kamp.cfg @@ -0,0 +1,351 @@ + +# Original code: https://github.com/kyleisah/Klipper-Adaptive-Meshing-Purging + +[gcode_macro _KAMP_Settings] +description: This macro contains all adjustable settings for KAMP + +# The following variables are settings for KAMP as a whole. +variable_verbose_enable: True # Set to True to enable KAMP information output when running. This is useful for debugging. + +# The following variables are for adjusting adaptive purge settings for KAMP. +variable_purge_height: 0.8 # Z position of nozzle during purge, default is 0.8. +variable_tip_distance: 5 # Distance between tip of filament and nozzle before purge. Should be similar to PRINT_END final retract amount. +variable_purge_margin: 10 # Distance the purge will be in front of the print area, default is 10. +variable_purge_amount: 30 # Amount of filament to be purged prior to printing. +variable_flow_rate: 12 # Flow rate of purge in mm3/s. Default is 12. + +# The following variables are for adjusting the Smart Park feature for KAMP, which will park the printhead near the print area at a specified height. +variable_smart_park_height: 5 # Z position for Smart Park, default is 10. + +gcode: # Gcode section left intentionally blank. Do not disturb. + + {action_respond_info(" Running the KAMP_Settings macro does nothing, it is only used for storing KAMP settings. ")} + + +# Original code: https://github.com/kyleisah/Klipper-Adaptive-Meshing-Purging + +[gcode_macro LINE_PURGE] +description: A purge macro that adapts to be near your actual printed objects +gcode: + # Get relevant printer params + {% set travel_speed = (printer.toolhead.max_velocity) * 30 | float %} + {% set cross_section = printer.configfile.settings.extruder.max_extrude_cross_section | float %} + + # Use firmware retraction if it is defined + {% if printer.firmware_retraction is defined %} + {% set RETRACT = G10 | string %} + {% set UNRETRACT = G11 | string %} + {% else %} + {% set RETRACT = 'G1 E-.5 F2100' | string %} + {% set UNRETRACT = 'G1 E.5 F2100' | string %} + {% endif %} + + # Get purge settings from _Kamp_Settings + {% set verbose_enable = printer["gcode_macro _KAMP_Settings"].verbose_enable | abs %} + {% set purge_height = printer["gcode_macro _KAMP_Settings"].purge_height | float %} + {% set tip_distance = printer["gcode_macro _KAMP_Settings"].tip_distance | float %} + {% set purge_margin = printer["gcode_macro _KAMP_Settings"].purge_margin | float %} + {% set purge_amount = printer["gcode_macro _KAMP_Settings"].purge_amount | float %} + {% set flow_rate = printer["gcode_macro _KAMP_Settings"].flow_rate | float %} + + + # Calculate purge origins and centers from objects + {% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %} # Get all object points + {% set purge_x_min = (all_points | map(attribute=0) | min | default(0)) %} # Object x min + {% set purge_x_max = (all_points | map(attribute=0) | max | default(0)) %} # Object x max + {% set purge_y_min = (all_points | map(attribute=1) | min | default(0)) %} # Object y min + {% set purge_y_max = (all_points | map(attribute=1) | max | default(0)) %} # Object y max + + {% set purge_x_center = ([((purge_x_max + purge_x_min) / 2) - (purge_amount / 2), 0] | max) %} # Create center point of purge line relative to print on X axis + {% set purge_y_center = ([((purge_y_max + purge_y_min) / 2) - (purge_amount / 2), 0] | max) %} # Create center point of purge line relative to print on Y axis + + {% set purge_x_origin = ([purge_x_min - purge_margin, 0] | max) %} # Add margin to x min, compare to 0, and choose the larger + {% set purge_y_origin = ([purge_y_min - purge_margin, 0] | max) %} # Add margin to y min, compare to 0, and choose the larger + + # Calculate purge speed + {% set purge_move_speed = (flow_rate / 5.0) * 60 | float %} + + {% if cross_section < 5 %} + + {action_respond_info("[Extruder] max_extrude_cross_section is insufficient for purge, please set it to 5 or greater. Purge skipped.")} + + {% else %} + + {% if verbose_enable == True %} + + {action_respond_info("Moving filament tip {}mms".format( + (tip_distance), + )) } + {% endif %} + + {% if printer.firmware_retraction is defined %} + {action_respond_info("KAMP purge is using firmware retraction.")} + {% else %} + {action_respond_info("KAMP purge is not using firmware retraction, it is recommended to configure it.")} + {% endif %} + + {% if purge_y_origin > 0 %} + + {action_respond_info("KAMP purge starting at {}, {} and purging {}mm of filament, requested flow rate is {}mm3/s.".format( + (purge_x_center), + (purge_y_origin), + (purge_amount), + (flow_rate), + )) } + + {% else %} + + {action_respond_info("KAMP purge starting at {}, {} and purging {}mm of filament, requested flow rate is {}mm3/s.".format( + (purge_x_origin), + (purge_y_center), + (purge_amount), + (flow_rate), + )) } + + {% endif %} + + SAVE_GCODE_STATE NAME=Prepurge_State # Create gcode state + + {% if purge_y_origin > 0 %} # If there's room on Y, purge along X axis in front of print area + + G92 E0 # Reset extruder + G0 F{travel_speed} # Set travel speed + G90 # Absolute positioning + G0 X{purge_x_center} Y{purge_y_origin} # Move to purge position + G0 Z{purge_height} # Move to purge Z height + M83 # Relative extrusion mode + G1 E{tip_distance} F{purge_move_speed} # Move filament tip + G1 X{purge_x_center + purge_amount} E{purge_amount} F{purge_move_speed} # Purge line + {RETRACT} # Retract + G0 X{purge_x_center + purge_amount + 10} F{travel_speed} # Rapid move to break string + G92 E0 # Reset extruder distance + M82 # Absolute extrusion mode + G0 Z{purge_height * 2} F{travel_speed} # Z hop + + {% else %} # If there's room on X, purge along Y axis to the left of print area + + G92 E0 # Reset extruder + G0 F{travel_speed} # Set travel speed + G90 # Absolute positioning + G0 X{purge_x_origin} Y{purge_y_center} # Move to purge position + G0 Z{purge_height} # Move to purge Z height + M83 # Relative extrusion mode + G1 E{tip_distance} F{purge_move_speed} # Move filament tip + G1 Y{purge_y_center + purge_amount} E{purge_amount} F{purge_move_speed} # Purge line + {RETRACT} # Retract + G0 Y{purge_y_center + purge_amount + 10} F{travel_speed} # Rapid move to break string + G92 E0 # Reset extruder distance + M82 # Absolute extrusion mode + G0 Z{purge_height * 2} F{travel_speed} # Z hop + + {% endif %} + + RESTORE_GCODE_STATE NAME=Prepurge_State # Restore gcode state + + {% endif %} + + + +[gcode_macro ELEGOO_PURGE] +description: A purge macro that adapts to be near your actual printed objects +gcode: + # Get relevant printer params + {% set travel_speed = (printer.toolhead.max_velocity) * 60 | float %} + {% set cross_section = printer.configfile.settings.extruder.max_extrude_cross_section | float %} + + # Use firmware retraction if it is defined + {% if printer.firmware_retraction is defined %} + {% set RETRACT = G10 | string %} + {% set UNRETRACT = G11 | string %} + {% else %} + {% set RETRACT = 'G1 E-.5 F2100' | string %} + {% set UNRETRACT = 'G1 E.5 F2100' | string %} + {% endif %} + +# Get purge settings from _Kamp_Settings + {% set verbose_enable = printer["gcode_macro _KAMP_Settings"].verbose_enable | abs %} + {% set purge_height = printer["gcode_macro _KAMP_Settings"].purge_height | float %} + {% set tip_distance = printer["gcode_macro _KAMP_Settings"].tip_distance | float %} + {% set purge_margin = printer["gcode_macro _KAMP_Settings"].purge_margin | float %} + {% set purge_amount = printer["gcode_macro _KAMP_Settings"].purge_amount | float %} + {% set flow_rate = printer["gcode_macro _KAMP_Settings"].flow_rate | float %} + {% set size = 10 | float %} + + # Calculate purge origins and centers from objects + {% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %} # Get all object points + {% set purge_x_min = (all_points | map(attribute=0) | min | default(0)) %} # Object x min + {% set purge_x_max = (all_points | map(attribute=0) | max | default(0)) %} # Object x max + {% set purge_y_min = (all_points | map(attribute=1) | min | default(0)) %} # Object y min + {% set purge_y_max = (all_points | map(attribute=1) | max | default(0)) %} # Object y max + + {% set purge_x_center = ([((purge_x_max + purge_x_min) / 2), 0] | max) %} # Center of print area on X axis + {% set purge_y_center = ([((purge_y_max + purge_y_min) / 2), 0] | max) %} # Center of print area on Y axis + {% set purge_x_base = ([purge_x_center - size/2, 0] | max) %} # Left edge so normalized path is centered on print + + {% set purge_x_origin = ([purge_x_min - purge_margin, 0] | max) %} # Add margin to x min, compare to 0, and choose the larger + {% set purge_y_front_origin = (purge_y_min - purge_margin - size) %} # Front placement (no clamping for availability check) + {% set purge_x_left_origin = (purge_x_min - purge_margin - size) %} # Left placement (no clamping for availability check) + {% set purge_y_side_base = ([purge_y_center - size/2, 0] | max) %} # Vertically center shape when using left side + + {% set has_front_room = (purge_y_front_origin >= 0) %} + {% set has_left_room = (purge_x_left_origin >= 0) %} + + {% if has_front_room %} + {% set purge_mode = 'front' %} + {% set purge_x_plot_base = purge_x_base %} + {% set purge_y_plot_base = purge_y_front_origin %} + {% elif has_left_room %} + {% set purge_mode = 'left' %} + {% set purge_x_plot_base = purge_x_left_origin %} + {% set purge_y_plot_base = purge_y_side_base %} + {% else %} + {% set purge_mode = 'skip' %} + {% set purge_x_plot_base = purge_x_base %} + {% set purge_y_plot_base = ([purge_y_front_origin, 0] | max) %} + {% endif %} + + # Calculate purge speed + {% set purge_move_speed = (flow_rate / 5.0) * 60 | float %} + + {% if cross_section < 5 %} + + {action_respond_info("[Extruder] max_extrude_cross_section is insufficient for purge, please set it to 5 or greater. Purge skipped.")} + + {% else %} + + {% if verbose_enable == True %} + + {action_respond_info("Moving filament tip {}mms".format( + (tip_distance), + )) } + {% endif %} + + {% if printer.firmware_retraction is defined %} + {action_respond_info("KAMP purge is using firmware retraction.")} + {% else %} + {action_respond_info("KAMP purge is not using firmware retraction, it is recommended to configure it.")} + {% endif %} + + {% if purge_mode == 'skip' %} + {action_respond_info("KAMP purge: no full front/left space available, skipping purge to avoid overlap.")} + {% elif purge_mode == 'front' %} + {action_respond_info("KAMP purge: using front placement.")} + {% else %} + {action_respond_info("KAMP purge: using left-side placement.")} + {% endif %} + + {% if purge_mode != 'skip' %} + + SAVE_GCODE_STATE NAME=Prepurge_State # Create gcode state + + G92 E0 # Reset extruder + G0 F{travel_speed} # Set travel speed + G90 # Absolute positioning + G0 X{purge_x_plot_base + size/2} Y{purge_y_plot_base + size/2} # Move to purge position + G0 Z{purge_height} # Move to purge Z height + M83 # Relative extrusion mode + G1 E{tip_distance} F{purge_move_speed} # Move tip of filament to nozzle + + G1 X{purge_x_plot_base + size*0.346} Y{purge_y_plot_base + size*0.042} E{purge_amount*0.019} F{purge_move_speed} + G1 X{purge_x_plot_base + size*0.280} Y{purge_y_plot_base + size*0.005} E{purge_amount*0.025} + G1 X{purge_x_plot_base + size*0.205} Y{purge_y_plot_base + size*0.003} E{purge_amount*0.027} + G1 X{purge_x_plot_base + size*0.136} Y{purge_y_plot_base + size*0.044} E{purge_amount*0.027} + G1 X{purge_x_plot_base + size*0.076} Y{purge_y_plot_base + size*0.127} E{purge_amount*0.028} + G1 X{purge_x_plot_base + size*0.029} Y{purge_y_plot_base + size*0.248} E{purge_amount*0.030} + G1 X{purge_x_plot_base + size*0.002} Y{purge_y_plot_base + size*0.407} E{purge_amount*0.033} + G1 X{purge_x_plot_base + size*0.000} Y{purge_y_plot_base + size*0.512} E{purge_amount*0.021} + G1 X{purge_x_plot_base + size*0.012} Y{purge_y_plot_base + size*0.661} E{purge_amount*0.029} + G1 X{purge_x_plot_base + size*0.039} Y{purge_y_plot_base + size*0.779} E{purge_amount*0.026} + G1 X{purge_x_plot_base + size*0.067} Y{purge_y_plot_base + size*0.841} E{purge_amount*0.016} + G1 X{purge_x_plot_base + size*0.095} Y{purge_y_plot_base + size*0.902} E{purge_amount*0.016} + G1 X{purge_x_plot_base + size*0.146} Y{purge_y_plot_base + size*0.966} E{purge_amount*0.022} + G1 X{purge_x_plot_base + size*0.204} Y{purge_y_plot_base + size*0.998} E{purge_amount*0.022} + G1 X{purge_x_plot_base + size*0.281} Y{purge_y_plot_base + size*0.997} E{purge_amount*0.028} + G1 X{purge_x_plot_base + size*0.342} Y{purge_y_plot_base + size*0.960} E{purge_amount*0.023} + G1 X{purge_x_plot_base + size*0.385} Y{purge_y_plot_base + size*0.905} E{purge_amount*0.019} + G1 X{purge_x_plot_base + size*0.431} Y{purge_y_plot_base + size*0.818} E{purge_amount*0.024} + G1 X{purge_x_plot_base + size*0.456} Y{purge_y_plot_base + size*0.737} E{purge_amount*0.018} + G1 X{purge_x_plot_base + size*0.486} Y{purge_y_plot_base + size*0.590} E{purge_amount*0.030} + G1 X{purge_x_plot_base + size*0.535} Y{purge_y_plot_base + size*0.295} E{purge_amount*0.061} + G1 X{purge_x_plot_base + size*0.573} Y{purge_y_plot_base + size*0.172} E{purge_amount*0.028} + G1 X{purge_x_plot_base + size*0.631} Y{purge_y_plot_base + size*0.070} E{purge_amount*0.030} + G1 X{purge_x_plot_base + size*0.690} Y{purge_y_plot_base + size*0.017} E{purge_amount*0.024} + G1 X{purge_x_plot_base + size*0.752} Y{purge_y_plot_base + size*0.000} E{purge_amount*0.022} + G1 X{purge_x_plot_base + size*0.833} Y{purge_y_plot_base + size*0.019} E{purge_amount*0.029} + G1 X{purge_x_plot_base + size*0.886} Y{purge_y_plot_base + size*0.071} E{purge_amount*0.022} + G1 X{purge_x_plot_base + size*0.934} Y{purge_y_plot_base + size*0.150} E{purge_amount*0.024} + G1 X{purge_x_plot_base + size*0.977} Y{purge_y_plot_base + size*0.273} E{purge_amount*0.028} + G1 X{purge_x_plot_base + size*1.000} Y{purge_y_plot_base + size*0.445} E{purge_amount*0.035} + G1 X{purge_x_plot_base + size*0.997} Y{purge_y_plot_base + size*0.613} E{purge_amount*0.033} + G1 X{purge_x_plot_base + size*0.986} Y{purge_y_plot_base + size*0.689} E{purge_amount*0.016} + G1 X{purge_x_plot_base + size*0.945} Y{purge_y_plot_base + size*0.826} E{purge_amount*0.031} + G1 X{purge_x_plot_base + size*0.888} Y{purge_y_plot_base + size*0.931} E{purge_amount*0.029} + G1 X{purge_x_plot_base + size*0.814} Y{purge_y_plot_base + size*0.991} E{purge_amount*0.029} + G1 X{purge_x_plot_base + size*0.731} Y{purge_y_plot_base + size*1.000} E{purge_amount*0.029} + G1 X{purge_x_plot_base + size*0.651} Y{purge_y_plot_base + size*0.954} E{purge_amount*0.030} + G1 X{purge_x_plot_base + size*0.612} Y{purge_y_plot_base + size*0.902} E{purge_amount*0.017} + + {RETRACT} # Retract + {% if purge_mode == 'left' %} + G0 Y{purge_y_plot_base + size + purge_amount + 10} F{travel_speed} # Rapid move to break string + {% else %} + G0 X{purge_x_plot_base + size + purge_amount + 10} F{travel_speed} # Rapid move to break string + {% endif %} + G92 E0 # Reset extruder distance + M82 # Absolute extrusion mode + G0 Z{purge_height*2} F{travel_speed} # Z hop + + RESTORE_GCODE_STATE NAME=Prepurge_State # Restore gcode state + + {% endif %} + + {% endif %} + + +# Original code: https://github.com/kyleisah/Klipper-Adaptive-Meshing-Purging + + +[gcode_macro SMART_PARK] +description: Parks your printhead near the print area for pre-print hotend heating. +gcode: + + {% set kamp_settings = printer["gcode_macro _KAMP_Settings"] %} # Pull all variables from _KAMP_Settings + {% set z_height = kamp_settings.smart_park_height | float %} # Set Z height variable + {% set purge_margin = kamp_settings.purge_margin | float %} # Set purge margin variable + {% set verbose_enable = kamp_settings.verbose_enable | abs %} # Set verbosity + {% set center_x = printer.toolhead.axis_maximum.x / 2 | float %} # Create center point of x for fallback + {% set center_y = printer.toolhead.axis_maximum.y / 2 | float %} # Create center point of y for fallback + {% set axis_minimum_x = printer.toolhead.axis_minimum.x | float %} + {% set axis_minimum_y = printer.toolhead.axis_minimum.y | float %} + {% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %} # Gather all object points + {% set x_min = all_points | map(attribute=0) | min | default(center_x) %} # Set x_min from smallest object x point + {% set y_min = all_points | map(attribute=1) | min | default(center_y) %} # Set y_min from smallest object y point + {% set travel_speed = (printer.toolhead.max_velocity) * 30 | float %} # Set travel speed from config + + {% if purge_margin > 0 and x_min != center_x and y_min != center_y %} # If objects are detected and purge margin + {% set x_min = [ x_min - purge_margin , x_min ] | min %} # value is greater than 0, move + {% set y_min = [ y_min - purge_margin , y_min ] | min %} # to purge location + margin + {% set x_min = [ x_min , axis_minimum_x ] | max %} + {% set y_min = [ y_min , axis_minimum_y ] | max %} + {% endif %} + + # Verbose park location + {% if verbose_enable == True %} + + { action_respond_info("Smart Park location: {},{}.".format( + (x_min), + (y_min), + )) } + + {% endif %} + + SAVE_GCODE_STATE NAME=Presmartpark_State # Create gcode state + + G90 # Absolute positioning + {% if printer.toolhead.position.z < z_height %} + G0 Z{z_height} # Move Z to park height if current Z position is lower than z_height + {% endif %} + G0 X{x_min} Y{y_min} F{travel_speed} # Move near object area + G0 Z{z_height} # Move Z to park height + + RESTORE_GCODE_STATE NAME=Presmartpark_State # Restore gcode state \ No newline at end of file diff --git a/meta-opencentauri/recipes-apps/klipper/files/klipper-init-d b/meta-opencentauri/recipes-apps/klipper/files/klipper-init-d index 68efd0e4..14bc2a73 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/klipper-init-d +++ b/meta-opencentauri/recipes-apps/klipper/files/klipper-init-d @@ -23,7 +23,7 @@ ensure_klipper_config_version() { if [ -f "$KLIPPER_CONFIG_VERSION_FILE" ]; then current_version="$(tr -d '[:space:]' < "$KLIPPER_CONFIG_VERSION_FILE" 2>/dev/null)" else - current_version="$KLIPPER_CONFIG_VERSION" + current_version="" #reset configs echo "$current_version" > "$KLIPPER_CONFIG_VERSION_FILE" || return 1 fi diff --git a/meta-opencentauri/recipes-apps/klipper/files/machine.cfg b/meta-opencentauri/recipes-apps/klipper/files/machine.cfg index d951c7ab..7d782109 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/machine.cfg +++ b/meta-opencentauri/recipes-apps/klipper/files/machine.cfg @@ -19,14 +19,20 @@ restart_method: command [printer] -kinematics: limited_corexy -max_x_accel:10000 -max_y_accel:5000 +kinematics: corexy max_velocity: 500 max_accel: 20000 max_z_velocity: 20 max_z_accel: 500 +# kinematics: limited_corexy +# max_x_accel:10000 +# max_y_accel:5000 +# max_velocity: 500 +# max_accel: 20000 +# max_z_velocity: 20 +# max_z_accel: 500 + [gcode_arcs] resolution: 0.5 @@ -134,10 +140,10 @@ sensor_pin: hotend:PA3 microsteps: 16 full_steps_per_rotation: 200 gear_ratio: 52:10 -rotation_distance: 27.3 #could be 27.3 needs more testing +rotation_distance: 28.8 #could be 27.3 needs more testing 28.8 default nozzle_diameter: 0.4 filament_diameter: 1.75 -sensor_type: hotend_termistor +sensor_type: hotend_thermistor_stock min_temp: 5 max_temp: 335 min_extrude_temp: 180 @@ -145,6 +151,10 @@ pressure_advance: 0.04 pressure_advance_smooth_time: 0.04 max_extrude_only_distance: 150 max_extrude_cross_section: 5 +control: pid +pid_Kp: 24.860427 +pid_Ki: 2.702253 +pid_Kd: 57.178292 [tmc2209 extruder] tx_pin: hotend:PC6 @@ -156,10 +166,37 @@ sense_resistor: 0.1 [verify_heater extruder] -[thermistor hotend_termistor] +[thermistor hotend_thermistor_stock] +temperature1: 25 +resistance1: 100000 +beta: 4700 + +[thermistor hotend_thermistor_canvas] temperature1: 25 resistance1: 100000 -beta: 4300 +beta: 4800 + +# CC1 "classic" hotend config +# Fixed beta value based on Atom's measurements +# beta: 4700 +[thermistor elegoo_stock_thermistor] +temperature1: 25 +resistance1: 100000 +temperature2: 242 +resistance2: 132.162 +temperature3: 297 +resistance3: 51.929 + +# CC1 CANVAS hotend config +# Fixed beta value based on Atom's measurements +# beta: 4800 +[thermistor elegoo_canvas_thermistor] +temperature1: 72 +resistance1: 9206.431 +temperature2: 95 +resistance2: 4186.247 +temperature3: 293 +resistance3: 47.387 [heater_fan extruder] pin: hotend:PC8 @@ -196,6 +233,10 @@ sensor_pin: PB14 sensor_type: Generic 3950 min_temp: 5 max_temp: 125 +control: pid +pid_Kp: 46.504839 +pid_Ki: 1.453276 +pid_Kd: 372.038710 [verify_heater heater_bed] @@ -272,8 +313,8 @@ insert_gcode: white_pin: PG15 initial_WHITE: 1 -# [led hotend] -# white_pin: hotend:PC9 +[led hotend] +white_pin: hotend:PC9 [temperature_sensor chamber] sensor_pin: PB13 diff --git a/meta-opencentauri/recipes-apps/klipper/files/macros.cfg b/meta-opencentauri/recipes-apps/klipper/files/macros.cfg index 19587e5f..a1bf5b56 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/macros.cfg +++ b/meta-opencentauri/recipes-apps/klipper/files/macros.cfg @@ -3,40 +3,18 @@ # EDITING THIS FILE WILL EXCLUDE YOUR CHANGES FROM FUTURE UPDATES. # ----- - - [gcode_macro _global_var] +variable_target_extruder: 0 variable_pause_park:{'x': 10, 'y': 240, 'z': 10, 'e': 2} variable_cancel_park:{'x': 240, 'y': 240, 'z': 10, 'e': 5} variable_extruder_temp:{'probing': 140, 'cleaning': 180, 'loading': 230, 'purging': 250} variable_z_maximum_lifting_distance: 250 variable_pause_resume_travel_speed: 150 -variable_heatsoak: 1 -variable_adaptive_mesh: True -variable_adaptive_purge: True +variable_heatsoak: 0 +variable_adaptive_mesh: False +variable_adaptive_purge: False gcode: -[gcode_macro ALL_FANS_OFF] -gcode: - M107 - SET_FAN_SPEED FAN=aux_fan SPEED=0 - SET_FAN_SPEED FAN=case_fan SPEED=0 - SET_DISPLAY_TEXT MSG="ALL FANS OFF!" - -[gcode_macro _IDLE_TIMEOUT] -gcode: - {% if printer.print_stats.state == "paused" %} - SET_DISPLAY_TEXT MSG="PAUSED" - {% else %} - M84 - TURN_OFF_HEATERS - ALL_FANS_OFF - SET_DISPLAY_TEXT MSG="No operations in 30mins!" - {% endif %} - -[gcode_macro M600] -gcode: - PAUSE STATE=filament_change [gcode_macro PRINT_START] gcode: @@ -45,6 +23,9 @@ gcode: {% set target_chamber = params.CHAMBER|int %} {% set sensor = printer['filament_switch_sensor filament_sensor'] %} {% set svar = printer['gcode_macro _global_var'] %} + + SET_GCODE_VARIABLE MACRO=_global_var VARIABLE=target_extruder VALUE={target_extruder} + ALL_FANS_OFF BED_MESH_CLEAR CLEAR_PAUSE @@ -170,6 +151,7 @@ gcode: M221 S100 CLEAR_PAUSE M84 + SET_GCODE_VARIABLE MACRO=_global_var VARIABLE=target_extruder VALUE=0 SET_DISPLAY_TEXT MSG="Cancel Print Success!" [gcode_macro PAUSE] @@ -189,34 +171,34 @@ gcode: SET_DISPLAY_TEXT MSG="Pausing" PAUSE_BASE - G91 + + + {% if (printer.extruder.temperature + 5 >= printer.extruder.target) and printer.extruder.can_extrude %} + {% if sensor.enabled and sensor.filament_detected %} + G91 + G1 E-{e_retract} F300 + G90 + {% endif %} + {% endif %} {% if printer.toolhead.homed_axes|lower == "xyz" %} {% set zpos = printer.gcode_move.position.z %} + G91 {% if (zpos + 5) < z_lift_max %} G1 Z+5 F3000 {% else %} G1 Z+{(z_lift_max - zpos)} F3000 {% endif %} - G90 - {% if pos.x != x_park or pos.y != y_park %} G1 X{x_park} Y{y_park} F{svar.pause_resume_travel_speed * 60} {% endif %} {% endif %} # Keep heater on so resume can prime quickly - M104 S{printer.extruder.target} + M104 S{svar.extruder_temp.probing} {% if state == 'normal' %} - {% if (printer.extruder.temperature + 5 >= printer.extruder.target) and extruder.can_extrude %} - {% if sensor.enabled and sensor.filament_detected %} - G91 - G1 E-{e_retract} F300 - G90 - {% endif %} - {% endif %} SET_DISPLAY_TEXT MSG="Paused normal" {% elif state == 'filament_change' %} @@ -224,8 +206,9 @@ gcode: {% if printer.extruder.temperature + 5 < printer.extruder.target %} M109 S{printer.extruder.target} {% endif %} - UNLOAD_FILAMENT SET_DISPLAY_TEXT MSG="Paused for filament change" + UNLOAD_FILAMENT + LOAD_FILAMENT {% elif state == 'runout' %} # Runout pause: keep heater on and prompt user to insert filament @@ -239,8 +222,6 @@ gcode: SET_DISPLAY_TEXT MSG="Printer already paused" {% endif %} - - [delayed_gcode _resume_wait] gcode: {% if printer['gcode_macro RESUME'].execute|lower != 'false' %} @@ -253,8 +234,9 @@ variable_state: 'normal' gcode: {% set svar = printer['gcode_macro _global_var'] %} {% set e_retract = svar.pause_park.e|float %} - {% set extruder_target_temp = printer.extruder.target|int %} + #{% set extruder_target_temp = printer.extruder.target|int %} {% set sensor = printer['filament_switch_sensor filament_sensor'] %} + {% set extruder_target_temp = printer['gcode_macro _global_var'].target_extruder %} # If filament sensor is enabled require filament present before resuming {% if sensor.enabled and not sensor.filament_detected %} @@ -263,8 +245,8 @@ gcode: {% endif %} # Ensure nozzle heated to target before attempting to prime/extrude - # {% if printer.extruder.temperature + 5 < extruder_target_temp %} - # SET_DISPLAY_TEXT MSG="Heating nozzle to {extruder_target_temp}C" + # if printer.extruder.temperature + 5 < extruder_target_temp %} + #SET_DISPLAY_TEXT MSG="Heating nozzle to {extruder_target_temp}C" M109 S{extruder_target_temp} # {% endif %} G91 @@ -284,7 +266,7 @@ gcode: # Move to purge position MOVE_TO_TRAY M104 S{svar.extruder_temp.purging} ; Heat nozzle to purging temp - TEMPERATURE_WAIT SENSOR=extruder MINIMUM={svar.extruder_temp.purging} + TEMPERATURE_WAIT SENSOR=extruder MINIMUM={svar.extruder_temp.purging} MAXIMUM={svar.extruder_temp.purging+5} ; Heat nozzle to 250°C and wait # Purge filament (8 cycles) @@ -296,7 +278,7 @@ gcode: M400 ; Wait for completion {% endfor %} M104 S{svar.extruder_temp.loading} - TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={svar.extruder_temp.loading} + TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={svar.extruder_temp.loading} MINIMUM={svar.extruder_temp.loading-5} {% for purge in range(4) %} G1 E25 F300 ; Extrude 13mm at medium speed G1 E10 F150 ; Extrude 2mm slowly (ensure flow) @@ -305,7 +287,7 @@ gcode: G1 E-2 F1800 ; Retract 2mm to prevent oozing M104 S0 M106 S255 - TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={svar.extruder_temp.cleaning} + TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={svar.extruder_temp.cleaning} MINIMUM={svar.extruder_temp.cleaning-5} M107 G0 X170 G0 Y250 @@ -314,36 +296,6 @@ gcode: G0 X170 G0 Y250 -# Home Z with Strain Gauge, ends up with the nozzle 2mm above bed - - - -[gcode_macro LOADCELL_Z_HOME] -gcode: - {% set svar = printer['gcode_macro _global_var'] %} - - M104 S{svar.extruder_temp.probing} - {% if "xyz" not in printer.toolhead.homed_axes %} - G28 ; Home if necessary - {% endif %} - BED_MESH_CLEAR - # Move down a Z to get some clearance - G91 ; Relative positioning - G1 Z5 F600 - G90 - G0 X128 Y128 F9000 ; Move up 2mm - M109 S{svar.extruder_temp.probing} - PROBE ; Probe with strain gauge - M400 ; Wait for moves to finish - - # Store the end position as new Z=0 - SET_KINEMATIC_POSITION Z=0 SET_HOMED=Z ; Set current Z as 0 - # Move up 2mm from the probed position - M104 S0 - G91 ; Relative positioning - G1 Z5 F600 ; Move up 2mm - G90 ; Absolute positioning -# Wipe Nozzle, see auto_leveling.cpp:443 [gcode_macro CLEAN_NOZZLE] gcode: {% set svar = printer['gcode_macro _global_var'] %} @@ -358,7 +310,7 @@ gcode: MOVE_TO_TRAY SET_DISPLAY_TEXT MSG="Cleaning nozzle: {svar.extruder_temp.cleaning}c" M104 S{svar.extruder_temp.cleaning} - TEMPERATURE_WAIT SENSOR=extruder MINIMUM={svar.extruder_temp.cleaning} + TEMPERATURE_WAIT SENSOR=extruder MINIMUM={svar.extruder_temp.cleaning} MAXIMUM={svar.extruder_temp.cleaning+5} M104 S{svar.extruder_temp.probing} M106 S255 # Wipe @@ -373,7 +325,7 @@ gcode: {% endfor %} # Move a 2mm on Y G1 Y263 - TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={svar.extruder_temp.probing} + TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={svar.extruder_temp.probing} M104 S0 G1 F9000 @@ -392,125 +344,8 @@ gcode: M107 M400 + ; Absolute positioning -[gcode_macro WIPE_NOZZLE] -gcode: - {% set bed_temp = params.BED_TEMP|default(60)|int %} - - G28 ; Home - M204 S5000 ; Set acceleration to 5000 mm/s - M400 ; Wait for moves to finish - G90 ; Absolute positioning - M106 S0 ; Turn off part cooling fan - SET_FAN_SPEED FAN=aux_fan SPEED=0 ; Turn off auxiliary fan - M83 ; Relative extrusion mode - - # Move to purge position - MOVE_TO_TRAY - M109 S250 ; Heat nozzle to 250°C and wait - - # Purge filament (8 cycles) - G92 E0 ; Reset extruder position - M106 S255 ; Turn on part cooling fan (full speed) - SET_FAN_SPEED FAN=aux_fan SPEED=1 ; Turn on auxiliary fan (full speed) - G1 E13 F523 ; Extrude 13mm at medium speed - G1 E2 F150 ; Extrude 2mm slowly (ensure flow) - M400 ; Wait for completion - G1 E13 F523 ; Repeat purge cycle 2 - G1 E2 F150 - M400 - G1 E13 F523 ; Repeat purge cycle 3 - G1 E2 F150 - M400 - G1 E13 F523 ; Repeat purge cycle 4 - G1 E2 F150 - M400 - G1 E13 F523 ; Repeat purge cycle 5 - G1 E2 F150 - M400 - G1 E13 F523 ; Repeat purge cycle 6 - G1 E2 F150 - M400 - G1 E13 F523 ; Repeat purge cycle 7 - G1 E2 F150 - M400 - G1 E13 F523 ; Repeat purge cycle 8 - G1 E2 F150 - M400 - G1 E-2 F1800 ; Retract 2mm to prevent oozing - - # Cool nozzle for cleaning - M109 S180 ; Cool to 180°C and wait - M400 ; Wait for moves - M104 S140 ; Start cooling to final temp (140°C) - G4 P4000 ; Dwell 4 seconds - - # Wipe nozzle using CLEAN_NOZZLE pattern - M204 S15000 ; Set high acceleration for wipe - CLEAN_NOZZLE ; Execute wipe pattern (moves across wiper) - M204 S5000 ; Restore normal acceleration - - # --- ADDITIONAL NOZZLE CLEANING --- - G1 X128 Y254 F3000 ; Move to cleaning brush area - M140 S{bed_temp} ; Keep bed at target temp - - STRAINGAUGE_Z_HOME ; Home Z using strain gauge - - M400 ; Wait for completion - #G91 ; Relative positioning - #G1 Z2 F600 ; Lift Z by 2mm - #G90 ; Absolute positioning - G1 Z2 F600 ; Ensure Z is 2mm above bed - - G1 Y261.5 F9000 ; Move to brush position - G91 ; Relative positioning - G1 Z-2.5 F600 ; Lower into brush - M400 ; Wait for position - - # Scrub nozzle back and forth (4 passes) - G90 ; Absolute positioning - G1 X140 F2000 ; Scrub right - G1 X110 ; Scrub left - G1 X140 F2000 ; Scrub right - G1 X110 ; Scrub left - G1 X140 F2000 ; Scrub right - G1 X110 ; Scrub left - G1 X140 F2000 ; Scrub right - G1 X110 ; Scrub left - G1 X140 F2000 ; Final scrub right - G1 X128 ; Return to center - M400 ; Wait for completion - - # Lift and move away from brush - G91 ; Relative positioning - G1 Z3 F600 ; Lift Z by 3mm - M400 ; Wait - G90 ; Absolute positioning - G1 Y254 F9000 ; Move away from brush - G1 X128 F9000 ; Center X position - - # --- CALIBRATION PREPARATION --- - M140 S{bed_temp} ; Keep bed at target temp - STRAINGAUGE_Z_HOME ; Home Z with strain gauge again - #G91 ; Relative positioning - #G1 Z-2.5 F600 ; Lower slightly - #G90 ; Absolute positioning - M400 ; Wait for completion - - # Heat to calibration temperatures - M140 S{bed_temp} ; Heat bed to target temp - M109 S140 ; Heat nozzle to 140°C and wait - M400 ; Wait for stability - M106 S0 ; Turn off part cooling fan - SET_FAN_SPEED FAN=aux_fan SPEED=0 ; Turn off auxiliary fan - - # Final positioning before probe calibration - G91 ; Relative positioning - G1 Z2 F600 ; Lift Z by 2mm - G90 ; Absolute positioning - - -# Move the toolhead to the tray [gcode_macro MOVE_TO_TRAY] gcode: {% if "xyz" not in printer.toolhead.homed_axes %} @@ -524,12 +359,16 @@ gcode: M400 ; Wait for movements to complete + [gcode_macro _LOAD_FILAMENT_STEP_PUSH] gcode: - _CLOSE_PROMPT ; Close any existing prompt + ; Close any existing prompt M83 ; Relative extrusion mode G92 E0 ; Reset extruder position - G1 E60 F420 ; Move filament into the extruder (120mm at 4mm/s) + G1 E70 F420 + ; Move filament into the extruder (120mm at 4mm/s) + G4 P1000 + _CLOSE_PROMPT #CLEAN_NOZZLE ; Wipe nozzle after loading RESPOND TYPE=command MSG="action:prompt_begin Loading Filament" @@ -545,46 +384,25 @@ gcode: M104 S0 ; Turn off nozzle heater #M106 S0 ; Turn off part cooling fan - [gcode_macro LOAD_FILAMENT] gcode: + {% set svar = printer['gcode_macro _global_var'] %} _CLOSE_PROMPT - {% set extruder_temp = params.EXTRUDER_TEMP|default(250) %} {% if "xyz" not in printer.toolhead.homed_axes %} G28 ; Home if necessary {% endif %} - M104 S{extruder_temp} ; Start heating the nozzle - MOVE_TO_TRAY ; Move to the tray + M104 S{svar.extruder_temp.loading} + TEMPERATURE_WAIT SENSOR=extruder MINIMUM={svar.extruder_temp.loading} MAXIMUM={svar.extruder_temp.loading+5} + M107 ; Turn on part cooling fan (full speed) RESPOND TYPE=command MSG="action:prompt_begin Load Filament" RESPOND TYPE=command MSG="action:prompt_text Insert filament all the way into extruder before continuing" RESPOND TYPE=command MSG="action:prompt_footer_button LOAD|_LOAD_FILAMENT_STEP_PUSH" - RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RETURN" + RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|_CLOSE_PROMPT" RESPOND TYPE=command MSG="action:prompt_show" - M109 S{extruder_temp} ; Wait for nozzle to reach temp - M107 ; Turn on part cooling fan (full speed) - _LOAD_FILAMENT_STEP_PUSH ; Push filament into extruder and wipe - - -# Cuts the tip of the filament and ejects it from the extruder - -[gcode_macro CUT_FILAMENT] -gcode: - {% if "xyz" not in printer.toolhead.homed_axes %} - G28 ; Home if necessary - {% endif %} - - G90 - G0 Y20 F8000 - G0 X255 F8000 - G0 Y4 F1200 - G0 Y20 F1200 - M400 - - [gcode_macro UNLOAD_FILAMENT] gcode: {% if "xyz" not in printer.toolhead.homed_axes %} @@ -599,21 +417,7 @@ gcode: COLD_EXTRUDE HEATER=extruder ENABLE=0 G0 Y250 M400 ; Wait for movements to complete -[gcode_macro BED_MESH_CALIBRATE] -rename_existing: BED_MESH_CALIBRATE_BASE -gcode: - {% set svar = printer['gcode_macro _global_var'] %} - {% set bed_temp = params.BED_TEMP|default(60)|float %} - M140 S{bed_temp} - G28 - CLEAN_NOZZLE - M190 S{bed_temp} - M104 S{svar.extruder_temp.probing} - G4 S60000 - LOADCELL_Z_HOME - M109 S{svar.extruder_temp.probing} - ALL_FANS_OFF - BED_MESH_CALIBRATE_BASE + [homing_override] axes: xyz # This forces the z position to be at 0 when we start homing, so we can move the Z up before homing. @@ -643,7 +447,90 @@ gcode: {% if "default" in printer.bed_mesh.profiles %} BED_MESH_PROFILE LOAD=default {% endif %} + +[gcode_macro LOADCELL_Z_HOME] +gcode: + {% set svar = printer['gcode_macro _global_var'] %} + M104 S{svar.extruder_temp.probing} + {% if "xyz" not in printer.toolhead.homed_axes %} + G28 ; Home if necessary + {% endif %} + BED_MESH_CLEAR + # Move down a Z to get some clearance + G91 ; Relative positioning + G1 Z5 F600 + G90 + G0 X128 Y128 F9000 ; Move up 2mm + M109 S{svar.extruder_temp.probing} + PROBE ; Probe with strain gauge + M400 ; Wait for moves to finish + + # Store the end position as new Z=0 + SET_KINEMATIC_POSITION Z=0 SET_HOMED=Z ; Set current Z as 0 + # Move up 2mm from the probed position + M104 S0 + G91 ; Relative positioning + G1 Z5 F600 ; Move up 2mm + G90 ; Absolute positioning + +[gcode_macro BED_MESH_CALIBRATE] +rename_existing: BED_MESH_CALIBRATE_BASE +gcode: + {% set svar = printer['gcode_macro _global_var'] %} + {% set bed_temp = params.BED_TEMP|default(60)|float %} + M140 S{bed_temp} + G28 + CLEAN_NOZZLE + M190 S{bed_temp} + M104 S{svar.extruder_temp.probing} + G4 S60000 + LOADCELL_Z_HOME + M109 S{svar.extruder_temp.probing} + ALL_FANS_OFF + BED_MESH_CALIBRATE_BASE + +[gcode_macro SCREWS_TILT_CALCULATE] +rename_existing: SCREWS_TILT_CALCULATE_BASE +gcode: + {% set svar = printer['gcode_macro _global_var'] %} + {% set bed_temp = params.BED_TEMP|default(60)|int %} + + {% if "xyz" not in printer.toolhead.homed_axes %} + G28 ; Home if necessary + {% endif %} + + BED_MESH_CLEAR + M190 S{bed_temp} + M109 S{svar.extruder_temp.probing} + M400 + G28 + CLEAN_NOZZLE + SCREWS_TILT_CALCULATE_BASE + + +[gcode_macro _IDLE_TIMEOUT] +gcode: + {% if printer.print_stats.state == "paused" %} + SET_DISPLAY_TEXT MSG="PAUSED" + {% else %} + M84 + TURN_OFF_HEATERS + ALL_FANS_OFF + SET_DISPLAY_TEXT MSG="No operations in 30mins!" + {% endif %} + +[gcode_macro ALL_FANS_OFF] +gcode: + M107 + SET_FAN_SPEED FAN=aux_fan SPEED=0 + SET_FAN_SPEED FAN=case_fan SPEED=0 + SET_DISPLAY_TEXT MSG="ALL FANS OFF!" + +[gcode_macro M600] +gcode: + PAUSE STATE=filament_change + [gcode_macro _SHOW_PROMPT] gcode: @@ -673,34 +560,6 @@ gcode: SET_DISPLAY_TEXT_BASE MSG="{message}" -[gcode_macro SCREWS_TILT_CALCULATE] -rename_existing: SCREWS_TILT_CALCULATE_BASE -gcode: - {% set svar = printer['gcode_macro _global_var'] %} - {% set bed_temp = params.BED_TEMP|default(60)|int %} - - {% if "xyz" not in printer.toolhead.homed_axes %} - G28 ; Home if necessary - {% endif %} - - BED_MESH_CLEAR - M190 S{bed_temp} - M109 S{svar.extruder_temp.probing} - M400 - G28 - CLEAN_NOZZLE - SCREWS_TILT_CALCULATE_BASE -[gcode_macro TEST] -gcode: - {% set svar = printer['gcode_macro _global_var'] %} - - {% if svar.adaptive_purge %} - SET_DISPLAY_TEXT MSG="purgeLINE_PURGE" - {% endif %} - - {% if svar.adaptive_mesh %} - SET_DISPLAY_TEXT MSG="meshSMART_PARK" - {% endif %} [gcode_macro M729] gcode: diff --git a/meta-opencentauri/recipes-apps/klipper/kalico_2026.02.00.bb b/meta-opencentauri/recipes-apps/klipper/kalico_2026.02.00.bb index a6e4d54e..11dc9921 100644 --- a/meta-opencentauri/recipes-apps/klipper/kalico_2026.02.00.bb +++ b/meta-opencentauri/recipes-apps/klipper/kalico_2026.02.00.bb @@ -13,7 +13,7 @@ SRC_URI += " \ file://shell.cfg \ file://screen.cfg \ file://calibration.cfg \ - file://client.cfg \ + file://kamp.cfg \ " inherit python3-dir update-rc.d @@ -97,7 +97,7 @@ do_install() { # Copy non-printer .cfg files to readonly folder install -d ${D}${sysconfdir}/klipper/config/klipper-readonly - install -m 0644 ${WORKDIR}/machine.cfg ${WORKDIR}/shell.cfg ${WORKDIR}/macros.cfg ${WORKDIR}/calibration.cfg ${WORKDIR}/screen.cfg ${WORKDIR}/client.cfg ${D}${sysconfdir}/klipper/config/klipper-readonly + install -m 0644 ${WORKDIR}/machine.cfg ${WORKDIR}/shell.cfg ${WORKDIR}/macros.cfg ${WORKDIR}/calibration.cfg ${WORKDIR}/screen.cfg ${WORKDIR}/kamp.cfg ${D}${sysconfdir}/klipper/config/klipper-readonly # Install SysVinit script install -d ${D}${sysconfdir}/init.d @@ -117,5 +117,5 @@ CONFFILES:${PN} = " \ ${sysconfdir}/klipper/config/klipper-readonly/shell.cfg \ ${sysconfdir}/klipper/config/klipper-readonly/screen.cfg \ ${sysconfdir}/klipper/config/klipper-readonly/calibration.cfg \ - ${sysconfdir}/klipper/config/klipper-readonly/client.cfg \ + ${sysconfdir}/klipper/config/klipper-readonly/kamp.cfg \ " From 8718d57be746b92b11b2b534724f72f5589d3e59 Mon Sep 17 00:00:00 2001 From: Atomique13 Date: Thu, 21 May 2026 05:32:11 -0400 Subject: [PATCH 3/5] Remove deprecated client configuration file to streamline Klipper setup --- .../recipes-apps/klipper/files/client.cfg | 319 ------------------ 1 file changed, 319 deletions(-) delete mode 100644 meta-opencentauri/recipes-apps/klipper/files/client.cfg diff --git a/meta-opencentauri/recipes-apps/klipper/files/client.cfg b/meta-opencentauri/recipes-apps/klipper/files/client.cfg deleted file mode 100644 index a75c4d20..00000000 --- a/meta-opencentauri/recipes-apps/klipper/files/client.cfg +++ /dev/null @@ -1,319 +0,0 @@ -# ----- -# PLEASE DO NOT EDIT THIS FILE. EDIT printer.cfg INSTEAD. -# EDITING THIS FILE WILL EXCLUDE YOUR CHANGES FROM FUTURE UPDATES. -# ----- - -## Client klipper macro definitions -## -## Copyright (C) 2022 Alex Zellner -## -## This file may be distributed under the terms of the GNU GPLv3 license -## -## !!! This file is read-only. Maybe the used editor indicates that. !!! -## -## Customization: -## 1) copy the gcode_macro _CLIENT_VARIABLE (see below) to your printer.cfg -## 2) remove the comment mark (#) from all lines -## 3) change any value in there to your needs -## -## Use the PAUSE macro direct in your M600: -## e.g. with a different park position front left and a minimal height of 50 -## [gcode_macro M600] -## description: Filament change -## gcode: PAUSE X=10 Y=10 Z_MIN=50 -## Z_MIN will park the toolhead at a minimum of 50 mm above to bed to make it easier for you to swap filament. -## -## Client variable macro for your printer.cfg -#[gcode_macro _CLIENT_VARIABLE] -#variable_use_custom_pos : False ; use custom park coordinates for x,y [True/False] -#variable_custom_park_x : 0.0 ; custom x position; value must be within your defined min and max of X -#variable_custom_park_y : 0.0 ; custom y position; value must be within your defined min and max of Y -#variable_custom_park_dz : 2.0 ; custom dz value; the value in mm to lift the nozzle when move to park position -#variable_retract : 1.0 ; the value to retract while PAUSE -#variable_cancel_retract : 5.0 ; the value to retract while CANCEL_PRINT -#variable_speed_retract : 35.0 ; retract speed in mm/s -#variable_unretract : 1.0 ; the value to unretract while RESUME -#variable_speed_unretract : 35.0 ; unretract speed in mm/s -#variable_speed_hop : 15.0 ; z move speed in mm/s -#variable_speed_move : 100.0 ; move speed in mm/s -#variable_park_at_cancel : False ; allow to move the toolhead to park while execute CANCEL_PRINT [True/False] -#variable_park_at_cancel_x : None ; different park position during CANCEL_PRINT [None/Position as Float]; park_at_cancel must be True -#variable_park_at_cancel_y : None ; different park position during CANCEL_PRINT [None/Position as Float]; park_at_cancel must be True -## !!! Caution [firmware_retraction] must be defined in the printer.cfg if you set use_fw_retract: True !!! -#variable_use_fw_retract : False ; use fw_retraction instead of the manual version [True/False] -#variable_idle_timeout : 0 ; time in sec until idle_timeout kicks in. Value 0 means that no value will be set or restored -#variable_runout_sensor : "" ; If a sensor is defined, it will be used to cancel the execution of RESUME in case no filament is detected. -## Specify the config name of the runout sensor e.g "filament_switch_sensor runout". Hint use the same as in your printer.cfg -## !!! Custom macros, please use with care and review the section of the corresponding macro. -## These macros are for simple operations like setting a status LED. Please make sure your macro does not interfere with the basic macro functions. -## Only single line commands are supported, please create a macro if you need more than one command. -#variable_user_pause_macro : "" ; Everything inside the "" will be executed after the klipper base pause (PAUSE_BASE) function -#variable_user_resume_macro: "" ; Everything inside the "" will be executed before the klipper base resume (RESUME_BASE) function -#variable_user_cancel_macro: "" ; Everything inside the "" will be executed before the klipper base cancel (CANCEL_PRINT_BASE) function -#gcode: - -[virtual_sdcard] -path: /etc/klipper/gcodes -on_error_gcode: CANCEL_PRINT - -[pause_resume] -#recover_velocity: 50. -# When capture/restore is enabled, the speed at which to return to -# the captured position (in mm/s). Default is 50.0 mm/s. - -[display_status] - -[respond] - -[gcode_macro CANCEL_PRINT] -description: Cancel the actual running print -rename_existing: CANCEL_PRINT_BASE -gcode: - ##### get user parameters or use default ##### - {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} - {% set allow_park = client.park_at_cancel|default(false)|lower == 'true' %} - {% set retract = client.cancel_retract|default(5.0)|abs %} - ##### define park position ##### - {% set park_x = "" if (client.park_at_cancel_x|default(none) is none) - else "X=" ~ client.park_at_cancel_x %} - {% set park_y = "" if (client.park_at_cancel_y|default(none) is none) - else "Y=" ~ client.park_at_cancel_y %} - {% set custom_park = park_x|length > 0 or park_y|length > 0 %} - ##### end of definitions ##### - # restore idle_timeout time if needed - {% if printer['gcode_macro RESUME'].restore_idle_timeout > 0 %} - SET_IDLE_TIMEOUT TIMEOUT={printer['gcode_macro RESUME'].restore_idle_timeout} - {% endif %} - {% if (custom_park or not printer.pause_resume.is_paused) and allow_park %} _TOOLHEAD_PARK_PAUSE_CANCEL {park_x} {park_y} {% endif %} - _CLIENT_RETRACT LENGTH={retract} - TURN_OFF_HEATERS - M106 S0 - {client.user_cancel_macro|default("")} - SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=idle_state VALUE=False - # clear pause_next_layer and pause_at_layer as preparation for next print - SET_PAUSE_NEXT_LAYER ENABLE=0 - SET_PAUSE_AT_LAYER ENABLE=0 LAYER=0 - CANCEL_PRINT_BASE - -[gcode_macro PAUSE] -description: Pause the actual running print -rename_existing: PAUSE_BASE -gcode: - ##### get user parameters or use default ##### - {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} - {% set idle_timeout = client.idle_timeout|default(0) %} - {% set temp = printer[printer.toolhead.extruder].target if printer.toolhead.extruder != '' else 0 %} - {% set restore = False if printer.toolhead.extruder == '' - else True if params.RESTORE|default(1)|int == 1 else False %} - ##### end of definitions ##### - SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=last_extruder_temp VALUE="{{'restore': restore, 'temp': temp}}" - # set a new idle_timeout value - {% if idle_timeout > 0 %} - SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=restore_idle_timeout VALUE={printer.configfile.settings.idle_timeout.timeout} - SET_IDLE_TIMEOUT TIMEOUT={idle_timeout} - {% endif %} - PAUSE_BASE - {client.user_pause_macro|default("")} - _TOOLHEAD_PARK_PAUSE_CANCEL {rawparams} - -[gcode_macro RESUME] -description: Resume the actual running print -rename_existing: RESUME_BASE -variable_last_extruder_temp: {'restore': False, 'temp': 0} -variable_restore_idle_timeout: 0 -variable_idle_state: False -gcode: - ##### get user parameters or use default ##### - {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} - {% set velocity = printer.configfile.settings.pause_resume.recover_velocity %} - {% set sp_move = client.speed_move|default(velocity) %} - {% set runout_resume = True if client.runout_sensor|default("") == "" # no runout - else True if not printer[client.runout_sensor].enabled # sensor is disabled - else printer[client.runout_sensor].filament_detected %} # sensor status - {% set can_extrude = True if printer.toolhead.extruder == '' # no extruder defined in config - else printer[printer.toolhead.extruder].can_extrude %} # status of active extruder - {% set do_resume = False %} - {% set prompt_txt = [] %} - ##### end of definitions ##### - #### Printer comming from timeout idle state #### - {% if printer.idle_timeout.state|upper == "IDLE" or idle_state %} - SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=idle_state VALUE=False - {% if last_extruder_temp.restore %} - # we need to use the unicode (\u00B0) for the ° as py2 env's would throw an error otherwise - RESPOND TYPE=echo MSG='{"Restoring \"%s\" temperature to %3.1f\u00B0C, this may take some time" % (printer.toolhead.extruder, last_extruder_temp.temp) }' - M109 S{last_extruder_temp.temp} - {% set do_resume = True %} - {% elif can_extrude %} - {% set do_resume = True %} - {% else %} - RESPOND TYPE=error MSG='{"Resume aborted !!! \"%s\" not hot enough, please heat up again and press RESUME" % printer.toolhead.extruder}' - {% set _d = prompt_txt.append("\"%s\" not hot enough, please heat up again and press RESUME" % printer.toolhead.extruder) %} - {% endif %} - #### Printer comming out of regular PAUSE state #### - {% elif can_extrude %} - {% set do_resume = True %} - {% else %} - RESPOND TYPE=error MSG='{"Resume aborted !!! \"%s\" not hot enough, please heat up again and press RESUME" % printer.toolhead.extruder}' - {% set _d = prompt_txt.append("\"%s\" not hot enough, please heat up again and press RESUME" % printer.toolhead.extruder) %} - {% endif %} - {% if runout_resume %} - {% if do_resume %} - {% if restore_idle_timeout > 0 %} SET_IDLE_TIMEOUT TIMEOUT={restore_idle_timeout} {% endif %} # restore idle_timeout time - {client.user_resume_macro|default("")} - _CLIENT_EXTRUDE - RESUME_BASE VELOCITY={params.VELOCITY|default(sp_move)} - {% endif %} - {% else %} - RESPOND TYPE=error MSG='{"Resume aborted !!! \"%s\" detects no filament, please load filament and press RESUME" % (client.runout_sensor.split(" "))[1]}' - {% set _d = prompt_txt.append("\"%s\" detects no filament, please load filament and press RESUME" % (client.runout_sensor.split(" "))[1]) %} - {% endif %} - ##### Generate User Information box in case of abort ##### - {% if not (runout_resume and do_resume) %} - RESPOND TYPE=command MSG="action:prompt_begin RESUME aborted !!!" - {% for element in prompt_txt %} - RESPOND TYPE=command MSG='{"action:prompt_text %s" % element}' - {% endfor %} - RESPOND TYPE=command MSG="action:prompt_footer_button Ok|RESPOND TYPE=command MSG=action:prompt_end|info" - RESPOND TYPE=command MSG="action:prompt_show" - {% endif %} - -# Usage: SET_PAUSE_NEXT_LAYER [ENABLE=[0|1]] [MACRO=] -[gcode_macro SET_PAUSE_NEXT_LAYER] -description: Enable a pause if the next layer is reached -gcode: - {% set pause_next_layer = printer['gcode_macro SET_PRINT_STATS_INFO'].pause_next_layer %} - {% set ENABLE = params.ENABLE|default(1)|int != 0 %} - {% set MACRO = params.MACRO|default(pause_next_layer.call, True) %} - SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_next_layer VALUE="{{ 'enable': ENABLE, 'call': MACRO }}" - -# Usage: SET_PAUSE_AT_LAYER [ENABLE=[0|1]] [LAYER=] [MACRO=] -[gcode_macro SET_PAUSE_AT_LAYER] -description: Enable/disable a pause if a given layer number is reached -gcode: - {% set pause_at_layer = printer['gcode_macro SET_PRINT_STATS_INFO'].pause_at_layer %} - {% set ENABLE = params.ENABLE|int != 0 if params.ENABLE is defined - else params.LAYER is defined %} - {% set LAYER = params.LAYER|default(pause_at_layer.layer)|int %} - {% set MACRO = params.MACRO|default(pause_at_layer.call, True) %} - SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_at_layer VALUE="{{ 'enable': ENABLE, 'layer': LAYER, 'call': MACRO }}" - -# Usage: SET_PRINT_STATS_INFO [TOTAL_LAYER=] [CURRENT_LAYER= ] -[gcode_macro SET_PRINT_STATS_INFO] -rename_existing: SET_PRINT_STATS_INFO_BASE -description: Overwrite, to get pause_next_layer and pause_at_layer feature -variable_pause_next_layer: { 'enable': False, 'call': "PAUSE" } -variable_pause_at_layer : { 'enable': False, 'layer': 0, 'call': "PAUSE" } -gcode: - {% if pause_next_layer.enable %} - RESPOND TYPE=echo MSG='{"%s, forced by pause_next_layer" % pause_next_layer.call}' - {pause_next_layer.call} ; execute the given gcode to pause, should be either M600 or PAUSE - SET_PAUSE_NEXT_LAYER ENABLE=0 - {% elif pause_at_layer.enable and params.CURRENT_LAYER is defined and params.CURRENT_LAYER|int == pause_at_layer.layer %} - RESPOND TYPE=echo MSG='{"%s, forced by pause_at_layer [%d]" % (pause_at_layer.call, pause_at_layer.layer)}' - {pause_at_layer.call} ; execute the given gcode to pause, should be either M600 or PAUSE - SET_PAUSE_AT_LAYER ENABLE=0 - {% endif %} - SET_PRINT_STATS_INFO_BASE {rawparams} - -##### internal use ##### -[gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL] -description: Helper: park toolhead used in PAUSE and CANCEL_PRINT -gcode: - ##### get user parameters or use default ##### - {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} - {% set velocity = printer.configfile.settings.pause_resume.recover_velocity %} - {% set use_custom = client.use_custom_pos|default(false)|lower == 'true' %} - {% set custom_park_x = client.custom_park_x|default(0.0) %} - {% set custom_park_y = client.custom_park_y|default(0.0) %} - {% set park_dz = client.custom_park_dz|default(2.0)|abs %} - {% set sp_hop = client.speed_hop|default(15) * 60 %} - {% set sp_move = client.speed_move|default(velocity) * 60 %} - ##### get config and toolhead values ##### - {% set origin = printer.gcode_move.homing_origin %} - {% set act = printer.gcode_move.gcode_position %} - {% set max = printer.toolhead.axis_maximum %} - {% set cone = printer.toolhead.cone_start_z|default(max.z) %} ; height as long the toolhead can reach max and min of an delta - {% set round_bed = True if printer.configfile.settings.printer.kinematics is in ['delta','polar','rotary_delta','winch'] - else False %} - ##### define park position ##### - {% set z_min = params.Z_MIN|default(0)|float %} - {% set z_park = [[(act.z + park_dz), z_min]|max, (max.z - origin.z)]|min %} - {% set x_park = params.X if params.X is defined - else custom_park_x if use_custom - else 0.0 if round_bed - else (max.x - 5.0) %} - {% set y_park = params.Y if params.Y is defined - else custom_park_y if use_custom - else (max.y - 5.0) if round_bed and z_park < cone - else 0.0 if round_bed - else (max.y - 5.0) %} - ##### end of definitions ##### - _CLIENT_RETRACT - {% if "xyz" in printer.toolhead.homed_axes %} - G90 - G1 Z{z_park} F{sp_hop} - G1 X{x_park} F{sp_move} - G1 X{x_park} Y{y_park} F{sp_move} - {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} - {% else %} - RESPOND TYPE=echo MSG='Printer not homed' - {% endif %} - -[gcode_macro _CLIENT_EXTRUDE] -description: Extrudes, if the extruder is hot enough -gcode: - ##### get user parameters or use default ##### - {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} - {% set use_fw_retract = (client.use_fw_retract|default(false)|lower == 'true') and (printer.firmware_retraction is defined) %} - {% set length = params.LENGTH|default(client.unretract)|default(1.0)|float %} - {% set speed = params.SPEED|default(client.speed_unretract)|default(35) %} - {% set absolute_extrude = printer.gcode_move.absolute_extrude %} - ##### end of definitions ##### - {% if printer.toolhead.extruder != '' %} - {% if printer[printer.toolhead.extruder].can_extrude %} - {% if use_fw_retract %} - {% if length < 0 %} - G10 - {% else %} - G11 - {% endif %} - {% else %} - M83 - G1 E{length} F{(speed|float|abs) * 60} - {% if absolute_extrude %} - M82 - {% endif %} - {% endif %} - {% else %} - RESPOND TYPE=echo MSG='{"\"%s\" not hot enough" % printer.toolhead.extruder}' - {% endif %} - {% endif %} - -[gcode_macro _CLIENT_RETRACT] -description: Retracts, if the extruder is hot enough -gcode: - {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} - {% set length = params.LENGTH|default(client.retract)|default(1.0)|float %} - {% set speed = params.SPEED|default(client.speed_retract)|default(35) %} - - _CLIENT_EXTRUDE LENGTH=-{length|float|abs} SPEED={speed|float|abs} - -[gcode_macro _CLIENT_LINEAR_MOVE] -description: Linear move with save and restore of the gcode state -gcode: - {% set x_move = "X" ~ params.X if params.X is defined else "" %} - {% set y_move = "Y" ~ params.Y if params.Y is defined else "" %} - {% set z_move = "Z" ~ params.Z if params.Z is defined else "" %} - {% set e_move = "E" ~ params.E if params.E is defined else "" %} - {% set rate = "F" ~ params.F if params.F is defined else "" %} - {% set ABSOLUTE = params.ABSOLUTE | default(0) | int != 0 %} - {% set ABSOLUTE_E = params.ABSOLUTE_E | default(0) | int != 0 %} - SAVE_GCODE_STATE NAME=_client_movement - {% if x_move or y_move or z_move %} - G9{ 0 if ABSOLUTE else 1 } - {% endif %} - {% if e_move %} - M8{ 2 if ABSOLUTE_E else 3 } - {% endif %} - G1 { x_move } { y_move } { z_move } { e_move } { rate } - RESTORE_GCODE_STATE NAME=_client_movement From 01f4a9be2f748eb425f640f3849efca34f6e80d6 Mon Sep 17 00:00:00 2001 From: Atomique13 Date: Thu, 21 May 2026 20:25:50 -0400 Subject: [PATCH 4/5] Refactor calibration process to replace M729 with CLEAN_NOZZLE and update BED_MESH_CALIBRATE command for improved accuracy --- meta-opencentauri/recipes-apps/klipper/files/calibration.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meta-opencentauri/recipes-apps/klipper/files/calibration.cfg b/meta-opencentauri/recipes-apps/klipper/files/calibration.cfg index 05cec51c..12d8afb5 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/calibration.cfg +++ b/meta-opencentauri/recipes-apps/klipper/files/calibration.cfg @@ -127,13 +127,13 @@ gcode: SET_DISPLAY_TEXT MSG="Performing extruder PID calibration" MOVE_TO_TRAY PID_CALIBRATE HEATER=extruder TARGET={hotend_temperature} - M729 + CLEAN_NOZZLE M400 SET_DISPLAY_TEXT MSG="Performing probe z-offset & bed mesh calibration" G90 G1 X128 Y128 F6000 - BED_MESH_CALIBRATE_WITH_WIPE BED_TEMP={bed_temperature} + BED_MESH_CALIBRATE BED_TEMP={bed_temperature} SET_DISPLAY_TEXT MSG="Performing shaper calibration" RUN_SHELL_COMMAND CMD=CAMERA_STOP From e110405f7c51e06389a526b143e4e912fabf6ec0 Mon Sep 17 00:00:00 2001 From: Atomique13 Date: Sat, 23 May 2026 05:20:17 -0400 Subject: [PATCH 5/5] Update Klipper configuration files: increment version to 0.0.7, adjust runout distance, and enhance macros for improved functionality --- .../recipes-apps/klipper/files/klipper-init-d | 2 +- .../recipes-apps/klipper/files/machine.cfg | 8 +-- .../recipes-apps/klipper/files/macros.cfg | 51 ++++++++++--------- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/meta-opencentauri/recipes-apps/klipper/files/klipper-init-d b/meta-opencentauri/recipes-apps/klipper/files/klipper-init-d index 14bc2a73..ddfe4d0f 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/klipper-init-d +++ b/meta-opencentauri/recipes-apps/klipper/files/klipper-init-d @@ -13,7 +13,7 @@ KLIPPER_PRINTER_CONFIG="/etc/klipper/config/printer.cfg" KLIPPY_ARGS="-O /usr/share/klipper/klippy/klippy.py $KLIPPER_PRINTER_CONFIG -l /board-resource/klippy.log -a /run/klippy.sock" PIDFILE="/var/run/klipper.pid" KLIPPER_VAR_CONFIG_BUILDER="/usr/bin/build-klipper-var-config" -KLIPPER_CONFIG_VERSION="0.0.6" +KLIPPER_CONFIG_VERSION="0.0.7" KLIPPER_CONFIG_VERSION_FILE="/etc/klipper-config.ver" KLIPPER_CONFIG_BACKUP_DIR="/etc/klipper/config/config_backups" diff --git a/meta-opencentauri/recipes-apps/klipper/files/machine.cfg b/meta-opencentauri/recipes-apps/klipper/files/machine.cfg index 7d782109..84f52b54 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/machine.cfg +++ b/meta-opencentauri/recipes-apps/klipper/files/machine.cfg @@ -24,6 +24,7 @@ max_velocity: 500 max_accel: 20000 max_z_velocity: 20 max_z_accel: 500 +square_corner_velocity: 9 # kinematics: limited_corexy # max_x_accel:10000 @@ -299,12 +300,12 @@ gain: A-128 switch_pin: PC0 pause_on_runout: false debounce_delay: 1 -runout_distance: 800 +runout_distance: 770 runout_gcode: RESPOND TYPE=echo MSG="Refill filament" PAUSE STATE=runout immediate_runout_gcode: - RESPOND TYPE=echo MSG="Ran out of filament" + RESPOND TYPE=echo MSG="Ran out of filament, using remaining filament in PTFE" insert_gcode: RESPOND TYPE=echo MSG="Filament is inserted" @@ -337,11 +338,12 @@ sensor_mcu: hotend sensor_type: temperature_mcu sensor_mcu: bed + [temperature_fan mainboard] pin: PG16 tachometer_pin: PG6 min_temp: 5 -max_temp: 85 +max_temp: 80 target_temp: 60 min_speed: 0 sensor_type: temperature_host diff --git a/meta-opencentauri/recipes-apps/klipper/files/macros.cfg b/meta-opencentauri/recipes-apps/klipper/files/macros.cfg index a1bf5b56..633acef2 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/macros.cfg +++ b/meta-opencentauri/recipes-apps/klipper/files/macros.cfg @@ -8,11 +8,11 @@ variable_target_extruder: 0 variable_pause_park:{'x': 10, 'y': 240, 'z': 10, 'e': 2} variable_cancel_park:{'x': 240, 'y': 240, 'z': 10, 'e': 5} variable_extruder_temp:{'probing': 140, 'cleaning': 180, 'loading': 230, 'purging': 250} -variable_z_maximum_lifting_distance: 250 +variable_z_maximum_lifting_distance: 256 variable_pause_resume_travel_speed: 150 -variable_heatsoak: 0 +variable_heatsoak: 1 variable_adaptive_mesh: False -variable_adaptive_purge: False +variable_adaptive_purge: True gcode: @@ -26,11 +26,11 @@ gcode: SET_GCODE_VARIABLE MACRO=_global_var VARIABLE=target_extruder VALUE={target_extruder} - ALL_FANS_OFF + TURN_OFF_FANS BED_MESH_CLEAR CLEAR_PAUSE G90 - SET_DISPLAY_TEXT MSG="Bed: {target_bed}c" + #SET_DISPLAY_TEXT MSG="Bed: {target_bed}c" M140 S{target_bed} G28 {% if sensor.enabled and not sensor.filament_detected %} @@ -72,12 +72,13 @@ gcode: SMART_PARK {% endif %} - SET_DISPLAY_TEXT MSG="Hotend: {target_extruder}c" + #SET_DISPLAY_TEXT MSG="Hotend: {target_extruder}c" M109 S{target_extruder} {% if svar.adaptive_purge %} LINE_PURGE {% endif %} - SET_DISPLAY_TEXT MSG="Printer goes brr" + SET_TEMPERATURE_FAN_TARGET temperature_fan=mainboard TARGET=30 + #_TEXT MSG="Printer goes brr" G90 [gcode_macro PRINT_END] @@ -104,7 +105,7 @@ gcode: G90 G1 X240 Y240 F9000 {% endif %} - ALL_FANS_OFF + TURN_OFF_FANS TURN_OFF_HEATERS M220 S100 M221 S100 @@ -137,7 +138,7 @@ gcode: {% endif %} {% endif %} - {%if (printer.gcode_move.position.z + 10) < z_lift_max %} + {% if (printer.gcode_move.position.z + 10) < z_lift_max %} G1 Z+10 F3000 {% else %} G1 Z+{(z_lift_max - printer.gcode_move.position.z)} F3000 @@ -145,14 +146,14 @@ gcode: G90 G1 X{x_park} Y{y_park} F9000 {% endif %} - ALL_FANS_OFF + TURN_OFF_FANS TURN_OFF_HEATERS M220 S100 M221 S100 CLEAR_PAUSE M84 SET_GCODE_VARIABLE MACRO=_global_var VARIABLE=target_extruder VALUE=0 - SET_DISPLAY_TEXT MSG="Cancel Print Success!" + #SET_DISPLAY_TEXT MSG="Cancel Print Success!" [gcode_macro PAUSE] rename_existing: PAUSE_BASE @@ -252,7 +253,7 @@ gcode: G91 G1 E{e_retract} F300 G90 - SET_DISPLAY_TEXT MSG="Resuming" + #SET_DISPLAY_TEXT MSG="Resuming" RESUME_BASE @@ -271,7 +272,7 @@ gcode: # Purge filament (8 cycles) G92 E0 ; Reset extruder position - M106 S0 ; Turn on part cooling fan (full speed) + M106 S0 ; Turn off part cooling fan (full speed) {% for purge in range(4) %} G1 E25 F300 ; Extrude 13mm at medium speed G1 E10 F150 ; Extrude 2mm slowly (ensure flow) @@ -308,7 +309,7 @@ gcode: # Move to tray MOVE_TO_TRAY - SET_DISPLAY_TEXT MSG="Cleaning nozzle: {svar.extruder_temp.cleaning}c" + #SET_DISPLAY_TEXT MSG="Cleaning nozzle: {svar.extruder_temp.cleaning}c" M104 S{svar.extruder_temp.cleaning} TEMPERATURE_WAIT SENSOR=extruder MINIMUM={svar.extruder_temp.cleaning} MAXIMUM={svar.extruder_temp.cleaning+5} M104 S{svar.extruder_temp.probing} @@ -396,7 +397,7 @@ gcode: MOVE_TO_TRAY ; Move to the tray M104 S{svar.extruder_temp.loading} TEMPERATURE_WAIT SENSOR=extruder MINIMUM={svar.extruder_temp.loading} MAXIMUM={svar.extruder_temp.loading+5} - M107 ; Turn on part cooling fan (full speed) + M107 ; Turn off part cooling fan (full speed) RESPOND TYPE=command MSG="action:prompt_begin Load Filament" RESPOND TYPE=command MSG="action:prompt_text Insert filament all the way into extruder before continuing" RESPOND TYPE=command MSG="action:prompt_footer_button LOAD|_LOAD_FILAMENT_STEP_PUSH" @@ -484,10 +485,10 @@ gcode: CLEAN_NOZZLE M190 S{bed_temp} M104 S{svar.extruder_temp.probing} - G4 S60000 + G4 P60000 LOADCELL_Z_HOME M109 S{svar.extruder_temp.probing} - ALL_FANS_OFF + TURN_OFF_FANS BED_MESH_CALIBRATE_BASE [gcode_macro SCREWS_TILT_CALCULATE] @@ -512,20 +513,22 @@ gcode: [gcode_macro _IDLE_TIMEOUT] gcode: {% if printer.print_stats.state == "paused" %} - SET_DISPLAY_TEXT MSG="PAUSED" + RESPOND MSG="PAUSED" {% else %} M84 TURN_OFF_HEATERS - ALL_FANS_OFF - SET_DISPLAY_TEXT MSG="No operations in 30mins!" + TURN_OFF_FANS + RESPOND MSG="Idle timeout reached, turning off heaters and fans!" + {% endif %} {% endif %} -[gcode_macro ALL_FANS_OFF] +[gcode_macro TURN_OFF_FANS] gcode: M107 SET_FAN_SPEED FAN=aux_fan SPEED=0 SET_FAN_SPEED FAN=case_fan SPEED=0 - SET_DISPLAY_TEXT MSG="ALL FANS OFF!" + SET_TEMPERATURE_FAN_TARGET temperature_fan=mainboard + RESPOND MSG="ALL FANS OFF!" [gcode_macro M600] gcode: @@ -563,10 +566,10 @@ gcode: [gcode_macro M729] gcode: - SET_DISPLAY_TEXT MSG="USE COSMOS GCODE!" + SET_DISPLAY_TEXT MSG="Use COSMOS start/end machine gcode" M112 [gcode_macro M8213] gcode: - SET_DISPLAY_TEXT MSG="USE COSMOS GCODE!" + SET_DISPLAY_TEXT MSG="Use COSMOS start/end machine gcode" M112 \ No newline at end of file