commit f6d6c47f8f51a80028f19f36e92f18c5d872ee8b Author: Martyn Date: Fri Jul 26 15:56:11 2024 +0100 initial repo setup, backdated diff --git a/bedfans.cfg b/bedfans.cfg new file mode 100644 index 0000000..267900c --- /dev/null +++ b/bedfans.cfg @@ -0,0 +1,126 @@ +############### Config options ################## + +[gcode_macro _BEDFANVARS] +variable_threshold: 100 # If bed temp target is above this threshold, fans will be enabled. If temp is set to below this threshold, fans will be disabled. +variable_fast: 0.6 # Fan speed once bed temp is reached +variable_slow: 0.2 # Fan speed while bed is heating +gcode: + +########## Bed Fans ######### + +[fan_generic BedFans] +pin: PB11 +#cycle_time: 0.05 +kick_start_time: 0.5 + +########## Aliases ######### + +[gcode_macro BEDFANSSLOW] +gcode: + # Vars + {% set SLOW = printer["gcode_macro _BEDFANVARS"].slow|float %} + + SET_FAN_SPEED FAN=BedFans SPEED={SLOW} + +[gcode_macro BEDFANSFAST] +gcode: + # Vars + {% set FAST = printer["gcode_macro _BEDFANVARS"].fast|float %} + + SET_FAN_SPEED FAN=BedFans SPEED={FAST} + +[gcode_macro BEDFANSOFF] +gcode: + SET_FAN_SPEED FAN=BedFans SPEED=0 + +############ Command overrides ############ + +# Override, set fan speeds to low and start monitoring loop. +[gcode_macro SET_HEATER_TEMPERATURE] +rename_existing: _SET_HEATER_TEMPERATURE +gcode: + # Parameters + {% set HEATER = params.HEATER|default("None") %} + {% set TARGET = params.TARGET|default(0)|int %} + # Vars + {% set THRESHOLD = printer["gcode_macro _BEDFANVARS"].threshold|int %} + + {% if HEATER|lower == "extruder" %} + M104 S{TARGET} + {% elif HEATER|lower == "heater_bed" %} + M99140 S{TARGET} + {% else %} + {action_respond_info("Heater %s not supported" % HEATER)} + {% endif %} + + # Set fans to low if heater_bed temp is requested above threshold temp, and kick off monitoring loop. + {% if HEATER|lower == "heater_bed" %} + {% if TARGET >= THRESHOLD %} + BEDFANSSLOW + UPDATE_DELAYED_GCODE ID=bedfanloop DURATION=1 + {% else %} + BEDFANSOFF + UPDATE_DELAYED_GCODE ID=bedfanloop DURATION=0 # Cancel bed fan loop if it's running + {% endif %} + {% endif %} + +# Override M190 (Wait for Bed Temperature) +# As a bonus, use TEMPERATURE_WAIT so we don't have to wait for PID to level off. +[gcode_macro M190] +rename_existing: M99190 +gcode: + # Parameters + {% set S = params.S|int %} + # Vars + {% set THRESHOLD = printer["gcode_macro _BEDFANVARS"].threshold|int %} + + {% if S >= THRESHOLD %} + BEDFANSSLOW # >= Threshold temp: Low speed fans while heating + {% else %} + BEDFANSOFF # < Threshold temp: Turn bed fans off + {% endif %} + + M140 {% for p in params + %}{'%s%s' % (p, params[p])}{% + endfor %} # Set bed temp + + {% if S != 0 %} + TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={S|int} MAXIMUM={S|int + 5} # Wait for bed temp within 5 degrees + {% endif %} + + # Post-heating fan speeds + {% if S >= THRESHOLD %} + BEDFANSFAST # >= Threshold temp: Higher speed fans after heating finished + {% endif %} + +# Replace M140 (Set Bed Temperature) to just be an alias of SET_HEATER_TEMPERATURE (which has associated bed fan logic if enabled) +[gcode_macro M140] +rename_existing: M99140 +gcode: + # Parameters + {% set S = params.S|float %} + + SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={S} + +# Replace TURN_OFF_HEATERS +[gcode_macro TURN_OFF_HEATERS] +rename_existing: _TURN_OFF_HEATERS +gcode: + BEDFANSOFF + _TURN_OFF_HEATERS + +################ Monitoring loop ##################### + +# Turns bed fans to "fast" speed once target bed temp is reached. +[delayed_gcode bedfanloop] +gcode: + # Vars + {% set THRESHOLD = printer["gcode_macro _BEDFANVARS"].threshold|int %} + + {% if printer.heater_bed.target >= THRESHOLD %} # Continue only if target temp greater than threshold. + {% if printer.heater_bed.temperature|int >= (printer.heater_bed.target|int - 1) %} + BEDFANSFAST # If within 1 degree of target temp: Higher speed fans + {% else %} + UPDATE_DELAYED_GCODE ID=bedfanloop DURATION=5 # If temp not reached yet: loop again + {% endif %} + {% endif %} diff --git a/crowsnest.conf b/crowsnest.conf new file mode 100644 index 0000000..b51c5a2 --- /dev/null +++ b/crowsnest.conf @@ -0,0 +1,47 @@ +#### crowsnest.conf +#### This is a typical default config. +#### Also used as default in mainsail / MainsailOS +#### See: +#### https://github.com/mainsail-crew/crowsnest/blob/master/README.md +#### for details to configure to your needs. + + +##################################################################### +#### ##### +#### Information about ports and according URL's ##### +#### ##### +##################################################################### +#### ##### +#### Port 8080 equals /webcam/?action=[stream/snapshot] ##### +#### Port 8081 equals /webcam2/?action=[stream/snapshot] ##### +#### Port 8082 equals /webcam3/?action=[stream/snapshot] ##### +#### Port 8083 equals /webcam4/?action=[stream/snapshot] ##### +#### ##### +#### Note: These ports are default for most Mainsail ##### +#### installations. To use any other port would involve ##### +#### changing the proxy configuration or using directly ##### +#### http://:/?action=[stream/snapshot] ##### +#### ##### +##################################################################### +#### RTSP Stream URL: ( if enabled and supported ) ##### +#### rtsp://:/stream.h264 ##### +##################################################################### + + +[crowsnest] +log_path: /home/pi/printer_data/logs/crowsnest.log +log_level: verbose # Valid Options are quiet/verbose/debug +delete_log: false # Deletes log on every restart, if set to true +no_proxy: false + +[cam 1] +mode: ustreamer # ustreamer - Provides mjpg and snapshots. (All devices) + # camera-streamer - Provides webrtc, mjpg and snapshots. (rpi + Raspi OS based only) +enable_rtsp: false # If camera-streamer is used, this enables also usage of an rtsp server +rtsp_port: 8554 # Set different ports for each device! +port: 8080 # HTTP/MJPG Stream/Snapshot Port +device: /dev/video0 # See Log for available ... +resolution: 640x480 # widthxheight format +max_fps: 15 # If Hardware Supports this it will be forced, otherwise ignored/coerced. +#custom_flags: # You can run the Stream Services with custom flags. +#v4l2ctl: # Add v4l2-ctl parameters to setup your camera, see Log what your cam is capable of. diff --git a/ebb36.cfg b/ebb36.cfg new file mode 100644 index 0000000..632656a --- /dev/null +++ b/ebb36.cfg @@ -0,0 +1,129 @@ +[mcu ebb36] +canbus_uuid: 856855c0f065 + +[temperature_sensor ebb36] +sensor_type: temperature_mcu +sensor_mcu: ebb36 +min_temp: 0 +max_temp: 100 + +[adxl345] +cs_pin: ebb36: PB12 +spi_software_sclk_pin: ebb36: PB10 +spi_software_mosi_pin: ebb36: PB11 +spi_software_miso_pin: ebb36: PB2 +axes_map: x,y,z + +##################################################################### +# Extruder +##################################################################### + +## Connected to MOTOR_6 +## Heater - HE0 +## Thermistor - T0 +[extruder] +step_pin: ebb36: PD0 +dir_pin: ebb36: PD1 +enable_pin: !ebb36: PD2 +## Update value below when you perform extruder calibration +## If you ask for 100mm of filament, but in reality it is 98mm: +## rotation_distance = * / 100 +## 22.6789511 is a good starting point +#rotation_distance: 22.6789511 #Bondtech 5mm Drive Gears +# 101/100 +rotation_distance: 22.905740611 +## Update Gear Ratio depending on your Extruder Type +## Use 50:10 for Stealthburner/Clockwork 2 +## Use 50:17 for Afterburner/Clockwork (BMG Gear Ratio) +## Use 80:20 for M4, M3.1 +gear_ratio: 50:10 #BMG Gear Ratio +microsteps: 16 +full_steps_per_rotation: 200 #200 for 1.8 degree, 400 for 0.9 degree +nozzle_diameter: 0.400 +filament_diameter: 1.75 +heater_pin: ebb36: PB13 +## Check what thermistor type you have. See https://www.klipper3d.org/Config_Reference.html#common-thermistors for common thermistor types. +## Use "Generic 3950" for NTC 100k 3950 thermistors +sensor_type: ATC Semitec 104NT-4-R025H42G +sensor_pin: ebb36: PA3 +min_temp: 10 +max_temp: 295 +max_power: 1.0 +min_extrude_temp: 170 +control = pid +pid_kp = 26.213 +pid_ki = 1.304 +pid_kd = 131.721 +max_extrude_only_distance = 101 +## Try to keep pressure_advance below 1.0 +#pressure_advance: 0.05 +## Default is 0.040, leave stock +#pressure_advance_smooth_time: 0.040 + +## E0 on MOTOR6 +## Make sure to update below for your relevant driver (2208 or 2209) +[tmc2209 extruder] +uart_pin: ebb36: PA15 +interpolate: false +run_current: 0.5 +sense_resistor: 0.110 +stealthchop_threshold: 0 + +[fan] +kick_start_time: 0.5 +pin: ebb36: PA1 + +[heater_fan hotend_fan] +pin: ebb36: PA0 +max_power: 1.0 +kick_start_time: 0.5 +heater: extruder +heater_temp: 50.0 +## If you are experiencing back flow, you can reduce fan_speed +#fan_speed: 1.0 + +[neopixel sb_leds] +pin: ebb36:PD3 +chain_count: 3 +# The number of Neopixel chips that are "daisy chained" to the +# provided pin. The default is 1 (which indicates only a single +# Neopixel is connected to the pin). +color_order: GRBW +# Set the pixel order required by the LED hardware. Options are GRB, +# RGB, GRBW, or RGBW. The default is GRB. +initial_RED: 0.0 +initial_GREEN: 0.0 +initial_BLUE: 0.0 +initial_WHITE: 0.0 + +##################################################################### +# Probe +##################################################################### + +## Inductive Probe +## This probe is not used for Z height, only Quad Gantry Leveling +# moved to printer.cfg so I can save from the interface. +# [probe] +# pin: ebb36:PB8 +# x_offset: 0 +# y_offset: 19.75 +# z_offset: 5.930 +# # below is default, trying -0.365 measured, if +0.365, it's 6.785 +# # z_offset: 6.42 +# speed: 5 +# samples: 3 +# samples_result: median +# sample_retract_dist: 2.0 +# samples_tolerance: 0.01 +# samples_tolerance_retries: 3 + +[adxl345] +cs_pin: ebb36:PB12 +spi_software_sclk_pin: ebb36:PB10 +spi_software_mosi_pin: ebb36:PB11 +spi_software_miso_pin: ebb36:PB2 +axes_map: x,y,z + +[resonance_tester] +accel_chip: adxl345 +probe_points: 175,175,15 \ No newline at end of file diff --git a/fluidd.cfg b/fluidd.cfg new file mode 120000 index 0000000..a825998 --- /dev/null +++ b/fluidd.cfg @@ -0,0 +1 @@ +/home/pi/fluidd-config/client.cfg \ No newline at end of file diff --git a/klicky-bed-mesh-calibrate.cfg b/klicky-bed-mesh-calibrate.cfg new file mode 100644 index 0000000..8bc2477 --- /dev/null +++ b/klicky-bed-mesh-calibrate.cfg @@ -0,0 +1,32 @@ +# This macro was provided by discord user Garrettwp to whom i give my thanks for sharing it with me. +# I have tweaked it a lot. +# They are based on the great Annex magprobe dockable probe macros "#Originally developed by Mental, +# modified for better use on K-series printers by RyanG and Trails", kudos to them. +# That macro as since evolved into a klipper plugin that currently is pending inclusion in klipper, +# more information here, https://github.com/Annex-Engineering/Quickdraw_Probe/tree/main/Klipper_Macros +# User richardjm revised the macro variables and added some functions, thanks a lot +# by standing on the shoulders of giants, lets see if we can see further +# +# the current home for this version is https://github.com/jlas1/Klicky-Probe + +################### +# Bed mesh calibrate +[gcode_macro BED_MESH_CALIBRATE] +rename_existing: _BED_MESH_CALIBRATE +description: Perform Mesh Bed Leveling with klicky automount +gcode: + {% set V = printer["gcode_macro _User_Variables"].verbose %} + {% if V %} + { action_respond_info("Bed Mesh Calibrate") } + {% endif %} + + _CheckProbe action=query + G90 + Attach_Probe + _KLICKY_STATUS_MESHING + + _BED_MESH_CALIBRATE {% for p in params + %}{'%s=%s ' % (p, params[p])}{% + endfor %} + + Dock_Probe \ No newline at end of file diff --git a/klicky-macros.cfg b/klicky-macros.cfg new file mode 100644 index 0000000..7906163 --- /dev/null +++ b/klicky-macros.cfg @@ -0,0 +1,990 @@ +# This macro was provided by discord user Garrettwp to whom i give my thanks for sharing it with me. +# I have tweaked it a lot. +# They are based on the great Annex magprobe dockable probe macros "#Originally developed by Mental, +# modified for better use on K-series printers by RyanG and Trails", kudos to them. +# That macro as since evolved into a klipper plugin that currently is pending inclusion in klipper, +# more information here, https://github.com/Annex-Engineering/Quickdraw_Probe/tree/main/Klipper_Macros +# User richardjm revised the macro variables and added some functions +# User sporkus added led status notifications +# Thanks to all who helped, +# by standing on the shoulders of giants, lets see if we can see further +# +# the current home for this version is https://github.com/jlas1/Klicky-Probe + +[respond] + +[gcode_macro _Probe_Variables] +variable_probe_attached: False +variable_probe_state: False +variable_probe_lock: False +variable_probe_z_homed: False +variable_z_endstop_x: 0 +variable_z_endstop_y: 0 +gcode: + + +#checks if the variable definitions are up to date +[gcode_macro _klicky_check_variables_version] +gcode: + {% set version = printer["gcode_macro _User_Variables"].version|default(0) %} + + {% if version != 1 %} + { action_raise_error("Please update your klicky variables, there are some functionality changes") } + {% endif %} + +[gcode_macro _KlickyDebug] +gcode: + {% set message = params.MSG %} + {% set debug = printer["gcode_macro _User_Variables"].debug|default(False) %} + + {% if debug %} + { action_respond_info(message) } + {% endif %} + + +[gcode_macro _exit_point] +gcode: + {% set function = 'pre_' ~ params.FUNCTION %} + {% set move = params.MOVE|default(0) %} + {% set speed = printer["gcode_macro _User_Variables"].travel_speed %} + + # mandatory to save the new safe position + M400 + SET_VELOCITY_LIMIT ACCEL={printer.configfile.settings.printer.max_accel} + RESTORE_GCODE_STATE NAME={function} MOVE={move} MOVE_SPEED={speed} + + +[gcode_macro _entry_point] +gcode: + {% set function = 'pre_' ~ params.FUNCTION %} + {% set move_accel = printer["gcode_macro _User_Variables"].move_accel|default(1000) %} + # mandatory to save the new safe position + M400 + SAVE_GCODE_STATE NAME={function} + # removes the Z offset for better bed based docking + SET_GCODE_OFFSET Z=0 + # all the macros initially assume absolute positioning + G90 + # set a safe(sane) Acceleration + SET_VELOCITY_LIMIT ACCEL={move_accel} + +[gcode_macro _Homing_Variables] +gcode: + {% set reset = params.RESET|default(0) %} + {% if reset %} + SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_lock VALUE={ False } + {% endif %} + +########################## +# Attach probe and lock it +[gcode_macro Attach_Probe_Lock] +description: Attaches Klicky Probe, can only be docked after unlocking +gcode: + Attach_Probe + _Probe_Lock + +######################## +# Dock probe and lock it +[gcode_macro Dock_Probe_Unlock] +description: Docks Klicky Probe even if it was locked +gcode: + _Probe_Unlock + Dock_Probe + +############## +# Unlock Probe +[gcode_macro _Probe_Unlock] +description: Unlocks Klicky Probe state +gcode: + _KlickyDebug msg="_Probe_Lock setting probe_lock variable to False" + SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_lock VALUE={ False } + +############ +# Lock Probe +[gcode_macro _Probe_Lock] +description: Locks Klicky Probe state +gcode: + _KlickyDebug msg="_Probe_Lock setting probe_lock variable to True" + SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_lock VALUE={ True } + +################### +# Klicky Dock Servo Deploy + +[gcode_macro _DeployKlickyDock] +description: Deploys Klicky servo-controlled dock +gcode: + {% set enable_dock_servo = printer["gcode_macro _User_Variables"].enable_dock_servo|default(False) %} + {% set servo_delay = printer["gcode_macro _User_Variables"].servo_delay|default(1000) %} + {% set servo_name = printer["gcode_macro _User_Variables"].servo_name %} + {% set servo_deploy = printer["gcode_macro _User_Variables"].servo_deploy|default(360) %} + + #wait for all the moves to complete + M400 + {% if enable_dock_servo != False %} + _KlickyDebug msg="_DeployKlickyDock Klicky servo configuration enabled" + {% if servo_deploy == 360 %} + { action_raise_error("Klicky: servo active on klicky-variables, but no servo deploy angle specified") } + {% endif %} + _KlickyDebug msg="_DeployKlickyDock SET_SERVO SERVO={servo_name|string} ANGLE={servo_deploy|int}" + SET_SERVO SERVO={servo_name|string} ANGLE={servo_deploy|int} + M400 + G4 P{servo_delay|int} + _KlickyDebug msg="_DeployKlickyDock SET_SERVO SERVO={servo_name|string} WIDTH=0" + SET_SERVO SERVO={servo_name|string} WIDTH=0 + {% elif printer["gcode_macro _DeployDock"] is defined %} + _KlickyDebug msg="_DeployKlickyDock calling _DeployDock" + _DeployDock + {% endif %} + +#################### +# Dock Servo Retract + +[gcode_macro _RetractKlickyDock] +description: Retracts Klicky servo-controlled dock +gcode: + {% set enable_dock_servo = printer["gcode_macro _User_Variables"].enable_dock_servo|default(False) %} + {% set servo_delay = printer["gcode_macro _User_Variables"].servo_delay|default(1000) %} + {% set servo_name = printer["gcode_macro _User_Variables"].servo_name %} + {% set servo_retract = printer["gcode_macro _User_Variables"].servo_retract|default(360) %} + + #wait for all the moves to complete + M400 + {% if enable_dock_servo != False %} + _KlickyDebug msg="_RetractKlickyDock Klicky servo configuration enabled" + {% if servo_retract == 360 %} + { action_raise_error("Klicky: servo active on klicky-variables, but no servo retract angle specified") } + {% endif %} + _KlickyDebug msg="_RetractKlickyDock SET_SERVO SERVO={servo_name|string} ANGLE={servo_retract|int}" + SET_SERVO SERVO={servo_name|string} ANGLE={servo_retract|int} + M400 + G4 P{servo_delay|int} + _KlickyDebug msg="_RetractKlickyDock SET_SERVO SERVO={servo_name|string} WIDTH=0" + SET_SERVO SERVO={servo_name|string} WIDTH=0 + {% elif printer["gcode_macro _RetractDock"] is defined %} + _KlickyDebug msg="_RetractKlickyDock calling _RetractDock" + _RetractDock + {% endif %} + + +###################### +# Attach Probe Routine +[gcode_macro Attach_Probe] +description: Attaches Klicky Probe +gcode: + # See if the position should be restored after the attach + {% set goback = params.BACK|default(0) %} + # Get probe attach status + {% set probe_attached = printer["gcode_macro _Probe_Variables"].probe_attached %} + {% set probe_lock = printer["gcode_macro _Probe_Variables"].probe_lock %} + {% set verbose = printer["gcode_macro _User_Variables"].verbose %} + # Get Docking location + {% set dockmove_x = printer["gcode_macro _User_Variables"].dockmove_x|default(0) %} + {% set dockmove_y = printer["gcode_macro _User_Variables"].dockmove_y|default(0) %} + {% set dockmove_z = printer["gcode_macro _User_Variables"].dockmove_z|default(0) %} + {% set docklocation_x = printer["gcode_macro _User_Variables"].docklocation_x %} + {% set docklocation_y = printer["gcode_macro _User_Variables"].docklocation_y %} + {% set docklocation_z = printer["gcode_macro _User_Variables"].docklocation_z %} + {% set attachmove_x = printer["gcode_macro _User_Variables"].attachmove_x|default(0) %} + {% set attachmove_y = printer["gcode_macro _User_Variables"].attachmove_y|default(0) %} + {% set attachmove_z = printer["gcode_macro _User_Variables"].attachmove_z|default(0) %} + {% set attachmove2_x = printer["gcode_macro _User_Variables"].attachmove2_x|default(0) %} + {% set attachmove2_y = printer["gcode_macro _User_Variables"].attachmove2_y|default(0) %} + {% set attachmove2_z = printer["gcode_macro _User_Variables"].attachmove2_z|default(0) %} + # Safe Z for travel + {% set safe_z = printer["gcode_macro _User_Variables"].safe_z %} + {% set enable_z_hop = printer["gcode_macro _User_Variables"].enable_z_hop %} + # Set feedrates + {% set travel_feedrate = printer["gcode_macro _User_Variables"].travel_speed * 60 %} + {% set dock_feedrate = printer["gcode_macro _User_Variables"].dock_speed * 60 %} + {% set release_feedrate = printer["gcode_macro _User_Variables"].release_speed * 60 %} + {% set z_drop_feedrate = printer["gcode_macro _User_Variables"].z_drop_speed * 60 %} + {% set bypass_probe_docking = printer["gcode_macro _User_Variables"].bypass_probe_docking|default(False) %} + + _entry_point function=Attach_Probe + + {% if bypass_probe_docking == False %} + + # If x and y are not homed + {% if not 'xy' in printer.toolhead.homed_axes %} + { action_raise_error("Must Home X and Y Axis First!") } + _KlickyDebug msg="Attach_Probe Axis homed" + + # If probe not attached and locked + {% elif not probe_attached and not probe_lock %} + _KlickyDebug msg="Attach_Probe going to attach probe" + {% if verbose %} + { action_respond_info("Attaching Probe") } + {% endif %} + _KLICKY_STATUS_BUSY + + {% if not 'z' in printer.toolhead.homed_axes %} + {% if verbose %} + { action_respond_info("Resetting Z position to zero") } + {% endif %} + _KlickyDebug msg="Attach_Probe Z not homed, setting position as X=Y=Z=0" + SET_KINEMATIC_POSITION Z=0 + {% if not enable_z_hop %} # Disables safe_z + _KlickyDebug msg="Attach_Probe z_hop disabled" + {% set safe_z = 0 %} + {% endif %} + {% endif %} + + # Prior to saving actual position, check if its necessary to move to a safe Z + # that has enought overhead for the attached probe + {% if printer.gcode_move.gcode_position.z < safe_z %} + _KlickyDebug msg="Attach_Probe toolhead too low, raising it to {safe_z}mm from {printer.gcode_move.gcode_position.z}mm" + {% if verbose %} + { action_respond_info("moving to a safe Z distance") } + {% endif %} + G0 Z{safe_z} F{z_drop_feedrate} + {% endif %} + + {% if not 'z' in printer.toolhead.homed_axes %} #duplicate?? + {% if verbose %} + { action_respond_info("Resetting Z position to zero, duplicate?") } + {% endif %} + _KlickyDebug msg="Attach_Probe Z not homed, setting position as X=Y=Z=0" + SET_KINEMATIC_POSITION Z=0 + {% endif %} + + {% if printer.gcode_move.gcode_position.z < safe_z %} #duplicate?? + _KlickyDebug msg="Attach_Probe toolhead too low, raising it to {safe_z}mm from {printer.gcode_move.gcode_position.z}mm" + G0 Z{safe_z} F{z_drop_feedrate} + {% endif %} + + _Umbilical_Path + + _entry_point function=Attach_Probe_intern + + # Probe entry location + _KlickyDebug msg="Attach_Probe moving near the dock with G0 X{docklocation_x|int - attachmove_x|int - attachmove2_x|int} Y{docklocation_y|int - attachmove_y|int - attachmove2_y} F{travel_feedrate}" + G0 X{docklocation_x|int - attachmove_x|int - attachmove2_x|int} Y{docklocation_y|int - attachmove_y|int - attachmove2_y} F{travel_feedrate} + {% if docklocation_z != -128 %} + _KlickyDebug msg="Attach_Probe moving near the dock with G0 Z{docklocation_z|int - attachmove_z|int - attachmove2_z|int} F{dock_feedrate}" + G0 Z{docklocation_z|int - attachmove_z|int - attachmove2_z|int} F{dock_feedrate} + _KlickyDebug msg="Attach_Probe moving near the dock with G0 Z{docklocation_z|int - attachmove_z|int} F{dock_feedrate}" + G0 Z{docklocation_z|int - attachmove_z|int} F{dock_feedrate} + {% endif %} + # if necessary do some actions before moving the toolhead to dock + _DeployKlickyDock + + # Drop Probe to Probe location + {% if docklocation_z != -128 %} + _KlickyDebug msg="Attach_Probe moving to the dock with G0 Z{docklocation_z} F{dock_feedrate}" + G0 Z{docklocation_z} F{dock_feedrate} + {% endif %} + _KlickyDebug msg="Attach_Probe moving to the dock with G0 X{docklocation_x|int - attachmove2_x|int} Y{docklocation_y|int - attachmove2_y} F{dock_feedrate}" + G0 X{docklocation_x|int - attachmove2_x|int} Y{docklocation_y|int - attachmove2_y} F{dock_feedrate} + _KlickyDebug msg="Attach_Probe moving to the dock with G0 X{docklocation_x} Y{docklocation_y} F{dock_feedrate}" + G0 X{docklocation_x} Y{docklocation_y} F{dock_feedrate} + # Probe Attached + {% if docklocation_z != -128 %} + _KlickyDebug msg="Attach_Probe moving from the dock to G0 Z{docklocation_z|int - attachmove_z|int} F{z_drop_feedrate}" + G0 Z{docklocation_z|int - attachmove_z|int} F{z_drop_feedrate} + {% endif %} + _KlickyDebug msg="Attach_Probe moving from the dock to G0 X{docklocation_x|int - attachmove_x|int} Y{docklocation_y|int - attachmove_y|int} F{release_feedrate}" + G0 X{docklocation_x|int - attachmove_x|int} Y{docklocation_y|int - attachmove_y|int} F{release_feedrate} + # if necessary do some actions after attaching the probe + _RetractKlickyDock + ## Go to Z safe distance + {% if ((printer.gcode_move.gcode_position.z < safe_z) or (docklocation_z != -128 and docklocation_z < safe_z ))%} + _KlickyDebug msg="Attach_Probe moving to a safe Z position: G0 Z{safe_z} F{z_drop_feedrate} from {printer.gcode_move.gcode_position.z}" + G0 Z{safe_z} F{z_drop_feedrate} + {% endif %} + + _Park_Toolhead + + _CheckProbe action=attach + + _exit_point function=Attach_Probe_intern move={goback} + _KLICKY_STATUS_READY + + {% elif probe_lock %} + {% if verbose %} + { action_respond_info("Probe locked!") } + {% endif %} + + # Probe attached, do nothing + _KlickyDebug msg="Attach_Probe probe locked not attaching probe" + _CheckProbe action=query + + {% else %} + {% if verbose %} + { action_respond_info("Probe already attached!") } + {% endif %} + + # Probe attached, do nothing + _KlickyDebug msg="Attach_Probe probe already attached, doing nothing" + _CheckProbe action=query + + {% endif %} + + _exit_point function=Attach_Probe + {% else %} + _KlickyDebug msg="Attach_Probe probe docking bypassed, doing nothing" + {% endif %} + + +#################### +# Dock Probe Routine +[gcode_macro Dock_Probe] +description: Docks Klicky Probe +gcode: + # See if the position should be restored after the dock + {% set goback = params.BACK|default(0) %} + # Get probe attach status + {% set probe_attached = printer["gcode_macro _Probe_Variables"].probe_attached %} + {% set probe_lock = printer["gcode_macro _Probe_Variables"].probe_lock %} + {% set verbose = printer["gcode_macro _User_Variables"].verbose %} + # Get Docking location + {% set dockmove_x = printer["gcode_macro _User_Variables"].dockmove_x|default(0) %} + {% set dockmove_y = printer["gcode_macro _User_Variables"].dockmove_y|default(0) %} + {% set dockmove_z = printer["gcode_macro _User_Variables"].dockmove_z|default(0) %} + {% set docklocation_x = printer["gcode_macro _User_Variables"].docklocation_x %} + {% set docklocation_y = printer["gcode_macro _User_Variables"].docklocation_y %} + {% set docklocation_z = printer["gcode_macro _User_Variables"].docklocation_z %} + {% set attachmove_x = printer["gcode_macro _User_Variables"].attachmove_x|default(0) %} + {% set attachmove_y = printer["gcode_macro _User_Variables"].attachmove_y|default(0) %} + {% set attachmove_z = printer["gcode_macro _User_Variables"].attachmove_z|default(0) %} + # Safe Z for travel + {% set safe_z = printer["gcode_macro _User_Variables"].safe_z|float %} + # Set feedrates + {% set travel_feedrate = printer["gcode_macro _User_Variables"].travel_speed * 60 %} + {% set dock_feedrate = printer["gcode_macro _User_Variables"].dock_speed * 60 %} + {% set release_feedrate = printer["gcode_macro _User_Variables"].release_speed * 60 %} + {% set z_drop_feedrate = printer["gcode_macro _User_Variables"].z_drop_speed * 60 %} + {% set bypass_probe_docking = printer["gcode_macro _User_Variables"].bypass_probe_docking|default(False) %} + {% if bypass_probe_docking == True %} + _KlickyDebug msg="Attach_Probe probe docking bypassed, doing nothing" + {% endif %} + + {% if bypass_probe_docking != True %} + _entry_point function=Dock_Probe + + # If probe not attached and not locked + {% if probe_attached and not probe_lock %} + _KLICKY_STATUS_BUSY + {% if printer.gcode_move.gcode_position.z < safe_z %} + _KlickyDebug msg="Dock_Probe toolhead too low, raising it to {safe_z}mm from {printer.gcode_move.gcode_position.z}mm" + G0 Z{safe_z} F{z_drop_feedrate} + {% endif %} + _Umbilical_Path + + # Probe entry location + _KlickyDebug msg="Dock_Probe moving near the dock with G0 X{docklocation_x|int - attachmove_x|int} Y{docklocation_y|int - attachmove_y|int} F{travel_feedrate}" + G0 X{docklocation_x|int - attachmove_x|int} Y{docklocation_y|int - attachmove_y|int} F{travel_feedrate} + + {% if docklocation_z != -128 %} + _KlickyDebug msg="Dock_Probe moving near the dock with G0 Z{docklocation_z|int - attachmove_z|int} F{dock_feedrate}" + G0 Z{docklocation_z|int - attachmove_z|int} F{dock_feedrate} + {% endif %} + + # if necessary do some actions before moving the toolhead to dock + _DeployKlickyDock + + # Drop Probe to Probe location + _KlickyDebug msg="Dock_Probe moving to the dock with G0 X{docklocation_x} Y{docklocation_y} F{dock_feedrate}" + + G0 X{docklocation_x} Y{docklocation_y} F{dock_feedrate} + {% if docklocation_z != -128 %} + _KlickyDebug msg="Attach_Probe moving to the dock with G0 Z{docklocation_z} F{dock_feedrate}" + G0 Z{docklocation_z} F{dock_feedrate} + {% endif %} + + # Probe decoupling + {% if docklocation_z != -128 %} + _KlickyDebug msg="Dock_Probe moving from the dock to G0 Z{docklocation_z|int + dockmove_z|int} F{release_feedrate}" + G0 Z{docklocation_z|int + dockmove_z|int} F{release_feedrate} + {% endif %} + + _KlickyDebug msg="Dock_Probe moving from the dock to G0 X{docklocation_x|int + dockmove_x|int} Y{docklocation_y|int + dockmove_y|int} F{release_feedrate}" + G0 X{docklocation_x|int + dockmove_x|int} Y{docklocation_y|int + dockmove_y|int} F{release_feedrate} + + # if necessary do some actions after attaching the probe + _RetractKlickyDock + + #Do an extra move away + _KlickyDebug msg="Dock_Probe moving away from the dock to G0 X{docklocation_x|int + dockmove_x|int - attachmove_x|int} Y{docklocation_y|int + dockmove_y|int - attachmove_y|int} F{release_feedrate}" + G0 X{docklocation_x|int + dockmove_x|int - attachmove_x|int} Y{docklocation_y|int + dockmove_y|int - attachmove_y|int} F{release_feedrate} + + ## Go to Z safe distance + {% if (printer.gcode_move.gcode_position.z < safe_z) %} + _KlickyDebug msg="Dock_Probe moving to a safe Z position: G0 Z{safe_z} F{z_drop_feedrate} from {printer.gcode_move.gcode_position.z}" + G0 Z{safe_z} F{z_drop_feedrate} + {% endif %} + + _Park_Toolhead + + G4 P1000 + _CheckProbe action=dock + _KLICKY_STATUS_READY + + {% elif probe_lock %} + {% if verbose %} + { action_respond_info("Probe locked") } + {% endif %} + + # Probe docked, do nothing + _KlickyDebug msg="Dock_Probe probe locked not docking probe" + _CheckProbe action=query + + {% else %} + {% if verbose %} + { action_respond_info("Probe already docked") } + {% endif %} + + # Probe docked, do nothing + _KlickyDebug msg="Dock_Probe probe already docked, doing nothing" + _CheckProbe action=query + + {% endif %} + + _exit_point function=Dock_Probe move={goback} + {% else %} + _KlickyDebug msg="Dock_Probe probe docking bypassed, doing nothing" + {% endif %} + + +################# +# Probe Calibrate +[gcode_macro PROBE_CALIBRATE] +rename_existing: _PROBE_CALIBRATE +description:Calibrate the probes z_offset with klicky automount +gcode: + {% set safe_z = printer["gcode_macro _User_Variables"].safe_z|float %} + {% set z_drop_feedrate = printer["gcode_macro _User_Variables"].z_drop_speed * 60 %} + {% set max_x = printer["gcode_macro _User_Variables"].max_bed_x|float %} + {% set max_y = printer["gcode_macro _User_Variables"].max_bed_y|float %} + {% set probe_offset_x = printer['configfile'].config["probe"]["x_offset"]|float %} + {% set probe_offset_y = printer['configfile'].config["probe"]["y_offset"]|float %} + {% set bypass_probe_docking = printer["gcode_macro _User_Variables"].bypass_probe_docking|default(False) %} + + + {% if not 'xyz' in printer.toolhead.homed_axes %} + { action_raise_error("Must Home X, Y and Z Axis First!") } + {% endif %} + _KlickyDebug msg="probe_calibrate Axis homed" + _KlickyDebug msg="probe_calibrate Variables max_x={max_x},max_y={max_y},probe_offset_x={probe_offset_x},probe_offset_y={probe_offset_y}" + + # Protect against PROBE CALIBRATE performed from outside the bed + {% if printer['gcode_move'].position.y > (max_y - probe_offset_y) + or printer['gcode_move'].position.y < - probe_offset_y + or printer['gcode_move'].position.x > (max_x - probe_offset_x) + or printer['gcode_move'].position.x < - probe_offset_x %} + { action_raise_error("Must perform PROBE_CALIBRATE with the probe above the BED, check klicky_variables bed size!") } + {% endif %} + + {% if bypass_probe_docking == False %} + _CheckProbe action=query + G90 + Attach_Probe back=1 + _KLICKY_STATUS_CALIBRATING_Z + + _KlickyDebug msg="probe_calibrate calling klipper probe_calibrate" + _PROBE_CALIBRATE {% for p in params + %}{'%s=%s ' % (p, params[p])}{% + endfor %} + + M118 moving the toolhead 20 mm from the bed + _KlickyDebug msg="probe_calibrate Moving Z up by 20mm" + TESTZ Z=20 + M118 remove manually the probe and continue calibration + _KLICKY_STATUS_READY + {% else %} + _KLICKY_STATUS_CALIBRATING_Z + _KlickyDebug msg="probe_calibrate calling klipper probe_calibrate" + _PROBE_CALIBRATE {% for p in params + %}{'%s=%s ' % (p, params[p])}{% + endfor %} + _KLICKY_STATUS_READY + {% endif %} + +################ +# Probe Accuracy +[gcode_macro PROBE_ACCURACY] +rename_existing: _PROBE_ACCURACY +description:Probe Z-height accuracy at current XY position with klicky automount +gcode: + {% set safe_z = printer["gcode_macro _User_Variables"].safe_z|float %} + {% set z_drop_feedrate = printer["gcode_macro _User_Variables"].z_drop_speed * 60 %} + {% set max_x = printer["gcode_macro _User_Variables"].max_bed_x|float %} + {% set max_y = printer["gcode_macro _User_Variables"].max_bed_y|float %} + {% set probe_offset_x = printer['configfile'].config["probe"]["x_offset"]|float %} + {% set probe_offset_y = printer['configfile'].config["probe"]["y_offset"]|float %} + + {% if not 'xyz' in printer.toolhead.homed_axes %} + { action_raise_error("Must Home X, Y and Z Axis First!") } + {% endif %} + _KlickyDebug msg="probe_accuracy Axis homed" + _KlickyDebug msg="probe_accuracy Variables max_x={max_x},max_y={max_y},probe_offset_x={probe_offset_x},probe_offset_y={probe_offset_y}" + + _entry_point function=PROBE_ACCURACY + + # Protect against PROBE_ACCURACY performed from outside the bed + {% if printer['gcode_move'].position.y > (max_y - probe_offset_y) + or printer['gcode_move'].position.y < - probe_offset_y + or printer['gcode_move'].position.x > (max_x - probe_offset_x) + or printer['gcode_move'].position.x < - probe_offset_x %} + { action_raise_error("Must perform PROBE_ACCURACY with the probe above the BED, check klicky_variables bed size!") } + {% endif%} + + _CheckProbe action=query + Attach_Probe back=1 + + _KlickyDebug msg="probe_accuracy calling klipper probe accuracy" + _PROBE_ACCURACY {% for p in params + %}{'%s=%s ' % (p, params[p])}{% + endfor %} + + Dock_Probe back=1 + + _exit_point function=PROBE_ACCURACY move=1 + +############################################# +# Enable to SET_KINEMATIC_POSITION for Z hop +[force_move] +enable_force_move: True + +################# +# Homing Override +[homing_override] +axes: xyz +gcode: + # collect user state variables + _User_Variables + {% set verbose = printer["gcode_macro _User_Variables"].verbose %} + {% set safe_z = printer["gcode_macro _User_Variables"].safe_z|float %} + # Safe Z for travel + {% set safe_z = printer["gcode_macro _User_Variables"].safe_z %} + {% set enable_z_hop = printer["gcode_macro _User_Variables"].enable_z_hop %} + {% set kinematic_z = 0 %} + {% set dock_on_zhome = printer["gcode_macro _User_Variables"].dock_on_zhome|default(True) %} + {% set attachmove_x = printer["gcode_macro _User_Variables"].attachmove_x|default(0) %} + {% set attachmove_y = printer["gcode_macro _User_Variables"].attachmove_y|default(0) %} + {% set attachmove_z = printer["gcode_macro _User_Variables"].attachmove_z|default(0) %} + {% set z_drop_feedrate = printer["gcode_macro _User_Variables"].z_drop_speed * 60 %} + {% set travel_feedrate = printer["gcode_macro _User_Variables"].travel_speed * 60 %} + {% set home_backoff_x = printer["gcode_macro _User_Variables"].home_backoff_x|default(0) %} + {% set home_backoff_y = printer["gcode_macro _User_Variables"].home_backoff_y|default(0) %} + {% set override_homing = printer["gcode_macro _User_Variables"].override_homing|default('') %} + + #checks if the variable definitions are up to date + _klicky_check_variables_version + + _CheckProbe action=query + + # reset parameters + {% set home_x, home_y, home_z, leave_probe_attached = False, False, False, False %} + + {% if 'PROBE_LOCK' in params%} + {% if verbose %} + { action_respond_info("PROBE_LOCK = True") } + {% endif %} + {% set leave_probe_attached = True %} + {% endif %} + + # which axes have been requested for homing + {% if not 'X' in params + and not 'Y' in params + and not 'Z' in params %} + + {% set home_x, home_y, home_z = True, True, True %} + _KlickyDebug msg="homing_override goint to home all axes" + + {% else %} + {% if 'X' in params %} + {% set home_x = True %} + _KlickyDebug msg="homing_override goint to home X" + + {% endif %} + + {% if 'Y' in params %} + {% set home_y = True %} + _KlickyDebug msg="homing_override goint to home Y" + {% endif %} + + {% if 'Z' in params %} + {% set home_z = True %} + _KlickyDebug msg="homing_override goint to home Z" + {% endif %} + + {% if 'X' in params + and 'Y' in params + and 'Z' in params %} + # reset homing state variables + # if homing all axes + _Homing_Variables reset=1 + _KlickyDebug msg="homing_override goint to home all axes" + {% endif %} + + {% endif %} + + _entry_point function=homing_override + _KLICKY_STATUS_HOMING + + # if Z is not homed, do not move the bed if it goes down + {% if 'z' not in printer.toolhead.homed_axes %} + {% if enable_z_hop == False %} # Disables safe_z + _KlickyDebug msg="homing_override z_hop disabled" + #preserve safe_z to use as the SET KINEMATIC Z position, so that the toolhead does not move to pick up the probe + {% set kinematic_z = safe_z %} + {% set safe_z = safe_z %} + {% endif %} + {% endif %} + + #On the first G28 after motors losing power, moves the Z to safe_z distance, if z_hop is enabled + {% if 'x' not in printer.toolhead.homed_axes and 'y' not in printer.toolhead.homed_axes and 'z' not in printer.toolhead.homed_axes%} + {% if verbose %} + { action_respond_info("No axis homed") } + {% endif %} + _KlickyDebug msg="homing_override no axis homed, setting position as X=Y=0 Z={kinematic_z}" + SET_KINEMATIC_POSITION X=0 Y=0 Z={kinematic_z} + M400 + _KlickyDebug msg="homing_override moving toolhead to {safe_z}mm from {printer.gcode_move.gcode_position.z}mm" + {% if verbose %} + { action_respond_info("moving to a safe Z distance") } + {% endif %} + G0 Z{safe_z} F{z_drop_feedrate} + {% if home_z != True %} + _KlickyDebug msg="homing_override clearing axis homed state if not already homing Z" + M84 + {% endif %} + {% else %} + _KlickyDebug msg="All axis homed" + {% set safe_z = printer.gcode_move.gcode_position.z|float %} + _KlickyDebug msg="Setting Safe_z to {printer.gcode_move.gcode_position.z}mm as Z is now above configured safe_z" + {% endif %} + + {% if home_z %} + {% if 'x' not in printer.toolhead.homed_axes and 'y' not in printer.toolhead.homed_axes%} + {% if verbose %} + { action_respond_info("X or Y not homed, forcing full G28") } + {% endif %} + {% set home_x, home_y, home_z = True, True, True %} + {% endif %} + {% endif %} + + # if the dock is oriented on the Y, first do Y endstop + {% if ((attachmove_y == 0 and override_homing == '' ) or (override_homing == 'Y'))%} + # Home y + {% if home_y %} + {% if override_homing == 'Y' %} + _KlickyDebug msg="homing_override Y homing first override, due to override_homing = Y" + {% else %} + _KlickyDebug msg="homing_override Y homing first override, due to attachmove_y = 0" + {% endif %} + {% if verbose %} + { action_respond_info("Homing Y") } + {% endif %} + {% if 'z' in printer.toolhead.homed_axes and printer.gcode_move.gcode_position.z < safe_z %} + _KlickyDebug msg="homing_override moving toolhead to {safe_z}mm from {printer.gcode_move.gcode_position.z}mm in Y homing seq" + {% if verbose %} + { action_respond_info("moving to a safe Z distance") } + {% endif %} + G0 Z{safe_z} F{z_drop_feedrate} + {% endif %} + {% if printer["gcode_macro _HOME_Y"] is defined %} + _KlickyDebug msg="homing_override calling _HOME_Y external script to handle the Y homing" + _HOME_Y + {% else %} + _KlickyDebug msg="homing_override Homing Y G28 Y0" + G28 Y0 + # does it need to back away from the home position + {% if home_backoff_y != 0 %} + {% if (printer.configfile.settings.stepper_y.position_endstop > (printer.configfile.settings.stepper_y.position_min|default(0) + printer.configfile.settings.stepper_y.position_max)/2) %} + _KlickyDebug msg="homing_override backing off Y endstop, G0 Y{printer.configfile.settings.stepper_y.position_endstop-home_backoff_y|int} F{travel_feedrate}" + G0 Y{printer.configfile.settings.stepper_y.position_endstop - home_backoff_y|int} F{travel_feedrate} + {% else %} + _KlickyDebug msg="homing_override backing off Y endstop, G0 Y{printer.configfile.settings.stepper_y.position_endstop + home_backoff_y|int} F{travel_feedrate}" + G0 Y{printer.configfile.settings.stepper_y.position_endstop + home_backoff_y|int} F{travel_feedrate} + {%endif %} + {%endif %} + {% endif %} + {% endif %} + {% set home_y = False %} + {% endif %} + + + # Home x + {% if home_x %} + {% if verbose %} + { action_respond_info("Homing X") } + {% endif %} + {% if 'z' in printer.toolhead.homed_axes and printer.gcode_move.gcode_position.z < safe_z %} + _KlickyDebug msg="homing_override moving toolhead to {safe_z}mm from {printer.gcode_move.gcode_position.z}mm in X homing seq" + {% if verbose %} + { action_respond_info("moving to a safe Z distance") } + {% endif %} + G0 Z{safe_z} F{z_drop_feedrate} + {% endif %} + {% if printer["gcode_macro _HOME_X"] is defined %} + _KlickyDebug msg="homing_override calling _HOME_X external script to handle the X homing" + _HOME_X + {% else %} + _KlickyDebug msg="homing_override Homing X, G28 X0" + G28 X0 + # does it need to back away from the home position + {% if home_backoff_x != 0 %} + {% if (printer.configfile.settings.stepper_x.position_endstop > (printer.configfile.settings.stepper_x.position_min|default(0) + printer.configfile.settings.stepper_x.position_max)/2) %} + _KlickyDebug msg="homing_override backing off X endstop, G0 X{printer.configfile.settings.stepper_x.position_endstop - home_backoff_x|int} F{travel_feedrate}" + G0 X{printer.configfile.settings.stepper_x.position_endstop - home_backoff_x|int} F{travel_feedrate} + {% else %} + _KlickyDebug msg="homing_override backing off X endstop, G0 X{printer.configfile.settings.stepper_x.position_endstop + home_backoff_x|int} F{travel_feedrate}" + G0 X{printer.configfile.settings.stepper_x.position_endstop + home_backoff_x|int} F{travel_feedrate} + {%endif %} + {%endif %} + {% endif %} + {% endif %} + + # Home y + {% if home_y %} + {% if verbose %} + { action_respond_info("Homing Y") } + {% endif %} + {% if 'z' in printer.toolhead.homed_axes and printer.gcode_move.gcode_position.z < safe_z %} + _KlickyDebug msg="homing_override moving toolhead to {safe_z}mm from {printer.gcode_move.gcode_position.z}mm in Y homing seq" + {% if verbose %} + { action_respond_info("moving to a safe Z distance") } + {% endif %} + G0 Z{safe_z} F{z_drop_feedrate} + {% endif %} + {% if printer["gcode_macro _HOME_Y"] is defined %} + _KlickyDebug msg="homing_override calling _HOME_Y external script to handle the Y homing" + _HOME_Y + {% else %} + _KlickyDebug msg="homing_override Homing Y, G28 Y0" + G28 Y0 + {% if home_backoff_y != 0 %} + {% if (printer.configfile.settings.stepper_y.position_endstop > (printer.configfile.settings.stepper_y.position_min|default(0) + printer.configfile.settings.stepper_y.position_max)/2) %} + _KlickyDebug msg="homing_override backing off Y endstop, G0 Y{printer.configfile.settings.stepper_y.position_endstop - home_backoff_y|int} F{travel_feedrate}" + G0 Y{printer.configfile.settings.stepper_y.position_endstop - home_backoff_y|int} F{travel_feedrate} + {% else %} + _KlickyDebug msg="homing_override backing off Y endstop, G0 Y{printer.configfile.settings.stepper_y.position_endstop + home_backoff_y|int} F{travel_feedrate}" + G0 Y{printer.configfile.settings.stepper_y.position_endstop + home_backoff_y|int} F{travel_feedrate} + {%endif %} + {%endif %} + {% endif %} + {% endif %} + # Home z + {% if home_z %} + {% if verbose %} + { action_respond_info("Homing Z") } + {% endif %} + {% if 'z' in printer.toolhead.homed_axes and printer.gcode_move.gcode_position.z < safe_z %} + _KlickyDebug msg="homing_override moving toolhead to {safe_z}mm from {printer.gcode_move.gcode_position.z}mm in Y homing seq" + {% if verbose %} + { action_respond_info("moving to a safe Z distance") } + {% endif %} + G0 Z{safe_z} F{z_drop_feedrate} + {% endif %} + + # if probe is configured as endstop, attach it, else check if the probe needs to be docked if attached + {% if 'z_virtual_endstop' in printer['configfile'].config["stepper_z"]["endstop_pin"] %} + _KlickyDebug msg="homing_override probe configured as a virtual Z endstop attaching probe" + Attach_Probe + # if PROBE_LOCK parameter is given, Attach Probe and lock until it´s unlocked + {% if leave_probe_attached %} + _Probe_Lock + {% endif %} + {% elif dock_on_zhome == True %} + Dock_Probe + {% endif %} + + _Home_Z_ + + # if probe is configured as endstop, dock it + {% if 'z_virtual_endstop' in printer['configfile'].config["stepper_z"]["endstop_pin"] %} + _KlickyDebug msg="homing_override probe no longer required, docking probe" + Dock_Probe + {% elif dock_on_zhome == False %} + Dock_Probe + {% endif %} + {% endif %} + _CheckProbe action=query + + # park the toolhead + _Park_Toolhead + + _exit_point function=homing_override + _KLICKY_STATUS_READY + +# Umbilical path setup +[gcode_macro _Umbilical_Path] +gcode: + {% set umbilical = printer["gcode_macro _User_Variables"].umbilical %} + {% set umbilical_x = printer["gcode_macro _User_Variables"].umbilical_x %} + {% set umbilical_y = printer["gcode_macro _User_Variables"].umbilical_y %} + {% set safe_z = printer["gcode_macro _User_Variables"].safe_z|float %} + {% set travel_feedrate = printer["gcode_macro _User_Variables"].travel_speed * 60 %} + + {% if umbilical %} + # Used to give the umbilical a better path to follow and coil properly if dock is tight in space + _entry_point function=Umbilical_Path + + _KlickyDebug msg="_Umbilical_Path moving to G0 X{umbilical_x} Y{umbilical_y} Z{safe_z} F{travel_feedrate}" + G0 X{umbilical_x} Y{umbilical_y} Z{safe_z} F{travel_feedrate} + + _exit_point function=Umbilical_Path + {% endif %} + + +# Home Z Routine +[gcode_macro _Home_Z_] +gcode: + {% set z_endstop_x = printer["gcode_macro _Probe_Variables"].z_endstop_x %} + {% set z_endstop_y = printer["gcode_macro _Probe_Variables"].z_endstop_y %} + {% set safe_z = printer["gcode_macro _User_Variables"].safe_z|float %} + {% set travel_feedrate = printer["gcode_macro _User_Variables"].travel_speed * 60 %} {% set z_drop_feedrate = printer["gcode_macro _User_Variables"].z_drop_speed * 60 %} + {% set verbose = printer["gcode_macro _User_Variables"].verbose %} + + _entry_point function=Home_Z + + # if x and y are not homed yet, raise error + {% if not 'xy' in printer.toolhead.homed_axes %} + { action_raise_error("Must Home X and Y Axis First!") } + {% else %} + _KlickyDebug msg="_Home_Z_ XY Axis homed" + {% if not 'z' in printer.toolhead.homed_axes %} + {% if verbose %} + { action_respond_info("Resetting Z position to zero") } + {% endif %} + _KlickyDebug msg="_Home_Z_ Z not homed, setting position as X=Y=Z=0" + SET_KINEMATIC_POSITION Z=0 + {% endif %} + + # Move tool to safe homing position and home Z axis + # location of z endstop + _KlickyDebug msg="_Home_Z_ moving to Z endstop position G0 X{z_endstop_x} Y{z_endstop_y} F{travel_feedrate}" + G0 X{z_endstop_x} Y{z_endstop_y} F{travel_feedrate} + _KlickyDebug msg="_Home_Z_ Homing Z G28 Z" + G28 Z0 + _KlickyDebug msg="_Home_Z_ toolhead too low, raising it to {safe_z}mm from {printer.gcode_move.gcode_position.z}mm" + G0 Z{safe_z} F{z_drop_feedrate} + + {% endif %} + + _exit_point function=Home_Z + +# Check to see if probe is where it is supposed to be after +# attaching/docking maneuver and set homing error or shutdown +[gcode_macro _CheckProbe] +variable_probe_state: 0 +gcode: + Query_Probe + _SetProbeState action={ params.ACTION } + +# Due to how templates are evaluated, we have query endstops in one +# macro and call another macro to make decisions based on the result +[gcode_macro _SetProbeState] +gcode: + {% set query_probe_triggered = printer.probe.last_query %} + {% set action = params.ACTION|default('') %} + + # If triggered (true), probe not attached + {% if query_probe_triggered %} + SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_attached VALUE={ False } + {% else %} + # If not triggered (false), probe attached + SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_attached VALUE={ True } + {% endif %} + + {% if action == 'query' %} + SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_state VALUE={ query_probe_triggered } + {% endif %} + + # If probe fails to attach/detach + + # If not docked + {% if not query_probe_triggered and action == 'dock' %} + { action_raise_error("Probe dock failed!") } + {% endif %} + + # If not attached + {% if query_probe_triggered and action == 'attach' %} + { action_raise_error("Probe attach failed!") } + {% endif %} + +# Park Toolhead Routine +[gcode_macro _Park_Toolhead] +gcode: + {% set park_toolhead = printer["gcode_macro _User_Variables"].park_toolhead %} + {% set parkposition_x = printer["gcode_macro _User_Variables"].parkposition_x %} + {% set parkposition_y = printer["gcode_macro _User_Variables"].parkposition_y %} + {% set parkposition_z = printer["gcode_macro _User_Variables"].parkposition_z %} + {% set travel_feedrate = printer["gcode_macro _User_Variables"].travel_speed * 60 %} + {% set verbose = printer["gcode_macro _User_Variables"].verbose %} + + _entry_point function=Park_Toolhead + + {% if park_toolhead and 'xyz' in printer.toolhead.homed_axes %} + {% if verbose %} + { action_respond_info("Parking Toolhead") } + {% endif %} + {% if parkposition_z == -128 %} + _KlickyDebug msg="_Park_Toolhead moving to G0 X{parkposition_x} Y{parkposition_y} F{travel_feedrate}" + G0 X{parkposition_x} Y{parkposition_y} F{travel_feedrate} + + {% else %} + + _KlickyDebug msg="_Park_Toolhead moving to G0 X{parkposition_x} Y{parkposition_y} Z{parkposition_z} F{travel_feedrate}" + G0 X{parkposition_x} Y{parkposition_y} Z{parkposition_z} F{travel_feedrate} + + {% endif %} + + {% endif %} + _exit_point function=Park_Toolhead + + + +################# +# Status LEDs +# This enables stealthburner-led status macros to be used in klicky macros if they exist. +# https://github.com/VoronDesign/Voron-Afterburner/blob/sb-beta/Klipper_Macros/stealthburner_leds.cfg +[gcode_macro _klicky_status_ready] +gcode: + {% if printer['gcode_macro status_ready'] is defined %} + _KlickyDebug msg="_klicky_status_ready activating the LED STATUS_READY" + STATUS_READY + {% endif %} + +[gcode_macro _klicky_status_busy] +gcode: + {% if printer['gcode_macro status_busy'] is defined %} + _KlickyDebug msg="_klicky_status_busy activating the LED STATUS_BUSY" + STATUS_BUSY + {% endif %} + +[gcode_macro _klicky_status_leveling] +gcode: + {% if printer['gcode_macro status_leveling'] is defined %} + _KlickyDebug msg="_klicky_status_leveling activating the LED STATUS_LEVELING" + STATUS_LEVELING + {% endif %} + +[gcode_macro _klicky_status_homing] +gcode: + {% if printer['gcode_macro status_homing'] is defined %} + _KlickyDebug msg="_klicky_status_homing activating the LED STATUS_HOMING" + STATUS_HOMING + {% endif %} + +[gcode_macro _klicky_status_cleaning] +gcode: + {% if printer['gcode_macro status_cleaning'] is defined %} + _KlickyDebug msg="_klicky_status_cleaning activating the LED STATUS_CLEANING" + STATUS_CLEANING + {% endif %} + +[gcode_macro _klicky_status_meshing] +gcode: + {% if printer['gcode_macro status_meshing'] is defined %} + _KlickyDebug msg="_klicky_status_meshing activating the LED STATUS_MESHING" + STATUS_MESHING + {% endif %} + +[gcode_macro _klicky_status_calibrating_z] +gcode: + {% if printer['gcode_macro status_calibrating_z'] is defined %} + _KlickyDebug msg="_klicky_status_calibrating_z activating the LED STATUS_CALIBRATING_Z" + STATUS_CALIBRATING_Z + {% endif %} diff --git a/klicky-probe.cfg b/klicky-probe.cfg new file mode 100644 index 0000000..7f1d13d --- /dev/null +++ b/klicky-probe.cfg @@ -0,0 +1,10 @@ +#Simple way to include all the various klicky macros and configurations +# the current home for this configuration is https://github.com/jlas1/Klicky-Probe, please check it + +#[include ./klicky-specific.cfg] #place to put other configurations specific to your printer +[include ./klicky-variables.cfg] #Required +[include ./klicky-macros.cfg] #Required +#[include ./klicky-bed-mesh-calibrate.cfg] #bed mesh, requires klipper configuration +#[include ./klicky-screws-tilt-calculate.cfg] #help adjust bed screws automatically +#[include ./klicky-quad-gantry-level.cfg] #level 4 Z motors +#[include ./klicky-z-tilt-adjust.cfg] #level 2 or 3 Z motors diff --git a/klicky-quad-gantry-level.cfg b/klicky-quad-gantry-level.cfg new file mode 100644 index 0000000..14be43c --- /dev/null +++ b/klicky-quad-gantry-level.cfg @@ -0,0 +1,31 @@ +# This macro was provided by discord user Garrettwp to whom i give my thanks for sharing it with me. +# I have tweaked it a lot. +# +# this macro is based on the great Annex magprobe dockable probe macros "#Originally developed by Mental, modified for better use on K-series printers by RyanG and Trails" +# that macro as since evolved into a klipper plugin that currently is pending inclusion in klipper +# more information here https://github.com/Annex-Engineering/Quickdraw_Probe/tree/main/Klipper_Macros +# +# by standing on the shoulders of giants, lets see if we can see further +# User richardjm revised the macro variables and added some functions, thanks a lot +# This macro home is https://github.com/jlas1/Klicky-Probe + +################### +# Quad Gantry Level +[gcode_macro QUAD_GANTRY_LEVEL] +rename_existing: _QUAD_GANTRY_LEVEL +description: Conform a moving, twistable gantry to the shape of a stationary bed with klicky automount +gcode: + {% set V = printer["gcode_macro _User_Variables"].verbose %} + {% if V %} + { action_respond_info("QG Level") } + {% endif %} + + _CheckProbe action=query + G90 + Attach_Probe + _KLICKY_STATUS_LEVELING + + _QUAD_GANTRY_LEVEL {% for p in params + %}{'%s=%s ' % (p, params[p])}{% + endfor %} + Dock_Probe diff --git a/klicky-screws-tilt-calculate.cfg b/klicky-screws-tilt-calculate.cfg new file mode 100644 index 0000000..af51d59 --- /dev/null +++ b/klicky-screws-tilt-calculate.cfg @@ -0,0 +1,32 @@ +# This macro was provided by discord user Garrettwp to whom i give my thanks for sharing it with me. +# I have tweaked it a lot. +# +# this macro is based on the great Annex magprobe dockable probe macros "#Originally developed by Mental, modified for better use on K-series printers by RyanG and Trails" +# that macro as since evolved into a klipper plugin that currently is pending inclusion in klipper +# more information here https://github.com/Annex-Engineering/Quickdraw_Probe/tree/main/Klipper_Macros +# +# by standing on the shoulders of giants, lets see if we can see further +# User richardjm revised the macro variables and added some functions, thanks a lot +# This macro home is https://github.com/jlas1/Klicky-Probe + +################### +## Screws Tilt Adjust +[gcode_macro SCREWS_TILT_CALCULATE] +rename_existing: _SCREWS_TILT_CALCULATE +description: +gcode: + {% set V = printer["gcode_macro _User_Variables"].verbose %} + {% if V %} + { action_respond_info("Screws Tilt Adjust") } + {% endif %} + + _CheckProbe action=query + G90 + Attach_Probe + _KLICKY_STATUS_LEVELING + + _SCREWS_TILT_CALCULATE {% for p in params + %}{'%s=%s ' % (p, params[p])}{% + endfor %} + + Dock_Probe \ No newline at end of file diff --git a/klicky-specific.cfg b/klicky-specific.cfg new file mode 100644 index 0000000..e69de29 diff --git a/klicky-variables.cfg b/klicky-variables.cfg new file mode 100644 index 0000000..bde36e0 --- /dev/null +++ b/klicky-variables.cfg @@ -0,0 +1,109 @@ +# This macro was provided by discord user Garrettwp to whom i give my thanks for sharing it with me. +# I have tweaked it a lot. +# They are based on the great Annex magprobe dockable probe macros "#Originally developed by Mental, +# modified for better use on K-series printers by RyanG and Trails", kudos to them. +# That macro as since evolved into a klipper plugin that currently is pending inclusion in klipper, +# more information here, https://github.com/Annex-Engineering/Quickdraw_Probe/tree/main/Klipper_Macros +# User richardjm revised the macro variables and added some functions, thanks a lot +# by standing on the shoulders of giants, lets see if we can see further +# +# the current home for this version is https://github.com/jlas1/Klicky-Probe +# the 1000 values below is to give an error instead of doing something wrong, hopefully, this won't be used is a printer larger than 1 meter + +[gcode_macro _User_Variables] +variable_verbose: True # Enable verbose output +variable_debug: False # Enable Debug output +variable_travel_speed: 200 # how fast all other travel moves will be performed when running these macros +variable_move_accel: 1000 # how fast should the toolhead accelerate when moving +variable_dock_speed: 50 # how fast should the toolhead move when docking the probe for the final movement +variable_release_speed: 75 # how fast should the toolhead move to release the hold of the magnets after docking +variable_z_drop_speed: 20 # how fast the z will lower when moving to the z location to clear the probe + +variable_safe_z: 25 # Minimum Z for attach/dock and homing functions +# if true it will move the bed away from the nozzle when Z is not homed +variable_enable_z_hop: True # set this to false for beds that fall significantly under gravity (almost to Z max) + +variable_max_bed_y: 350 # maximum Bed size avoids doing a probe_accuracy outside the bed +variable_max_bed_x: 350 # maximum Bed size avoids doing a probe_accuracy outside the bed + +# if a separate Z endstop switch is in +# use, specify the coordinates of the switch here (Voron). +# Set to 0 to have the probe move to center of bed +#variable_z_endstop_x: 228 +#variable_z_endstop_y: 346 +variable_z_endstop_x: 0 +variable_z_endstop_y: 0 + +#Check the printer specific documentation on klipper Dock/Undock configuration, these are dummy values +#dock location +variable_docklocation_x: 36 # X Dock position +variable_docklocation_y: 350 # Y Dock position +variable_docklocation_z: -128 # Z dock position (-128 for a gantry/frame mount) + +#The following variables are used if the dock is deployed and retracted via a servo motor +variable_enable_dock_servo: False # Set to true if your klicky dock is servo-controlled +variable_servo_name: 'NAME' # The name of the dock servo defined in printer.cfg under [servo] +variable_servo_deploy: 10 # This EXAMPLE is the value used to deploy the servo fully +variable_servo_retract: 11 # This EXAMPLE is the value used to retract the servo fully (initial_angle in [servo] config) +variable_servo_delay: 250 # This is a delay to wait the servo to reach the requested position, be carefull with high values + +#Dock move, final toolhead movement to release the probe on the dock +#it's a relative move +Variable_dockmove_x: 30 +Variable_dockmove_y: 0 +Variable_dockmove_z: 0 + +#Attach move. final toolhead movement to attach the probe on the mount +#it's a relative move +Variable_attachmove_x: 0 +Variable_attachmove_y: 30 +Variable_attachmove_z: 0 + +#Umbilical to help untangle the umbilical in difficult situations +variable_umbilical: False # should we untangle the umbilical +variable_umbilical_x: 15 # X umbilical position +variable_umbilical_y: 15 # Y umbilical position + +# location to park the toolhead +variable_park_toolhead: False # Enable toolhead parking +variable_parkposition_x: 345 +variable_parkposition_y: 345 +variable_parkposition_z: 30 + +variable_version: 1 # Helps users to update the necessary variables, do not update if the variables above are not updated + +#Below this remark, you normally do not need to configure +#Attach move2 +Variable_attachmove2_x: 0 # intermediate toolhead movement to attach +Variable_attachmove2_y: 0 # the probe on the dock +Variable_attachmove2_z: 0 # (can be negative) + +variable_home_backoff_x: 10 # how many mm to move away from the X endstop after homing X + # this is useful for the voron v0 to enable the toolhead to move out of the way to allow an unstricted Y homing +variable_home_backoff_y: 10 # how many mm to move away from the Y endstop after homing Y + +variable_override_homing: '' # configures what axis to home first + # '' = default klicky behavior (tries to avoid the hitting the dock) + # 'X' = forces X to home first + # 'Y' = forces Y to home first + +variable_dock_on_zhome: True # docks the probe on Z Homing if not necessary (avoids hitting the bed on some printers + +# Do not modify below +gcode: + {% set Mx = printer['configfile'].config["stepper_x"]["position_max"]|float %} + {% set My = printer['configfile'].config["stepper_y"]["position_max"]|float %} + {% set Ox = printer['configfile'].config["probe"]["x_offset"]|float %} + {% set Oy = printer['configfile'].config["probe"]["y_offset"]|float %} + {% set Oz = printer['configfile'].config["probe"]["z_offset"]|float %} + + # If x, y coordinates are set for z endstop, assign them + {% if z_endstop_x != 0 or z_endstop_y != 0 %} + SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=z_endstop_x VALUE={ z_endstop_x } + SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=z_endstop_y VALUE={ z_endstop_y } + + # if no x, y coordinates for z endstop, assume probe is endstop and move toolhead to center of bed + {% else %} + SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=z_endstop_x VALUE={ (Mx * 0.5) - Ox } + SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=z_endstop_y VALUE={ (My * 0.5) - Oy } + {% endif %} diff --git a/klicky-z-tilt-adjust.cfg b/klicky-z-tilt-adjust.cfg new file mode 100644 index 0000000..3264c85 --- /dev/null +++ b/klicky-z-tilt-adjust.cfg @@ -0,0 +1,32 @@ +# This macro was provided by discord user Garrettwp to whom i give my thanks for sharing it with me. +# I have tweaked it a lot. +# +# this macro is based on the great Annex magprobe dockable probe macros "#Originally developed by Mental, modified for better use on K-series printers by RyanG and Trails" +# that macro as since evolved into a klipper plugin that currently is pending inclusion in klipper +# more information here https://github.com/Annex-Engineering/Quickdraw_Probe/tree/main/Klipper_Macros +# +# by standing on the shoulders of giants, lets see if we can see further +# User richardjm revised the macro variables and added some functions, thanks a lot +# This macro home is https://github.com/jlas1/Klicky-Probe + +################### +## Z Tilt Adjust +[gcode_macro Z_TILT_ADJUST] +rename_existing: _Z_TILT_ADJUST +description: +gcode: + {% set V = printer["gcode_macro _User_Variables"].verbose %} + {% if V %} + { action_respond_info("Z Tilt Adjust") } + {% endif %} + + _CheckProbe action=query + G90 + Attach_Probe + _KLICKY_STATUS_LEVELING + + _Z_TILT_ADJUST {% for p in params + %}{'%s=%s ' % (p, params[p])}{% + endfor %} + Dock_Probe + G28 Z0 \ No newline at end of file diff --git a/klicky_z_calibration.cfg b/klicky_z_calibration.cfg new file mode 100644 index 0000000..9bc2d67 --- /dev/null +++ b/klicky_z_calibration.cfg @@ -0,0 +1,49 @@ +[z_calibration] +nozzle_xy_position: 228,346 +# A X, Y coordinate (e.g. 100,100) of the nozzle, clicking on the z endstop. +switch_xy_position: 222,325 +# A X, Y coordinate (e.g. 100,100) of the probe's switch body, clicking on +# the z endstop. +#switch_xy_offsets: optional when switch_xy_position is used +# Instead of an absolute position (switch_xy_position), this configuration +# adds an X, Y offset (e.g. -6,-18) to the nozzle position. +bed_xy_position: 175,175 +# A X, Y coordinate (e.g. 100,100) where the print surface (e.g. the center +# point) is probed. These coordinates are adjusted by the +# probe's X and Y offsets. The default is the zero_reference_position which +# replaces the deprecated relative_reference_index +# of the configured bed_mesh, if configured. It's possible to change the zero +# reference position at runtime or use the GCode argument BED_POSITION of CALIBRATE_Z. +wiggle_xy_offsets: 0,0 +# After probing the nozzle and retracting, move x some distance away and +# back. Useful to prevent the z endstop pin sticking to the nozzle and +# being pulled out of the assembly. Can be negative. Defaults to zero to +# disable it. Can be combined in x and y to move diagonally. Be careful +# to not move your nozzle out of range! +switch_offset: 0.521 +# The trigger point offset of the used mag-probe switch. +# A larger value will position the nozzle closer to the bed. +# This must be determined manually. More on this later +# in this section.. +offset_margins: -1.0,1.0 +# The minimum and maximum margins allowed for the calculated offset. +# If the offset is outside these values, it will stop! +# The margin can be defined as "min,max" e.g. "-0.5,1.5" or by just one +# value e.g. "1.0" which translates to "-1.0,1.0" (which is also the default). +probing_first_fast: false +# If true, the first probing will be faster by the probing speed. +# This is to get down faster and not record the result as a +# probing sample. The default is false. +start_gcode: ATTACH_PROBE +# A list of G-Code commands to run before each calibration command. +# See docs/Command_Templates.md for the G-Code format. This can be used to +# attach the probe. +#before_switch_gcode: +# A list of G-Code commands to run before to each probing on the +# mag-probe. See docs/Command_Templates.md for the G-Code format. This can +# be used to attach the probe after probing on the nozzle and before probing +# on the mag-probe. +end_gcode: DOCK_PROBE +# A list of G-Code commands to run after each calibration command. +# See docs/Command_Templates.md for the G-Code format. This can be used to +# detach the probe afterwards. diff --git a/shaketune.cfg b/shaketune.cfg new file mode 100644 index 0000000..b6cf37b --- /dev/null +++ b/shaketune.cfg @@ -0,0 +1,14 @@ +[shaketune] + result_folder: ~/printer_data/config/ShakeTune_results +# The folder where the results will be stored. It will be created if it doesn't exist. + number_of_results_to_keep: 3 +# The number of results to keep in the result_folder. The oldest results will +# be automatically deleted after each runs. + keep_raw_csv: False +# If True, the raw CSV files will be kept in the result_folder alongside the +# PNG graphs. If False, they will be deleted and only the graphs will be kept. + show_macros_in_webui: True +# Mainsail and Fluidd doesn't create buttons for "system" macros that are not in the +# printer.cfg file. If you want to see the macros in the webui, set this to True. + timeout: 300 +# The maximum time in seconds to let Shake&Tune process the CSV files and generate the graphs. \ No newline at end of file diff --git a/stealthburner_leds.cfg b/stealthburner_leds.cfg new file mode 100644 index 0000000..66dc8c2 --- /dev/null +++ b/stealthburner_leds.cfg @@ -0,0 +1,193 @@ +# Macros for setting the status leds on the Voron StealthBurner toolhead (or for any neopixel-type leds). +# +# You will need to configure a neopixel (or other addressable led, such as dotstar). See +# https://www.klipper3d.org/Config_Reference.html#neopixel for configuration details. +# +# CONFIGURATION +# is in ebb36.cfg +# +# MACROS +# +# The following status macros are available: +# STATUS_READY +# STATUS_OFF +# STATUS_BUSY +# STATUS_HEATING +# STATUS_LEVELING +# STATUS_HOMING +# STATUS_CLEANING +# STATUS_MESHING +# STATUS_CALIBRATING_Z +# With additional macros for direct control: +# SET_NOZZLE_LEDS_ON +# SET_LOGO_LEDS_OFF +# SET_NOZZLE_LEDS_OFF +# +# Contributed by Voron discord users wile.e, Tetsunosuke, and etherwalker + +[gcode_macro _sb_vars] +# User settings for the StealthBurner status leds. You can change the status colors and led +# configurations for the logo and nozzle here. +variable_colors: { + 'logo': { # Colors for logo states + 'busy': {'r': 0.4, 'g': 0.0, 'b': 0.0, 'w': 0.0}, + 'cleaning': {'r': 0.0, 'g': 0.02, 'b': 0.5, 'w': 0.0}, + 'calibrating_z': {'r': 0.8, 'g': 0., 'b': 0.35, 'w': 0.0}, + 'heating': {'r': 0.3, 'g': 0.18, 'b': 0.0, 'w': 0.0}, + 'homing': {'r': 0.0, 'g': 0.6, 'b': 0.2, 'w': 0.0}, + 'leveling': {'r': 0.5, 'g': 0.1, 'b': 0.4, 'w': 0.0}, + 'meshing': {'r': 0.2, 'g': 1.0, 'b': 0.0, 'w': 0.0}, + 'off': {'r': 0.0, 'g': 0.0, 'b': 0.0, 'w': 0.0}, + 'printing': {'r': 1.0, 'g': 0.0, 'b': 0.0, 'w': 0.0}, + 'standby': {'r': 0.01, 'g': 0.01, 'b': 0.01, 'w': 0.1}, + }, + 'nozzle': { # Colors for nozzle states + 'heating': {'r': 0.8, 'g': 0.35, 'b': 0.0, 'w':0.5}, + 'off': {'r': 0.0, 'g': 0.0, 'b': 0.0, 'w': 0.0}, + 'on': {'r': 1.0, 'g': 1.0, 'b': 1.0, 'w':1.0}, + 'standby': {'r': 0.6, 'g': 0.0, 'b': 0.0, 'w':0.8}, + }, + 'thermal': { + 'hot': {'r': 1.0, 'g': 0.0, 'b': 0.0, 'w': 0.0}, + 'cold': {'r': 0.3, 'g': 0.0, 'b': 0.3, 'w': 0.0} + } + } +variable_logo_led_name: "sb_leds" +# The name of the addressable LED chain that contains the logo LED(s) +variable_logo_idx: "1" +# A comma-separated list of indexes LEDs in the logo +variable_nozzle_led_name: "sb_leds" +# The name of the addressable LED chain that contains the nozzle LED(s). This will +# typically be the same LED chain as the logo. +variable_nozzle_idx: "2,3" +# A comma-separated list of indexes of LEDs in the nozzle + +variable_thermal_config: { + 'extruder': { + 'cool_temp': 40, + 'leds': 'logo', + }, + 'heater_bed': { + 'cool_temp': 40, + 'leds': 'nozzle', + }, + } +# temperatures at which cooling will be considered complete + +gcode: + ; Do nothing + +[gcode_macro _set_sb_leds] +gcode: + {% set red = params.RED|default(0)|float %} + {% set green = params.GREEN|default(0)|float %} + {% set blue = params.BLUE|default(0)|float %} + {% set white = params.WHITE|default(0)|float %} + {% set led = params.LED|string %} + {% set idx = (params.IDX|string).split(',') %} + {% set transmit_last = params.TRANSMIT|default(1) %} + + {% for led_index in idx %} + {% set transmit=transmit_last if loop.last else 0 %} + set_led led={led} red={red} green={green} blue={blue} white={white} index={led_index} transmit={transmit} + {% endfor %} + +[gcode_macro _set_sb_leds_by_name] +gcode: + {% set leds_name = params.LEDS %} + {% set color_name = params.COLOR %} + {% set color = printer["gcode_macro _sb_vars"].colors[leds_name][color_name] %} + {% set led = printer["gcode_macro _sb_vars"][leds_name + "_led_name"] %} + {% set idx = printer["gcode_macro _sb_vars"][leds_name + "_idx"] %} + {% set transmit = params.TRANSMIT|default(1) %} + + _set_sb_leds led={led} red={color.r} green={color.g} blue={color.b} white={color.w} idx="{idx}" transmit={transmit} + +[gcode_macro _set_logo_leds] +gcode: + {% set red = params.RED|default(0)|float %} + {% set green = params.GREEN|default(0)|float %} + {% set blue = params.BLUE|default(0)|float %} + {% set white = params.WHITE|default(0)|float %} + {% set led = printer["gcode_macro _sb_vars"].logo_led_name %} + {% set idx = printer["gcode_macro _sb_vars"].logo_idx %} + {% set transmit=params.TRANSMIT|default(1) %} + + _set_sb_leds led={led} red={red} green={green} blue={blue} white={white} idx="{idx}" transmit={transmit} + +[gcode_macro _set_nozzle_leds] +gcode: + {% set red = params.RED|default(0)|float %} + {% set green = params.GREEN|default(0)|float %} + {% set blue = params.BLUE|default(0)|float %} + {% set white = params.WHITE|default(0)|float %} + {% set led = printer["gcode_macro _sb_vars"].nozzle_led_name %} + {% set idx = printer["gcode_macro _sb_vars"].nozzle_idx %} + {% set transmit=params.TRANSMIT|default(1) %} + + _set_sb_leds led={led} red={red} green={green} blue={blue} white={white} idx="{idx}" transmit={transmit} + +[gcode_macro set_logo_leds_off] +gcode: + {% set transmit=params.TRANSMIT|default(1) %} + _set_logo_leds red=0 blue=0 green=0 white=0 transmit={transmit} + +[gcode_macro set_nozzle_leds_on] +gcode: + {% set transmit=params.TRANSMIT|default(1) %} + _set_sb_leds_by_name leds="nozzle" color="on" transmit={transmit} + +[gcode_macro set_nozzle_leds_off] +gcode: + {% set transmit=params.TRANSMIT|default(1) %} + _set_sb_leds_by_name leds="nozzle" color="off" transmit={transmit} + +[gcode_macro status_off] +gcode: + set_logo_leds_off transmit=0 + set_nozzle_leds_off + +[gcode_macro status_ready] +gcode: + _set_sb_leds_by_name leds="logo" color="standby" transmit=0 + _set_sb_leds_by_name leds="nozzle" color="standby" transmit=1 + +[gcode_macro status_busy] +gcode: + _set_sb_leds_by_name leds="logo" color="busy" transmit=0 + set_nozzle_leds_on + +[gcode_macro status_heating] +gcode: + _set_sb_leds_by_name leds="logo" color="heating" transmit=0 + _set_sb_leds_by_name leds="nozzle" color="heating" transmit=1 + +[gcode_macro status_leveling] +gcode: + _set_sb_leds_by_name leds="logo" color="leveling" transmit=0 + set_nozzle_leds_on + +[gcode_macro status_homing] +gcode: + _set_sb_leds_by_name leds="logo" color="homing" transmit=0 + set_nozzle_leds_on + +[gcode_macro status_cleaning] +gcode: + _set_sb_leds_by_name leds="logo" color="cleaning" transmit=0 + set_nozzle_leds_on + +[gcode_macro status_meshing] +gcode: + _set_sb_leds_by_name leds="logo" color="meshing" transmit=0 + set_nozzle_leds_on + +[gcode_macro status_calibrating_z] +gcode: + _set_sb_leds_by_name leds="logo" color="calibrating_z" transmit=0 + set_nozzle_leds_on + +[gcode_macro status_printing] +gcode: + _set_sb_leds_by_name leds="logo" color="printing" transmit=0 + set_nozzle_leds_on