KP3S改のKlipper復帰用設定

ファイル自体もバックアップをしておりますが、内容をすぐに確認できるようnoteに残して置くことにしました。
改造箇所が多いため、他の方が同じ設定で使用することはできないですが、ご覧になりたい方もおられるかもしれないと思い公開しております。
自分用ですので、告知無しで随時内容は更新します。
質問が有りましたら、わかる範囲ではお答えします。

2024年4月1日更新

Raspberry Pi ImagerでMainsail OS(32bit)のイメージをMicroSDに焼く
16GB以上のMicroSDが良い

https://www.raspberrypi.com/software/

有線LANもしくはWifiに接続後、ルーターの設定でラズパイのMACアドレスを元にipアドレスを固定して
Tera Term等にてSSH接続で操作
ID:pi
PASS:raspberry
必要に応じてID・PASSは変更する

KIAUHを導入してから色々インストール
Obicoもここでインストール
fluiddもここでインストール
ポートを追加してMainsailだけでなくfliddでもアクセスできるようにする
KP3Sのファームもここで作成

cd ~
git clone https://github.com/th33xitus/kiauh.git

./kiauh/kiauh.sh

ファーム作成時の設定はprinter.cfgの冒頭を参照
ファーム作成後WinSCP等で接続後にPCにファームを取り出し、MicroSDに入れてKP3Sに適用
ファーム作成後の出力先

/home/pi/klipper/out

Happy Hare V2 (ERCF用)インストール

cd ~
git clone https://github.com/moggieuk/Happy-Hare.git

./Happy-Hare/install.sh -i

Tailscaleインストール
https://tailscale.com/download/linux/rpi

curl -fsSL https://tailscale.com/install.sh | sh
インストール後PC等にて
https://login.tailscale.com/admin/machines
に追加されているMainsailOSのログインの期間制限を解除
(... をクリック後にDisable key Expiry )

moonrakerの設定(Tailscaleの信用アドレス追加や、TP-linkプラグのアドレス等)

[authorization]trusted_clients:
に他のPCやスマホのTailscaleでのipアドレスを追加する

[power printer]type: tplink_smartplug
address: 192.168.10.14  #ルーターにて固定したTP-linkプラグのアドレス
を追加

ADXL345で共振測定できるように色々インストール

sudo apt update
sudo apt install python3-numpy python3-matplotlib libatlas-base-dev
~/klippy-env/bin/pip install matplotlib numpy

cfg類

.cfgの置き場

/home/pi/printer_data/config

printer.cfg

[include fluidd.cfg]

# Note that the "make flash" command does not work with MKS Robin
# boards. After running "make", run the following command:
#   ./scripts/update_mks_robin.py out/klipper.bin out/Robin_nano.bin
# Copy the file out/Robin_nano.bin to an SD card and then restart the
# printer with that SD card.

#[*] Enable extra low-level configuration options
#    Micro-controller Architecture (STMicroelectronics STM32)  --->
#    Processor model (STM32F103)  --->
#[ ] Disable SWD at startup (for GigaDevice stm32f103 clones) (NEW)
#   Bootloader offset (28KiB bootloader)  --->
#    Clock Reference (8 MHz crystal)  --->
#    Communication interface (Serial (on USART3 PB11/PB10))  --->
#(250000) Baud rate for serial port (NEW)
#(!PC6, !PD13) GPIO pins to set at micro-controller startup

#[include fly_adxl345_x.cfg]
#[include fly_adxl345_y.cfg]
[include mmu_root.cfg]
#[include x_3d_printer.cfg]
#[include x_laser_plotter.cfg]
#[include x_laser_plotter_Y180.cfg]
#[include x_cutting_plotter.cfg]
#[include x_pen_plotter.cfg]
[include macro.cfg]
[include pa_calibrate.cfg]
[include timelapse.cfg]
#[include KAMP_Settings.cfg]
[include chip_mesh.cfg]

[exclude_object]

[heater_fan hotend_fan]
pin: PB0
max_power: 1.0
fan_speed: 1
cycle_time: 0.1
kick_start_time: 0.5
heater: extruder
heater_temp: 45.0

[mcu]
serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
restart_method: command

[force_move]
enable_force_move: False

[stepper_z]
step_pin: PB5
dir_pin: !PB4
enable_pin: !PB8
rotation_distance: 8
full_steps_per_rotation: 200
microsteps: 32
endstop_pin: probe:z_virtual_endstop
position_max: 250
position_min: -5
homing_speed: 8
second_homing_speed: 3
homing_retract_dist: 3

[heater_bed]
heater_pin: PA0
sensor_pin: PC0
sensor_type: EPCOS 100K B57560G104F
control: pid
pid_Kp: 325.10
pid_Ki: 63.35
pid_Kd: 417.10
max_temp: 115
min_temp: 1
max_power: 0.8

[temperature_sensor chamber]
sensor_pin: PC2
sensor_type: Generic 3950

[temperature_sensor raspberry_pi]
sensor_type: temperature_host
min_temp: 10
max_temp: 100

[static_digital_output display_reset]
pins: !PC6, !PD13

[virtual_sdcard]
path: /home/pi/printer_data/gcodes

[pause_resume]
recover_velocity: 300

[input_shaper]
#shaper_freq_x: 73.6
#shaper_type_x: 3hump_ei
#shaper_freq_y: 72.8
#shaper_type_y: 3hump_ei

[gcode_arcs]
resolution: 1

######################################################################
# Beeper
######################################################################

# GCODE macro.  Usage:
#   M300 [S<Hz>]  [P<ms>] 
#   S the tone frequency, P is the tone duration
# 
#   for Exsample 
#   M300 S440 P1000  :440Hz 1000ms

[output_pin BEEPER_Pin]
pin: PC5
pwm: TRUE ; A piezo beeper needs a PWM signal, a DC buzzer doesn't.
value: 0 ; Silent at power on, set to 1 if active low.
shutdown_value: 0 ; Disable at emergency shutdown
cycle_time: 0.001 ; PWM frequency : 0.001 = 1ms will give a base tone of 1kHz
scale: 1

[gcode_macro M300]
gcode:
   {% set S = params.S|default(1000)|int %} ; S sets the tone frequency
   {% set P = params.P|default(1000)|int %} ; P sets the tone duration

   {% set L = 0.5 %} ; L varies the PWM on time, close to 0 or 1 the tone gets a bit quieter. 0.5 is a symmetric waveform

   {% if S <= 0 %} ; dont divide through zero
       {% set F = 1 %}
       {% set L = 0 %}
   {% elif S >= 10000 %} ;max frequency set to 10kHz
        {% set F = 0 %}
   {% else %}
        {% set F = 1/S %} ;convert frequency to seconds 
   {% endif %}

       SET_PIN PIN=BEEPER_Pin VALUE={L} CYCLE_TIME={F} ;Play tone
       G4 P{P} ;tone duration
       SET_PIN PIN=BEEPER_Pin VALUE=0

[display_status]

[gcode_macro POWER_OFF_PRINTER]
gcode:
  {action_call_remote_method("set_device_power",
                             device="printer",
                             state="off")}

[delayed_gcode delayed_printer_off]
initial_duration: 0.
gcode:
  {% if printer.idle_timeout.state == "Idle" %}
    POWER_OFF_PRINTER
  {% endif %}

[idle_timeout]
gcode:
  TURN_OFF_MOTORS
  TURN_OFF_HEATERS
  UPDATE_DELAYED_GCODE ID=delayed_printer_off DURATION=300
timeout: 900

[include moonraker_obico_macros.cfg]

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 	-0.155000, -0.071250, -0.007917, -0.001667, -0.074167
#*# 	-0.059167, -0.051667, -0.022917, -0.027500, -0.068750
#*# 	-0.023333, -0.001667, -0.010000, -0.015833, -0.038333
#*# 	-0.024167, -0.009167, -0.034167, -0.031667, -0.100417
#*# 	-0.126667, -0.042500, -0.074583, -0.070000, -0.143333
#*# tension = 0.2
#*# min_x = 18.0
#*# algo = lagrange
#*# y_count = 5
#*# mesh_y_pps = 2
#*# min_y = 10.0
#*# x_count = 5
#*# max_y = 160.0
#*# mesh_x_pps = 2
#*# max_x = 160.0
#*#
#*# [bltouch]
#*# z_offset = 2.330
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 22.640
#*# pid_ki = 0.986
#*# pid_kd = 129.897
#*#
#*# [input_shaper]
#*# shaper_type_x = 2hump_ei
#*# shaper_freq_x = 47.0
#*# shaper_type_y = 2hump_ei
#*# shaper_freq_y = 56.4

x_3d_printer.cfg(シングルノズル、シングルカラー時の設定)

[printer]
kinematics: cartesian
max_velocity: 350
max_accel: 25000
max_z_velocity: 24
max_z_accel: 200
square_corner_velocity: 5

[stepper_x]
step_pin: PE3
dir_pin: !PE2
enable_pin: !PE4
microsteps: 64
rotation_distance: 40
full_steps_per_rotation: 400
endstop_pin: ^!PA15
position_max: 178
position_endstop: -10
position_min: -10
homing_speed: 50

[stepper_y]
step_pin: PE0
dir_pin: !PB9
enable_pin: !PE1
microsteps: 64
rotation_distance: 40
full_steps_per_rotation: 400
endstop_pin: ^!PA12
position_endstop: -5
position_min: -5
position_max: 180
homing_speed: 50

[tmc2208 stepper_x]
uart_pin: PA3
uart_address: 0
run_current: 1.0
stealthchop_threshold: 0
# interpolate: False

[tmc2208 stepper_y]
uart_pin: PA6
uart_address: 0
run_current: 1.0
stealthchop_threshold: 0
# interpolate: False

# [tmc2208 stepper_z]
# uart_pin: PE5
# uart_address: 0
# run_current: 0.350
# hold_current: 0.350
# stealthchop_threshold: 0
# interpolate: False


[extruder]
step_pin: PD6
dir_pin: PD3
enable_pin: !PB3
rotation_distance: 22.885
gear_ratio: 50:17
microsteps: 64
full_steps_per_rotation: 200
nozzle_diameter: 1
filament_diameter: 1.750
max_extrude_only_distance: 200.0
max_extrude_cross_section: 50.0
max_extrude_only_velocity: 75.0
max_extrude_only_accel: 1500
min_temp: 1
max_temp: 300
max_power: 1.0
min_extrude_temp: 75
smooth_time: 2.0
heater_pin: PC3
sensor_type: Generic 3950
sensor_pin: PC1

[tmc2208 extruder]
uart_pin: PA1
uart_address: 0
run_current: 0.650
stealthchop_threshold: 0
interpolate: False

[safe_z_home]
home_xy_position: 66,102
speed: 50
z_hop: 15
z_hop_speed: 5

[bltouch]
sensor_pin: ^PC4
control_pin: PA8
stow_on_each_sample:False
x_offset: 24
y_offset: -12
#z_offset: 0
speed: 10
samples: 3

[bed_mesh]
speed: 250
horizontal_move_z: 10
mesh_min: 18,10
mesh_max: 160,160
probe_count: 5,5

[fan]
pin: PB1
kick_start_time: 0.5

[gcode_macro PAUSE]
rename_existing: PAUSE_OLD
gcode:
    SAVE_GCODE_STATE NAME=PAUSE_state
    PAUSE_OLD
    G91
    G92 E0 ;Reset Extruder
    G1 E-2 F1000
    M125 ; parking
    ;SET_FILAMENT_SENSOR SENSOR=bear_ir ENABLE=0

[gcode_macro RESUME]
rename_existing: RESUME_OLD
gcode:
    G91
    G92 E0 ;Reset Extruder
    ##G1 E0.5 F300
    G90
    ;SET_FILAMENT_SENSOR SENSOR=bear_ir ENABLE=1
    RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
    RESUME_OLD

[gcode_macro CANCEL_PRINT]
rename_existing: CANCEL_PRINT_OLD
gcode:
    M300
    G91 ; relative
    G1 E-0.9 F1800 ; retract
    {% if printer.toolhead.position.z <= 60 %}
        G90
        G0 Z70 F3000
        G91
    {% else %}
        G0 Z5 F3000
    {% endif %}

    G90
    G0 X30 Y150 F3000 ; park toolhead

    CLEAR_PAUSE
    TURN_OFF_HEATERS
    M84 ; disable steppers
    M107 ; fan off
    BED_MESH_CLEAR
    ;SET_FILAMENT_SENSOR SENSOR=bear_ir ENABLE=1
    CANCEL_PRINT_OLD
    SDCARD_RESET_FILE

[gcode_button BUTTON1]
pin: ^!PB2
press_gcode:
	ERCF_UNLOCK

[gcode_button BUTTON2]
pin: ^!PA4
press_gcode:
	M701

[gcode_button BUTTON3]
pin: ^!PE6
press_gcode:
	FILAMENT_PURGE

[gcode_button BUTTON4]
pin: ^!PA2
press_gcode:
	M702

[gcode_button BUTTON5]
pin: ^!PA11
press_gcode:
  {% if printer.print_stats.state == "printing" %}
    PAUSE
  {% elif printer.print_stats.state == "paused" %}
    RESUME
  {% endif %}

[gcode_macro _ERCF_FORM_TIP_STANDALONE]
description: Standalone macro that mimics SS process

# Unloading and Ramming values - Initial moves to form and shape tip
variable_unloading_speed_start: 80     # Fast here to seperate the filament from meltzone (Very intitial retract SS uses distance of E-15)
variable_unloading_speed: 20           # Too fast forms excessively long tip or hair. Slow is better here UNLOADING_SPEED_START/COOLING_MOVES seems a good start
variable_ramming_volume: 20            # in mm3 SS default values = 2, 5, 9, 13, 18, 23, 27. Only Used to Simulate SS Ramming during standalone
variable_ss_ramming: 0                 # Set to 0 when using standalone ramming (RAMMING_VOLUME) or tuning, 1 to let the slicer do it

# Cooling Move Values - To cool the tip formed and separate from strings
variable_cooling_tube_position: 35     # Dragon ST: 35, Dragon HF: 30, Mosquito: 30, Revo: 35, Phaetus Rapido HF: 43;  Measured from Top of Heater Block to Top of Heatsink
variable_cooling_tube_length: 15       # Dragon ST: 15, Dragon HF: 10, Mosquito: 20, Revo: 10, Phaetus Rapido HF: 22; Measured from Nozzle to Top of Heater Block
variable_initial_cooling_speed: 10     # Slow to solidify tip and cool string if formed.
variable_final_cooling_speed: 50       # High speed break the string formed. Too fast = tip deformation during eject. Too Slow = long string/no seperation
variable_toolchange_temp: 0            # Used if you want to lower temp during toolchanges default 0
variable_cooling_moves: 4              # 2-4 is a good start

# SkinnyDip values - To burn off VERY FINE hairs only (This is NOT for long tip reshaping)
variable_use_skinnydip: 1              # Tune this LAST, this is for removal of VERY FINE hairs only (Different than a long tip)
variable_skinnydip_distance: 30        # Start just under Cooling_tube_position and increase - Will depend on how much Ramming Volume is used
variable_dip_insertion_speed: 30       # Medium-Slow - Just long enough to melt the fine hairs. Too slow will pull up molten filament
variable_dip_extraction_speed: 70      # Around 2x Insertion speed, Prevents forming new hairs
variable_melt_zone_pause: 0            # in milliseconds - default 0
variable_cooling_zone_pause: 0         # in milliseconds - default 0 - If you need to adjust here its possible Dip Insertion too slow
variable_use_fast_skinnydip: 0         # Skip the toolhead temp change during skinnydip move - default 0

# Park filament ready to eject
# variable_parking_distance: 0          # TODO: SS parks filament after final cooling move

# Final Eject - for standalone tuning only
variable_final_eject: 0                # default 0, enable during standalone tuning process to eject the filament

gcode:
# Initialize Paramaters
    {% set UNLOADING_SPEED_START = params.UNLOADING_SPEED_START|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['unloading_speed_start']) %}
    {% set UNLOADING_SPEED = params.UNLOADING_SPEED|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['unloading_speed']) %}
    {% set RAMMING_VOLUME = params.RAMMING_VOLUME|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['ramming_volume'], True) %}
    {% set SS_RAMMING = params.SS_RAMMING|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['ss_ramming'], True) %}
    {% set COOLING_TUBE_LENGTH = params.COOLING_TUBE_LENGTH|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['cooling_tube_length']) %}
    {% set COOLING_TUBE_POSITION = params.COOLING_TUBE_POSITION|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['cooling_tube_position']) %}
    {% set INITIAL_COOLING_SPEED = params.INITIAL_COOLING_SPEED|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['initial_cooling_speed']) %}
    {% set FINAL_COOLING_SPEED = params.FINAL_COOLING_SPEED|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['final_cooling_speed']) %}
    {% set COOLING_MOVES = params.COOLING_MOVES|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['cooling_moves']) %}
    {% set TOOLCHANGE_TEMP = params.TOOLCHANGE_TEMP|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['toolchange_temp'],True) %}
    {% set USE_SKINNYDIP = params.USE_SKINNYDIP|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['use_skinnydip'], True) %}
    {% set USE_FAST_SKINNYDIP = params.USE_FAST_SKINNYDIP|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['use_fast_skinnydip'], True) %}
    {% set SKINNYDIP_DISTANCE = params.SKINNYDIP_DISTANCE|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['skinnydip_distance']) %}
    {% set DIP_INSERTION_SPEED = params.DIP_INSERTION_SPEED|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['dip_insertion_speed']) %}
    {% set DIP_EXTRACTION_SPEED = params.DIP_EXTRACTION_SPEED|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['dip_extraction_speed']) %}
    {% set MELT_ZONE_PAUSE = params.MELT_ZONE_PAUSE|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['melt_zone_pause']) %}
    {% set COOLING_ZONE_PAUSE = params.COOLING_ZONE_PAUSE|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['cooling_zone_pause']) %}
    {% set FINAL_EJECT = params.FINAL_EJECT|default(printer['gcode_macro _ERCF_FORM_TIP_STANDALONE']['final_eject'], True) %}

    G91
    G92 E0
    
    #---------------------------------#
    #-Tip forming Process begins here-#
    #---------------------------------#

    SET_PRESSURE_ADVANCE ADVANCE=0
    {% set OLD_TEMP = printer.extruder.target %}
    {% if SS_RAMMING|int == 0 %} # Standalone Ramming
        {% set RATIO = (RAMMING_VOLUME|float) /23.0 %}
        G1 E{0.5784 * RATIO|float} F299 #7
        G1 E{0.5834 * RATIO|float} F302 #3
        G1 E{0.5918 * RATIO|float} F306 #6
        G1 E{0.6169 * RATIO|float} F319 #6
        G1 E{0.3393 * RATIO|float} F350 #0
        G1 E{0.3363 * RATIO|float} F350 #0
        G1 E{0.7577 * RATIO|float} F392 #6
        G1 E{0.8382 * RATIO|float} F434 #3
        G1 E{0.7776 * RATIO|float} F469 #9
        G1 E{0.1293 * RATIO|float} F469 #9
        G1 E{0.9673 * RATIO|float} F501 #2
        G1 E{1.0176 * RATIO|float} F527 #2
        G1 E{0.5956 * RATIO|float} F544 #6
        G1 E{0.4555 * RATIO|float} F544 #6
        G1 E{1.0662 * RATIO|float} F552 #4
    {% endif %}

    # Set toolchange temperature just prior to filament being extracted from melt zone and wait for set point
    # (SKINNYDIP -- normal mode only)
    # Only used if changing between filament types eg. ABS-->PLA
    {% if TOOLCHANGE_TEMP|float > 0 and USE_FAST_SKINNYDIP|int == 0 %}
         M109 S{TOOLCHANGE_TEMP}
    {% endif %}

    # Unloading - This is where the tip spear shape comes from Faster=longer/pointer/higher stringing
    {% set TOTAL_RETRACTION_DISTANCE = COOLING_TUBE_POSITION|float + COOLING_TUBE_LENGTH|float / 2 - 15 %}
    G1 E-15 F{1.0 * UNLOADING_SPEED_START|float * 60} # Default value from SS - Cannot modify
    G1 E-{0.7 * TOTAL_RETRACTION_DISTANCE} F{1.0 * UNLOADING_SPEED|float * 60}
    G1 E-{0.2 * TOTAL_RETRACTION_DISTANCE} F{0.5 * UNLOADING_SPEED|float * 60}
    G1 E-{0.1 * TOTAL_RETRACTION_DISTANCE} F{0.3 * UNLOADING_SPEED|float * 60}

    {% if TOOLCHANGE_TEMP|float > 0 and USE_FAST_SKINNYDIP|int == 1 %}
        M104 S{TOOLCHANGE_TEMP}
    {% endif %}

    # Generate Cooling Moves - Solidifies tip shape and helps break strings if formed
    {% set SPEED_INC = (FINAL_COOLING_SPEED|float - INITIAL_COOLING_SPEED|float) / (2 * COOLING_MOVES|float - 1) %}
    {% for move in range(COOLING_MOVES|int) %}
        G1 E{COOLING_TUBE_LENGTH} F{(INITIAL_COOLING_SPEED|float + SPEED_INC*move*2) * 60}
        G1 E-{COOLING_TUBE_LENGTH} F{(INITIAL_COOLING_SPEED|float + SPEED_INC*(move*2+1)) * 60}
    {% endfor %}

    # Wait for extruder to reach toolchange temperature after cooling moves complete (SKINNYDIP--fast mode only)
    {% if TOOLCHANGE_TEMP|float > 0 and USE_FAST_SKINNYDIP|int == 1 %}
        M109 S{TOOLCHANGE_TEMP}
    {% endif %}

    # Skinny dip Move - burns off VERY FINE hairs
    {% if USE_SKINNYDIP|int == 1 %}
        G1 E{SKINNYDIP_DISTANCE} F{DIP_INSERTION_SPEED|float * 60}
        G4 P{MELT_ZONE_PAUSE}
        G1 E-{SKINNYDIP_DISTANCE} F{DIP_EXTRACTION_SPEED|float * 60}
        G4 P{COOLING_ZONE_PAUSE}
    {% endif %}

    {% if TOOLCHANGE_TEMP|float > 0 %}
        M104 S{OLD_TEMP}
    {% endif %}
    
    # Park filament
    # TODO: park filament after cooling/skinny dip. Maths to determine distance of previous moves to final parking distance
  
    # Eject once all shaping is done - Standalone mode only
    {% if FINAL_EJECT|int == 1 %}
        G92 E0
        G1 E-100 F3000
    {% endif %}

    G92 E0
    G90

###########################################################################
# EndlessSpool handling
# Note that EndlessSpool is an unsupervised filament change
###########################################################################

macro.cfg

# load filament. Slow feed filament into the gear, fast load to cold zone then slow load to nozzle.
[gcode_macro M701]
gcode:
    SAVE_GCODE_STATE NAME=loading_filament
    M83
    G92 E0.0
    G1 E{params.FEED_LENGTH|default(10)|int} F200    ; slow feed filament
    G1 E{params.FAST_LOAD_LENGTH|default(32)|int} F2000    ; Fast load to cold zone
    G1 E{params.SLOW_LOAD_LENGTH|default(30)|int} F100     ; Slow load to nozzle
    G92 E0.0
    RESTORE_GCODE_STATE NAME=loading_filament

# Unload filament. Extrude a small amount, quick pull then slow pull
[gcode_macro M702]
gcode:
    SAVE_GCODE_STATE NAME=unloading_filament
    G91 ; set relative
    G1 E{params.FEED_LENGTH|default(20)|int} F350 
    G92 E0.0
    G1 E-{params.FAST_UNLOAD_LENGTH|default(60)|int} F4000  ; fast unload
    G92 E0.0
    G1 E-{params.SLOW_UNLOAD_LENGTH|default(5)|int} F1000  ; slow unload
    G92 E0.0
    RESTORE_GCODE_STATE NAME=unloading_filament


[gcode_macro RESONANCES_X]
gcode:
  {% if printer.toolhead.homed_axes != "xyz" %}
  G28
  {% endif %}
      TEST_RESONANCES AXIS=X
## ~/klipper/scripts/calibrate_shaper.py /tmp/resonances_x_*.csv -o /tmp/shaper_calibrate_x.png
[gcode_macro RESONANCES_Y]
gcode:
  {% if printer.toolhead.homed_axes != "xyz" %}
  G28
  {% endif %}
      TEST_RESONANCES AXIS=Y
## ~/klipper/scripts/calibrate_shaper.py /tmp/resonances_y_*.csv -o /tmp/shaper_calibrate_y.png

[gcode_macro CALIBRATE_X]
gcode:
  {% if printer.toolhead.homed_axes != "xyz" %}
  G28
  {% endif %}
    SHAPER_CALIBRATE AXIS=X
    SAVE_CONFIG

[gcode_macro CALIBRATE_Y]
gcode:
  {% if printer.toolhead.homed_axes != "xyz" %}
  G28
  {% endif %}
    SHAPER_CALIBRATE AXIS=Y
    SAVE_CONFIG

[gcode_macro PEN_PRE]
gcode:
  {% if printer.toolhead.homed_axes != "xyz" %}
  G28
  {% endif %}
  BED_MESH_CALIBRATE
  BED_MESH_PROFILE LOAD=default
  G1 X0 Y0 Z0

[gcode_macro PEN_MESH]
gcode:
  {% if printer.toolhead.homed_axes != "xyz" %}
  G28
  {% endif %}
  BED_MESH_CALIBRATE
  BED_MESH_PROFILE LOAD=default

[gcode_macro PEN_ZERO]
gcode:
  {% if printer.toolhead.homed_axes != "xyz" %}
  G28
  {% endif %}
  G1 X20 Y20 Z0

[gcode_macro PAPER_SET]
gcode:
  {% if printer.toolhead.homed_axes != "xyz" %}
  G28
  {% endif %}
  BED_MESH_PROFILE LOAD=default
  G90
  G1 Y110 Z50 F3000

[gcode_macro LASER_HOMING]
gcode:
  {% if printer.toolhead.homed_axes != "xyz" %}
  G28
  {% endif %}
      G90
      G1 Z100 F3000

[gcode_macro LASER_ZERO]
gcode:
      G1 X0 Y0
      M106 S1
      G4 P500
      M107

[gcode_macro COLD_PULL]
gcode:
    {% set FARST_TEMP = params.FARST_TEMP|default(230)|float %}
    SET_HEATER_TEMPERATURE HEATER=extruder TARGET={FARST_TEMP}
    M109 S{FARST_TEMP}
    G91
    G92 E0 ;Reset Extruder
    G1 E2 F300
    {% set SECOND_TEMP = params.SECOND_TEMP|default(77)|float %}
    SET_HEATER_TEMPERATURE HEATER=extruder TARGET={SECOND_TEMP}
    M109 S{SECOND_TEMP}
    G92 E0 ;Reset Extruder
    G1 E-150 F120
    TURN_OFF_HEATERS

[gcode_macro PREHEATING_CHAMBER]
gcode:
    {% set TARGET_TEMP = params.TARGET_TEMP|default(100)|float %}
      SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={TARGET_TEMP}
    {% set MINUTES = params.MINUTES|default(30)|float %}
      G4 P{1000 * 60 * MINUTES}
      
[gcode_macro FILAMENT_IN]
gcode:
      M701

[gcode_macro FILAMENT_OUT]
gcode:
      M702

[gcode_macro CALIBRATE]
gcode:
    G28
    PROBE_CALIBRATE
    TESTZ Z=-5

[gcode_macro PROBE_M001]
gcode:
    TESTZ Z=-0.01

[gcode_macro PROBE_P002]
gcode:
    TESTZ Z=0.02

[gcode_macro CALIBRATE_END]
gcode:
    ACCEPT
    G0 Z50
    SAVE_CONFIG

[gcode_macro NOZZLE_CHANGE]
gcode:
    M104 S250
  {% if printer.toolhead.homed_axes != "xyz" %}
  G28
  {% endif %}
    G1 X30 F3000
    G1 Z180 F3000

[gcode_macro M900]
gcode:
    SET_PRESSURE_ADVANCE ADVANCE={params.K|default(0)|float}

[gcode_macro M125]
gcode:
    SAVE_GCODE_STATE NAME=parking
    G91
    G1 Z{params.ZLIFT|default(10)|int} F3000
    G90
    G1 X{params.XPOS|default(170)|int} Y{params.YPOS|default(170)|int} F3000
    RESTORE_GCODE_STATE NAME=parking

[gcode_macro PIDTUNE]
gcode:
    {% set TARGET_TEMP = params.TARGET_TEMP|default(210)|float %}
  PID_CALIBRATE HEATER=extruder TARGET={TARGET_TEMP}
  SAVE_CONFIG

[gcode_macro G29]
gcode:
  {% if printer.toolhead.homed_axes != "xyz" %}
  G28
  {% endif %}
  BED_MESH_CALIBRATE

[gcode_macro M600]
gcode:
 PAUSE

[gcode_macro FILAMENT_PURGE]
gcode:
    SAVE_GCODE_STATE NAME=purge_filament
    M83
    G92 E0.0
    G1 E{params.FEED_LENGTH|default(50)|int} F200
    G92 E0.0
    RESTORE_GCODE_STATE NAME=purge_filament

[gcode_macro FILAMENT_PURGE_SLOW]
gcode:
    SAVE_GCODE_STATE NAME=purge_filament
    M83
    G92 E0.0
    G1 E{params.FEED_LENGTH|default(10)|int} F60
    G92 E0.0
    RESTORE_GCODE_STATE NAME=purge_filament


[gcode_macro START_PRINT]
gcode:
    CLEAR_PAUSE
    M220 S100 ; reset feedrate
    {% if printer.toolhead.homed_axes != "xyz" %}
  G28
  {% endif %}
    G90
    G0 X-2 Y0 Z50 F3000 

    G28 Z ;re-home Z
    ;SET_GCODE_OFFSET Z=0.525
    ;BED_MESH_CALIBRATE AREA_START={params.AREA_START|default("0,0")} AREA_END={params.AREA_END|default("0,0")}
    ;BED_MESH_CALIBRATE AREA_START={print_pos_min_x},{print_pos_min_y} AREA_END={print_pos_max_x},{print_pos_max_y} ;ideamaker
    BED_MESH_CALIBRATE AREA_START={first_layer_print_min[0]},{first_layer_print_min[1]} AREA_END={first_layer_print_max[0]},{first_layer_print_max[1]} ;PlusaSlicer
    ;BED_MESH_PROFILE LOAD="default"


    ;M221 S93 ; Tuned flow

[gcode_macro END_PRINT]
gcode:
 G91 ; relative
    G1 E-0.4 F1800
 {% if printer.toolhead.position.z <= 60 %}
        G90
        G0 Z160 F3000
        G91
    {% else %}
        G0 Z5 F3000
    {% endif %}
    G90 ; absolute pos
    G1 X30 Y170 F3000
    TURN_OFF_HEATERS ; heaters off
    M84 ; disable steppers
    M107 ; fan off
    BED_MESH_CLEAR

[gcode_macro END_PRINT_ERCF]
gcode:
     G91 ; relative
    G1 E-0.4 F2000
     {% if printer.toolhead.position.z <= 60 %}
        G90
        G0 Z160 F3000
        G91
    {% else %}
        G0 Z5 F3000
    {% endif %}
    G90 ; absolute pos
    G1 X30 Y170 F3000
    MMU_EJECT
    TURN_OFF_HEATERS ; heaters off
    M84 ; disable steppers
    M107 ; fan off
    BED_MESH_CLEAR

pa_calibrate.cfg

[gcode_macro PRINT_START]
gcode:
    {% set BED_TEMP = params.BED_TEMP|default(60)|float %}
    {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(190)|float %}
    M140 S{BED_TEMP}
    G90
    G28
    M104 S170 ; set extruder temp for bed leveling
    M109 S170 ; wait for temp
    M190 S{BED_TEMP}
    G1 X-6 F3000
    G1 Z1
    G1 X0 F3000
    G1 X-7 F3000
    G1 X0 F3000
    G28    
    BED_MESH_CALIBRATE
    M104 S{EXTRUDER_TEMP}
    M109 S{EXTRUDER_TEMP}
    G1 X-6 F3000
    G1 Z1
    G1 X0 F3000
    G1 X-7 F3000
    G1 X0 F3000

[gcode_macro PA_CALIBRATE]
gcode:

    {% set nozzle_diameter = params.NOZZLE_DIAMETER|default(0.4)|float %}
    {% set bed_size_x = 180|float %}
    {% set bed_size_y = 180|float %}
    {% set retract = 0.9 | float %}
    {% set retract_speed = 60 * 60|float %}
    {% set filament_diameter = 1.75|float %}
    {% set layer_height = params.LAYER_HEIGHT|default(0.2)|float %}
    {% set nozzle_line_ratio = params.NOZZLE_LINE_RATIO|default(1.13)|float %}
    {% set extrusion_multiplier = 1.0|float %}
    {% set bed_temp = params.BED_TEMP|default(60) %}
    {% set extruder_temp = params.EXTRUDER_TEMP|default(210) %}
    {% set slow_speed = params.SLOW_SPEED|default(25)|float %}
    {% set slow_length = 20 | float %}
    {% set fast_speed = params.FAST_SPEED|default(80)| float %}
    {% set fast_length = 40| float %}
    {% set travel_speed = 105 | float %}
    {% set pa_start = params.PA_START|default(0.005) | float %}
    {% set pa_end = params.PA_END|default(0.1) | float %}
    {% set pa_step = params.PA_STEP|default(0.005) | float %}
    {% set accel = params.MAX_ACCEL|default(3000) | float %}
    {% set deaccel = params.MAX_ACCEL_TO_DECEL|default(3000) | float %}
    {% set line_spacing = 5  | float %}
    ######################################################################################
    ####                           !!! DO NOT EDIT BELOW !!!                           ###
    ######################################################################################
    {% set spacing = line_spacing                                                       %}
    {% set fd      = filament_diameter                                                  %}
    {% set nd      = nozzle_diameter                                                    %}
    {% set ew      = nozzle_diameter * nozzle_line_ratio                                %}
    {% set em      = extrusion_multiplier                                               %}
    {% set lh      = layer_height                                                       %}
    {% set pa      = pa_start                                                           %}
    ##################################[ calculations ]####################################
    {% set slow_speed           = slow_speed * 60                               | float %}
    {% set fast_speed           = fast_speed * 60                               | float %}
    {% set travel_speed         = travel_speed * 60                             | float %}
    {% set lines    = (((pa_end - pa_start) / pa_step) + 1) | round(0, 'ceil')  | int   %}
    {% set p_width  = ((2 * slow_length + fast_length))                                 %}
    {% set p_height = (lines * (spacing + (nd * ew)))                                   %}
    {% set p_width_total  = p_width + 20                                                %}
    {% set p_height_total = p_height + 40                                               %}
    {% set start_x_pos    = (bed_size_x - p_width) / 2                                  %}
    {% set end_x_pos      = (bed_size_x + p_width) / 2                                  %}
    {% set start_y_pos    = (bed_size_y - p_height) / 2                                 %}
    {% set end_y_pos      = (bed_size_y + p_height) / 2                                 %}
    {% set x_pos          = start_x_pos                                                 %}
    {% set y_pos          = start_y_pos                                                 %}
    ########################[ check if test patter fits on bed ]##########################
    {% if p_height_total > bed_size_y or p_width_total > bed_size_x %}
      {% set exceeds_bed_area = true  %}
    {% else %}
      {% set exceeds_bed_area = false %}
    {% endif %}
    ######################################################################################
    ### Using Slic3r flow math to calculate extrusion amounts:                         ###
    ######################################################################################
    ### V_in  = (pi * fd ** 2) / 4 * E                                                 ###
    ### V_out = A * L * em                                                             ###
    ### V_in  = V_out                                                                  ###
    ### A     = (ew - lh) * lh + pi * (lh / 2) ** 2                                    ###
    ### E     = ((A * L * 4) / (pi * fd ** 2)) * em                                    ###
    ######################################################################################
    {% set pi      = 3.141592654                                     | float            %}
    {% set A       = (ew - lh) * lh + pi * (lh / 2) ** 2             | float            %}
    {% set E_prime = (((A * p_height * 4) / (pi * fd ** 2)) * 1.6)   | round(6, 'ceil') %}
    {% set E_frame = (((A * ( p_height+ 2 ) * 4) / (pi * fd ** 2)) * 1.6)   | round(6, 'ceil') %}
    {% set E_slow  = (((A * slow_length * 4) / (pi * fd ** 2)) * em) | round(6, 'ceil') %}
    {% set E_fast  = (((A * fast_length * 4) / (pi * fd ** 2)) * em) | round(6, 'ceil') %}
    {% set E_mark  = (((A * 20 * 4) / (pi * fd ** 2)) * em)          | round(6, 'ceil') %}
    ######################################################################################
    ### START CALIBRATION ###
    PRINT_START BED_TEMP={bed_temp} EXTRUDER_TEMP={extruder_temp}
    SET_VELOCITY_LIMIT ACCEL={accel} ACCEL_TO_DECEL={deaccel}
    ### PRIME NOZZLE ###
    M83 ; set relative extrusion mode
    G1 X{ x_pos - 10 } Y{ y_pos } F{ travel_speed } ; move to prime line start
    G1 Z{ layer_height } ; move Z down
    G1 Y{ y_pos + p_height } E{ E_prime } F { slow_speed } ; print first prime line
    G1 X{ x_pos - 5 } F{ travel_speed } ; move to second prime line start
    G1 Y{ y_pos } E{ E_prime } F { slow_speed } ; print second prime line
    G1 Z{ layer_height + 0.3 } ; move Z up
    ### FRAME ###
    G1 X{ x_pos } Y{ y_pos - 1 } F{ travel_speed }
    G1 Z{ layer_height } ; move Z down
    G1 Y{ y_pos + p_height + 1 } E{ E_frame } F { slow_speed } ; frame left 
    G1 X{ end_x_pos } Y{ y_pos - 1 } F{ travel_speed }
    G1 Z{ layer_height } ; move Z down
    G1 Y{ y_pos + p_height + 1 } E{ E_frame } F { slow_speed } ; frame right
    G1 E-{ retract } F{ retract_speed } ; retract
    G1 Z{ layer_height + 0.3 } ; move Z up
    G92 E0
    ### START TEST PATTERN ###
    SET_PRESSURE_ADVANCE EXTRUDER=extruder ADVANCE={ pa }
    {% for i in range(lines) %}
        {% if not loop.first %}
            {% set y_pos = y_pos + (i * (spacing + ew)) %}
            {% set pa = pa + (i * pa_step) %}
            SET_PRESSURE_ADVANCE EXTRUDER=extruder ADVANCE={ pa }
        {% endif %}
        M117 PA={ pa }
        ### move to line starting postion
        G1 X{ x_pos } Y{ y_pos } F{ travel_speed }
        G1 E{ retract } F{ retract_speed } ; un-retract
        G1 Z{ layer_height } ; move Z down
        ### print first slow part
        {% set x_pos = x_pos + slow_length %}
        G1 X{ x_pos } Y{ y_pos } E{ E_slow } F{ slow_speed }
        ### print fast part
        {% set x_pos = x_pos + fast_length %}
        G1 X{ x_pos } Y{ y_pos } E{ E_fast } F{ fast_speed }
        ### print second slow part
        {% set x_pos = x_pos + slow_length %}
        G1 X{ x_pos } Y{ y_pos } E{ E_slow } F{ slow_speed }
        G1 E-{ retract } F{ retract_speed } ; retract
        G1 Z{ layer_height + 0.3 } ; move Z up
        ### reset x position
        {% set x_pos = start_x_pos %}
    {% endfor %}

    END_PRINT

fly_adxl345_x.cfg

[mcu adxl]
serial: /dev/serial/by-id/usb-Klipper_rp2040_E6625C4893486A23-if00
### 查询usb固件id是:ls -l /dev/serial/by-id/
### 把/dev/serial/by-id/usb-Klipper_rp2040_XXXXXXXXXXXXXXXXXXXXX替换查询到的id
[adxl345]
cs_pin: adxl:gpio9
spi_software_sclk_pin: adxl:gpio10
spi_software_mosi_pin: adxl:gpio11
spi_software_miso_pin: adxl:gpio12

[resonance_tester]
accel_chip: adxl345
probe_points:
    90,90,20

fly_adxl345_y.cfg

[mcu adxl]
serial: /dev/serial/by-id/usb-Klipper_rp2040_E6625C4893716523-if00
### 查询usb固件id是:ls -l /dev/serial/by-id/
### 把/dev/serial/by-id/usb-Klipper_rp2040_XXXXXXXXXXXXXXXXXXXXX替换查询到的id
[adxl345]
cs_pin: adxl:gpio9
spi_software_sclk_pin: adxl:gpio10
spi_software_mosi_pin: adxl:gpio11
spi_software_miso_pin: adxl:gpio12

[resonance_tester]
accel_chip: adxl345
probe_points:
    90,90,20

x_laser_plotter.cfg

# This file contains an example configuration to use a PWM-controlled tool
# such as a laser or spindle.
# See docs/Using_PWM_Tools.md for a more detailed description.

# [output_pin TOOL]
# pin: PB1      # use your fan's pin number
# pwm: True
# hardware_pwm: True
# cycle_time: 0.001
# shutdown_value: 0
# maximum_mcu_duration: 5
# Default: 0 (disabled)
# Amount of time in which the host has to acknowledge
# a non-shutdown output value.
# Suggested value is around 5 seconds.
# Use a value that does not burn up your stock.
# Please note that during homing, your tool
# needs to be in default speed.
[fan]
pin: PB1
kick_start_time: 0.01

[gcode_macro M3]
gcode:
    {% set S = params.S|default(0.0)|float %}
    SET_PIN PIN=TOOL VALUE={S / 255.0}

[gcode_macro M4]
gcode:
    {% set S = params.S|default(0.0)|float %}
    SET_PIN PIN=TOOL VALUE={S / 255.0}

[gcode_macro M5]
gcode:
    SET_PIN PIN=TOOL VALUE=0

[printer]
kinematics: cartesian
max_velocity: 105
max_accel: 1000
max_z_velocity: 24
max_z_accel: 240
square_corner_velocity: 5

[stepper_x]
step_pin: PE3
dir_pin: !PE2
enable_pin: !PE4
microsteps: 32
rotation_distance: 40
full_steps_per_rotation: 400
endstop_pin: ^!PA15
position_max: 168
position_endstop: -5.5
position_min: -6.5
homing_speed: 50

[stepper_y]
step_pin: PE0
dir_pin: !PB9
enable_pin: !PE1
microsteps: 32
rotation_distance: 40
full_steps_per_rotation: 400
endstop_pin: ^!PA12
position_endstop: -48
position_max: 135
position_min: -49
homing_speed: 50

[tmc2208 stepper_x]
uart_pin: PA3
uart_address: 0
run_current: 1.0
stealthchop_threshold: 0
interpolate: False

[tmc2208 stepper_y]
uart_pin: PA6
uart_address: 0
run_current: 1.0
stealthchop_threshold: 0
interpolate: False

# [tmc2208 stepper_z]
# uart_pin: PE5
# uart_address: 0
# run_current: 0.350
# hold_current: 0.350
# stealthchop_threshold: 0
# interpolate: False

[tmc2208 extruder]
uart_pin: PA1
uart_address: 0
run_current: 0.650
stealthchop_threshold: 0
interpolate: False

[safe_z_home]
# home_xy_position: 63.5,59
home_xy_position: 0,0
speed: 50
z_hop: 15
z_hop_speed: 5

[bltouch]
sensor_pin: ^PC4
control_pin: PA8
stow_on_each_sample:False
x_offset: 26.5
y_offset: 31
#z_offset: 0
speed: 10
samples: 3


[bed_mesh]
speed: 105
horizontal_move_z: 10
mesh_min: 18,10
mesh_max: 160,130
probe_count: 5,5



[gcode_macro CANCEL_PRINT]
rename_existing: CANCEL_PRINT_OLD
gcode:
    G90
    G0 X30 Y120 F3000 ; park toolhead
    CLEAR_PAUSE
    M84 ; disable steppers
    M107 ; fan off
    BED_MESH_CLEAR
    CANCEL_PRINT_OLD
    SDCARD_RESET_FILE


[gcode_macro RESUME]
rename_existing: RESUME_OLD
gcode:
    G91
    G90
    ;SET_FILAMENT_SENSOR SENSOR=bear_ir ENABLE=1
    RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
    RESUME_OLD

[gcode_macro PAUSE]
rename_existing: PAUSE_OLD
gcode:
    SAVE_GCODE_STATE NAME=PAUSE_state
    PAUSE_OLD
    G91
    M125 ; parking
    ;SET_FILAMENT_SENSOR SENSOR=bear_ir ENABLE=0

x_laser_plotter_Y180.cfg

[fan]
pin: PB1
kick_start_time: 0.001

[printer]
kinematics: cartesian
max_velocity: 105
max_accel: 1000
max_z_velocity: 24
max_z_accel: 240
square_corner_velocity: 5

[stepper_x]
step_pin: PE3
dir_pin: PE2
enable_pin: !PE4
microsteps: 32
rotation_distance: 40
full_steps_per_rotation: 200
endstop_pin: ^!PA15
position_max: 168
position_endstop: -5.5
position_min: -5.5
homing_speed: 50

[stepper_y]
step_pin: PE0
dir_pin: PB9
enable_pin: !PE1
microsteps: 32
rotation_distance: 40
full_steps_per_rotation: 200
endstop_pin: ^!PA12
position_endstop: -5
position_max: 180
position_min: -5
homing_speed: 50

[tmc2208 stepper_x]
uart_pin: PA3
uart_address: 0
run_current: 1.0
stealthchop_threshold: 0
interpolate: False

[tmc2208 stepper_y]
uart_pin: PA6
uart_address: 0
run_current: 1.0
stealthchop_threshold: 0
interpolate: False

# [tmc2208 stepper_z]
# uart_pin: PE5
# uart_address: 0
# run_current: 0.350
# hold_current: 0.350
# stealthchop_threshold: 0
# interpolate: False

[tmc2208 extruder]
uart_pin: PA1
uart_address: 0
run_current: 0.650
stealthchop_threshold: 0
interpolate: False

[bltouch]
sensor_pin: ^PC4
control_pin: PA8
stow_on_each_sample:False
x_offset: 26.5
y_offset: 31
#z_offset: 0
speed: 10
samples: 3

[bed_mesh]
speed: 105
horizontal_move_z: 10
mesh_min: 18,10
mesh_max: 160,130
probe_count: 5,5

[gcode_macro CANCEL_PRINT]
rename_existing: CANCEL_PRINT_OLD
gcode:
    G90
    G0 X30 Y120 F3000 ; park toolhead
    CLEAR_PAUSE
    M84 ; disable steppers
    M107 ; fan off
    BED_MESH_CLEAR
    CANCEL_PRINT_OLD
    SDCARD_RESET_FILE


[gcode_macro RESUME]
rename_existing: RESUME_OLD
gcode:
    G91
    G90
    ;SET_FILAMENT_SENSOR SENSOR=bear_ir ENABLE=1
    RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
    RESUME_OLD

[gcode_macro PAUSE]
rename_existing: PAUSE_OLD
gcode:
    SAVE_GCODE_STATE NAME=PAUSE_state
    PAUSE_OLD
    G91
    M125 ; parking
    ;SET_FILAMENT_SENSOR SENSOR=bear_ir ENABLE=0

x_pen_plotter.cfg

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 1000
max_z_velocity: 24
max_z_accel: 240
square_corner_velocity: 5

[stepper_x]
step_pin: PE3
dir_pin: !PE2
enable_pin: !PE4
microsteps: 32
rotation_distance: 40
full_steps_per_rotation: 400
endstop_pin: ^!PA15
position_max: 180
position_endstop: 0
position_min: -10
homing_speed: 50

[stepper_y]
step_pin: PE0
dir_pin: !PB9
enable_pin: !PE1
microsteps: 32
rotation_distance: 40
full_steps_per_rotation: 400
endstop_pin: ^!PA12
position_endstop: -50
position_max: 130
position_min: -50
homing_speed: 50

[tmc2208 stepper_x]
uart_pin: PA3
uart_address: 0
run_current: 1.0
stealthchop_threshold: 0
interpolate: False

[tmc2208 stepper_y]
uart_pin: PA6
uart_address: 0
run_current: 1.0
stealthchop_threshold: 0
interpolate: False

# [tmc2208 stepper_z]
# uart_pin: PE5
# uart_address: 0
# run_current: 0.350
# hold_current: 0.350
# stealthchop_threshold: 0
# interpolate: False

[tmc2208 extruder]
uart_pin: PA1
uart_address: 0
run_current: 0.650
stealthchop_threshold: 0
interpolate: False

[bltouch]
sensor_pin: ^PC4
control_pin: PA8
stow_on_each_sample:False
x_offset: 17
y_offset: 30
#z_offset: 0
speed: 10
samples: 3

[bed_mesh]
speed: 105
horizontal_move_z: 10
mesh_min: 20,10
mesh_max: 160,125
probe_count: 6,5

[safe_z_home]
home_xy_position: 70,50
speed: 50
z_hop: 15
z_hop_speed: 5

[fan]
pin: PB1
kick_start_time: 0.5

[gcode_macro CANCEL_PRINT]
rename_existing: CANCEL_PRINT_OLD
gcode:
    G91 ; relativet
    {% if printer.toolhead.position.z <= 60 %}
        G90
        G0 Z70 F3000
        G91
    {% else %}
        G0 Z5 F3000
    {% endif %}
    G90
    G0 X30 Y120 F3000 ; park toolhead
    CLEAR_PAUSE
    CANCEL_PRINT_OLD
    SDCARD_RESET_FILE


[gcode_macro RESUME]
rename_existing: RESUME_OLD
gcode:
    G91
    G90
    ;SET_FILAMENT_SENSOR SENSOR=bear_ir ENABLE=1
    RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
    RESUME_OLD

[gcode_macro PAUSE]
rename_existing: PAUSE_OLD
gcode:
    SAVE_GCODE_STATE NAME=PAUSE_state
    PAUSE_OLD
    G91
    M125 ; parking
    ;SET_FILAMENT_SENSOR SENSOR=bear_ir ENABLE=0

x_cutting_plotter.cfg

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 1000
max_z_velocity: 24
max_z_accel: 240
square_corner_velocity: 5

[stepper_x]
step_pin: PE3
dir_pin: !PE2
enable_pin: !PE4
microsteps: 32
rotation_distance: 40
full_steps_per_rotation: 400
endstop_pin: ^!PA15
position_max: 178
position_endstop: 0
position_min: -10
homing_speed: 50

[stepper_y]
step_pin: PE0
dir_pin: !PB9
enable_pin: !PE1
microsteps: 32
rotation_distance: 40
full_steps_per_rotation: 400
endstop_pin: ^!PA12
position_endstop: -42
position_max: 140
position_min: -42
homing_speed: 50

[tmc2208 stepper_x]
uart_pin: PA3
uart_address: 0
run_current: 1.0
stealthchop_threshold: 0
interpolate: False

[tmc2208 stepper_y]
uart_pin: PA6
uart_address: 0
run_current: 1.0
stealthchop_threshold: 0
interpolate: False

# [tmc2208 stepper_z]
# uart_pin: PE5
# uart_address: 0
# run_current: 0.350
# hold_current: 0.350
# stealthchop_threshold: 0
# interpolate: False

[tmc2208 extruder]
uart_pin: PA1
uart_address: 0
run_current: 0.650
stealthchop_threshold: 0
interpolate: False

[bltouch]
sensor_pin: ^PC4
control_pin: PA8
stow_on_each_sample:False
x_offset: 17
y_offset: 27
#z_offset: 0
speed: 10
samples: 3

[bed_mesh]
speed: 105
horizontal_move_z: 10
mesh_min: 20,10
mesh_max: 160,130
probe_count: 6,5

[safe_z_home]
home_xy_position: 70,50
speed: 50
z_hop: 15
z_hop_speed: 5

[fan]
pin: PB1
kick_start_time: 0.5

[gcode_macro RESUME]
rename_existing: RESUME_OLD
gcode:
    G91
    G90
    ;SET_FILAMENT_SENSOR SENSOR=bear_ir ENABLE=1
    RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
    RESUME_OLD

[gcode_macro PAUSE]
rename_existing: PAUSE_OLD
gcode:
    SAVE_GCODE_STATE NAME=PAUSE_state
    PAUSE_OLD
    G91
    M125 ; parking
    ;SET_FILAMENT_SENSOR SENSOR=bear_ir ENABLE=0


[gcode_macro CANCEL_PRINT]
rename_existing: CANCEL_PRINT_OLD
gcode:
    G91 ; relativet
    {% if printer.toolhead.position.z <= 60 %}
        G90
        G0 Z70 F3000
        G91
    {% else %}
        G0 Z5 F3000
    {% endif %}
    G90
    G0 X30 Y120 F3000 ; park toolhead
    CLEAR_PAUSE
    CANCEL_PRINT_OLD
    SDCARD_RESET_FILE

moonraker.conf

[server]
host: 0.0.0.0
port: 7125
# The maximum size allowed for a file upload (in MiB).  Default 1024 MiB
max_upload_size: 1024
# Path to klippy Unix Domain Socket
klippy_uds_address: ~/printer_data/comms/klippy.sock

[file_manager]
# post processing for object cancel. Not recommended for low resource SBCs such as a Pi Zero. Default False
enable_object_processing: False

[authorization]
cors_domains:
    https://my.mainsail.xyz
    http://my.mainsail.xyz
    http://*.local
    http://*.lan
trusted_clients:
    10.0.0.0/8
    127.0.0.0/8
    169.254.0.0/16
    172.16.0.0/12
    100.  削除済み Tailscaleのクライアント機器側アドレスを入れる
    192.168.0.0/16
    FE80::/10
    ::1/128

# enables partial support of Octoprint API

[power printer]
type: tplink_smartplug
address: 192.168.10.14

[octoprint_compat]

# enables moonraker to track and store print history.
[history]

# this enables moonraker announcements for mainsail
[announcements]
subscriptions:
    mainsail

# this enables moonraker's update manager
[update_manager]
refresh_interval: 168
enable_auto_refresh: True

[update_manager mainsail]
type: web
channel: stable
repo: mainsail-crew/mainsail
path: ~/mainsail

[update_manager mainsail-config]
type: git_repo
primary_branch: master
path: ~/mainsail-config
origin: https://github.com/mainsail-crew/mainsail-config.git
managed_services: klipper

### moonraker-timelapse
### Don't forget to include timelapse.cfg to your printer.cfg
### Uncomment to enable moonraker-timelapse


#[update_manager timelapse]
#type: git_repo
#primary_branch: main
#path: ~/moonraker-timelapse
#origin: https://github.com/mainsail-crew/moonraker-timelapse.git
#managed_services: klipper moonraker

#[timelapse]
###   Directory where the generated video will be saved
#output_path: ~/timelapse/
###   Directory where ffmpeg is installed
#ffmpeg_binary_path: /usr/bin/ffmpeg

# Crowsnest update_manager entry
[update_manager crowsnest]
type: git_repo
path: ~/crowsnest
origin: https://github.com/mainsail-crew/crowsnest.git
managed_services: crowsnest
install_script: tools/pkglist.sh

# Sonar update_manager entry
[update_manager sonar]
type: git_repo
path: ~/sonar
origin: https://github.com/mainsail-crew/sonar.git
primary_branch: main
managed_services: sonar
install_script: tools/install.sh

[update_manager fluidd-config]
type: git_repo
primary_branch: master
path: ~/fluidd-config
origin: https://github.com/fluidd-core/fluidd-config.git
managed_services: klipper

[update_manager fluidd]
type: web
channel: stable
repo: fluidd-core/fluidd
path: ~/fluidd

[include moonraker-obico-update.cfg]

[update_manager timelapse]
type: git_repo
primary_branch: main
path: ~/moonraker-timelapse
origin: https://github.com/mainsail-crew/moonraker-timelapse.git
managed_services: klipper moonraker

[update_manager Klipper-Adaptive-Meshing-Purging]
type: git_repo
channel: dev
path: ~/Klipper-Adaptive-Meshing-Purging
origin: https://github.com/kyleisah/Klipper-Adaptive-Meshing-Purging.git
managed_services: klipper
primary_branch: main

[update_manager happy-hare]
type: git_repo
path: ~/Happy-Hare
origin: https://github.com/moggieuk/Happy-Hare.git
primary_branch: main
install_script: install.sh
managed_services: klipper

[mmu_server]
enble_file_preprocessor: True
enable_toolchange_next_pos: True

chip_mesh.cfg



[gcode_macro BED_MESH_CALIBRATE]
rename_existing: BED_MESH_CALIBRATE_BASE
; gcode parameters
variable_parameter_AREA_START : 0,0
variable_parameter_AREA_END : 0,0
; the clearance between print area and probe area 
variable_mesh_area_offset : 5.0
; number of sample per probe point
variable_probe_samples : 3
; minimum and maximum probe count
variable_min_probe_count : 4
; scale up the probe count, the value should be 1.0 ~ < max/min probe count
variable_probe_count_scale_factor : 1.0
gcode:
    {% if params.AREA_START and params.AREA_END %}
        {% set bedMeshConfig = printer["configfile"].config["bed_mesh"] %}
        {% set safe_min_x = bedMeshConfig.mesh_min.split(",")[0]|float %}
        {% set safe_min_y = bedMeshConfig.mesh_min.split(",")[1]|float %}
        {% set safe_max_x = bedMeshConfig.mesh_max.split(",")[0]|float %}
        {% set safe_max_y = bedMeshConfig.mesh_max.split(",")[1]|float %}

        {% set area_min_x = params.AREA_START.split(",")[0]|float %}
		{% set area_min_y = params.AREA_START.split(",")[1]|float %}
		{% set area_max_x = params.AREA_END.split(",")[0]|float %}
		{% set area_max_y = params.AREA_END.split(",")[1]|float %}

        {% set meshPointX = bedMeshConfig.probe_count.split(",")[0]|int %}
        {% set meshPointY = bedMeshConfig.probe_count.split(",")[1]|int %}

        {% set meshMaxPointX = meshPointX %}
	    {% set meshMaxPointY = meshPointY %}


        {% if (area_min_x < area_max_x) and (area_min_y < area_max_y) %}
            {% if area_min_x - mesh_area_offset >=  safe_min_x %}
                {% set area_min_x = area_min_x - mesh_area_offset %}
            {% else %}
                {% set area_min_x = safe_min_x %}
            {% endif %}

            {% if area_min_y - mesh_area_offset >=  safe_min_y %}
                {% set area_min_y = area_min_y - mesh_area_offset %}
            {% else %}
                {% set area_min_y = safe_min_y %}
            {% endif %}

            {% if area_max_x + mesh_area_offset <=  safe_max_x %}
                {% set area_max_x = area_max_x + mesh_area_offset %}
            {% else %}
                {% set area_max_x = safe_max_x %}
            {% endif %}

            {% if area_max_y + mesh_area_offset <=  safe_max_y %}
                {% set area_max_y = area_max_y + mesh_area_offset %}
            {% else %}
                {% set area_max_y = safe_max_y %}
            {% endif %}

            {% set meshPointX = (meshPointX * (area_max_x - area_min_x) / (safe_max_x - safe_min_x)  * probe_count_scale_factor|float)|round(0)|int %}
            {% if meshPointX < min_probe_count %}
                {% set meshPointX = min_probe_count %}
            {% endif %}
            {% if meshPointX > meshMaxPointX %}
                {% set meshPointX = meshMaxPointX %}
            {% endif %}

            {% set meshPointY = (meshPointY * (area_max_y -area_min_y ) / (safe_max_y - safe_min_y) * probe_count_scale_factor|float)|round(0)|int %}
            {% if meshPointY < min_probe_count %}
                {% set meshPointY = min_probe_count %}
            {% endif %}
            {% if meshPointY > meshMaxPointY %}
                {% set meshPointY = meshMaxPointY %}
            {% endif %}

            BED_MESH_CALIBRATE_BASE mesh_min={area_min_x},{area_min_y} mesh_max={area_max_x},{area_max_y} probe_count={meshPointX},{meshPointY} samples={probe_samples|int}
        {% else %}
            BED_MESH_CALIBRATE_BASE
        {% endif %}
    {% else %}
        BED_MESH_CALIBRATE_BASE
    {% endif %}

mmu_root.cfg(ERCF シングルノズル、マルチカラー時の設定)

[include mmu/base/*.cfg]
[include mmu/optional/client_macros.cfg]
#[include mmu/optional/mmu_ercf_compat.cfg]
#[include mmu/optional/mmu_menu.cfg]

[printer]
kinematics: cartesian
max_velocity: 350
max_accel: 20000
max_z_velocity: 24
max_z_accel: 200
square_corner_velocity: 5

[stepper_x]
step_pin: PE3
dir_pin: !PE2
enable_pin: !PE4
microsteps: 64
rotation_distance: 40
full_steps_per_rotation: 400
endstop_pin: ^!PA15
position_max: 178
position_endstop: -10
position_min: -10
homing_speed: 50

[stepper_y]
step_pin: PE0
dir_pin: !PB9
enable_pin: !PE1
microsteps: 64
rotation_distance: 40
full_steps_per_rotation: 400
endstop_pin: ^!PA12
position_endstop: -5
position_min: -5
position_max: 180
homing_speed: 50

[tmc2208 stepper_x]
uart_pin: PA3
uart_address: 0
run_current: 1.0
stealthchop_threshold: 0
# interpolate: False

[tmc2208 stepper_y]
uart_pin: PA6
uart_address: 0
run_current: 1.0
stealthchop_threshold: 0
# interpolate: False

# [tmc2208 stepper_z]
# uart_pin: PE5
# uart_address: 0
# run_current: 0.350
# hold_current: 0.350
# stealthchop_threshold: 0
# interpolate: False

[extruder]
step_pin: PD6
dir_pin: PD3
enable_pin: !PB3
rotation_distance: 22.885
gear_ratio: 50:17
microsteps: 64
full_steps_per_rotation: 200
nozzle_diameter: 1
filament_diameter: 1.750
max_extrude_only_distance: 200.0
max_extrude_cross_section: 50.0
max_extrude_only_velocity: 75.0
max_extrude_only_accel: 1500
min_temp: 1
max_temp: 300
max_power: 1.0
min_extrude_temp: 75
smooth_time: 2.0
heater_pin: PC3
sensor_type: Generic 3950
sensor_pin: PC1

[tmc2208 extruder]
uart_pin: PA1
uart_address: 0
run_current: 0.650
stealthchop_threshold: 0
interpolate: False

[safe_z_home]
home_xy_position: 66,102
speed: 50
z_hop: 15
z_hop_speed: 5

[bltouch]
sensor_pin: ^PC4
control_pin: PA8
stow_on_each_sample:False
x_offset: 24
y_offset: -12
#z_offset: 0
speed: 10
samples: 3

[bed_mesh]
speed: 250
horizontal_move_z: 10
mesh_min: 18,10
mesh_max: 160,160
probe_count: 5,5

[fan]
pin: PB1
kick_start_time: 0.5

[gcode_button BUTTON1]
pin: ^!PA2
press_gcode:
	MMU_EJECT

[gcode_button BUTTON2]
pin: ^!PA4
press_gcode:
	M701

[gcode_button BUTTON3]
pin: ^!PE6
press_gcode:
	FILAMENT_PURGE

[gcode_button BUTTON4]
pin: ^!PB2
press_gcode:
	MMU_UNLOCK

[gcode_button BUTTON5]
pin: ^!PA11
press_gcode:
  {% if printer.print_stats.state == "printing" %}
    PAUSE 
  {% else %}
   MMU_RECOVER
   RESUME
  {% endif %}


[gcode_macro CANCEL_PRINT]
rename_existing: CANCEL_PRINT_OLD
gcode:
    G91 ; relative
    G1 E-0.9 F1800 ; retract
    {% if printer.toolhead.position.z <= 60 %}
        G90
        G0 Z70 F3000
        G91
    {% else %}
        G0 Z5 F3000
    {% endif %}

    G90
    G0 X30 Y150 F3000 ; park toolhead

    CLEAR_PAUSE
    MMU_EJECT
    TURN_OFF_HEATERS
    M84 ; disable steppers
    M107 ; fan off
    BED_MESH_CLEAR
    ;SET_FILAMENT_SENSOR SENSOR=bear_ir ENABLE=1
    CANCEL_PRINT_OLD
    SDCARD_RESET_FILE

[gcode_macro _PARK]
description: Park toolhead safely away from print
gcode:
    {% set Z_HOP = params.Z_HOP|default(5)|float %}
    {% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
    {% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
    {% set max_z = printer.toolhead.axis_maximum.z|float %}
    {% set act_z = printer.toolhead.position.z|float %}

    {% if act_z < (max_z - Z_HOP) %}
        {% set z_safe = Z_HOP %}
    {% else %}
        {% set z_safe = max_z - act_z %}
    {% endif %}

    G91
    G1 Z{z_safe} F900
    G90
    G0 X{x_park} Y{y_park} F6000


[gcode_macro CALIBRATE_SELECTOR]
gcode:
    {% set tool = params.TOOL|default(0)|int %}
    MMU_CALIBRATE_SELECTOR GATE={tool}
#
# This is an example (but working) PAUSE macro
# You can also use your existing, but it should follow this pattern
#
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
description: Pause the print and park
gcode:
  {% if printer.pause_resume.is_paused %}
    RESPOND MSG="Print is already paused"
  {% else %}
    G92 E0
    G1 E-1.0 F1500.0	; Retract a little to reduce ooze
    G90
    SAVE_GCODE_STATE NAME=PAUSE_state
    BASE_PAUSE
    _PARK Z_HOP=5
  {% endif %}

#
# This is an example (but working) RESUME macro
# You can also use your existing, but it should follow this pattern
#
[gcode_macro RESUME]
rename_existing: BASE_RESUME
description: Resume the print
gcode:
  {% if not printer.pause_resume.is_paused %}
    RESPOND MSG="Print is not paused. Resume ignored"
  {% else %}
    #
    # Good place to add other things like purging or nozzle cleaning
    #
    RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1 MOVE_SPEED=100
    G90
    BASE_RESUME
  {% endif %}

mmu_hardware.cfg


########################################################################################################################
# Happy Hare MMU hardware config file with config for EASY-BRD MCU board
#
# EDIT THIS FILE BASED ON YOUR SETUP
#
# Notes about setup of common external mcus can be found here:
#  https://github.com/moggieuk/Happy-Hare/blob/main/doc/mcu_notes.md
# 
# Note about "touch" endstops: Happy Hare provides extremely flexible homing options using both single steppers or
# synced steppers. The "touch" option leverages stallguard and thus requires the appropriate 'diag_pin' and stallguard
# parameters set on the TMC driver section. If you have the diag_pin exposed, it is harmless to define this because
# they will only be used when explicitly needed and configured.
#
# Touch option for each stepper provides these benefits / possibilities (experimental):
#  - on extruder stepper allows for the automatic detection of the nozzle!
#  - on selector stepper allows for the automatic detection of filament stuck in the gate and subsequent recovery
#  - on gear stepper allows for the automatic detection of the extruder entrance
#
# These sound wonderful right?  They are, but there are caveats:
#  - The external EASY-BRD and ERB mcu's are terrible at detecting stallguard and often result in an "undervoltage
#    error". It is generally possible to get selector touch (TMC2209) tuned especially if you set 'stealthchop_threshold'
#    to a value greater than homing speeds and less than move speed. I.e. the stepper runs in stealthchop mode when
#    homing. [klipper experts will know that it switches the chip mode automatically to stealthchop and then back for
#    Stallguard2 support, howver the automatic switching back to spreadcycle at the end homing move seems to provoke
#    the error condition and setting 'shealthchip_threshold' appropriately avoids this condition. More than you wanted
#    to know I'm sure!
#  - I have not had much luck with touch (stallguard) on the gear stepper with EASY-BRD and ERB mcu's and you really
#    want the extra torque of spreadcycle so adjusting 'stealthchop_threshold' is not really an option
#  - Enabling on the extruder stepper is viable but you will likley have to change jumpers on your main mcu to expose
#    the DIAG pin for whichever driver the extruder stepper is connected to.
#
# In summary, "touch" homing with your MMU is an advanced option that requires patience and careful tuning.  Everything
# works with regular endstops and there are workaround options for certain homing points (like extruder entry) in
# the absence of any endstop. I'm really interested in creative setups. Ping me on Discord (moggieuk#6538)
#
# See 'mmu.cfg' for serial definition and pins aliaes
#
# HOMING CAPABLE EXTRUDER (VERY ADVANCED) -----------------------------------------------------------------------------
# With Happy Hare installed even the extruder can be homed. You will find the usual 'endstop' parameters can be added
# to your '[extruder]' section.  Useless you have some clever load cell attached to your nozzle it only really makes
# sense to configure stallguard style "touch" homing. To do this add lines similar to this to your existing
# '[extruder]' definition in printer.cfg.
#
#    [extruder]
#    endstop_pin: tmc2209_extruder:virtual_endstop
#
# Also be sure to add the appropriate stallguard config to the TMC section, e.g.
#
#    [tmc2209 extruder]
#    diag_pin: E_DIAG		# Set to MCU pin connected to TMC DIAG pin for extruder
#    driver_SGTHRS: 100		# 255 is most sensitive value, 0 is least sensitive
#
# Happy Hare will take care of the rest and add a 'mmu_ext_touch' endstop automatically
#


# FILAMENT DRIVE GEAR STEPPER  -----------------------------------------------------------------------------------------
# Note that 'toolhead' & 'mmu_gear' endstops will automatically be added if a toolhead sensor or gate sensor is defined
#
# The default values are tested with the ERCF BOM NEMA14 motor. Please adapt these values to the motor you are using
# Example : for NEMA17 motors, you'll usually use higher current
#
[tmc2209 stepper_mmu_gear]
uart_pin: mmu:MMU_GEAR_UART
uart_address: 0 			# Only for EASY-BRD
run_current: 0.5			# ERCF BOM NEMA14 motor
hold_current: 0.1			# Recommend to be small if not using "touch" or move (TMC stallguard)
interpolate: False
sense_resistor: 0.110			# Usually 0.11, 0.15 for BTT TMC2226
stealthchop_threshold: 0		# Spreadcycle has more torque and better at speed
#
# Uncomment two lines below if you have TMC and want the ability to use filament "touch" homing with gear stepper
#diag_pin: ^mmu:MMU_GEAR_DIAG		# Set to MCU pin connected to TMC DIAG pin for gear stepper
#driver_SGTHRS: 60			# 255 is most sensitive value, 0 is least sensitive

[stepper_mmu_gear]
step_pin: mmu:MMU_GEAR_STEP
dir_pin: mmu:MMU_GEAR_DIR
enable_pin: !mmu:MMU_GEAR_ENABLE
rotation_distance: 22.7316868		# Bondtech 5mm Drive Gears. Overriden by 'mmu_gear_rotation_distance' in mmu_vars.cfg
gear_ratio: 80:20			# E.g. ERCF 80:20, Tradrack 50:17
microsteps: 16 				# Recommend 16. Increase only if you "step compress" issues when syncing
full_steps_per_rotation: 200		# 200 for 1.8 degree, 400 for 0.9 degree
#
# Uncomment the two lines below to enable filament "touch" homing option with gear motor
#extra_endstop_pins: tmc2209_stepper_mmu_gear:virtual_endstop
#extra_endstop_names: mmu_gear_touch


# SELECTOR STEPPER  ----------------------------------------------------------------------------------------------------
# Consult doc if you want to setup selector for "touch" homing instead or physical endstop
#
[tmc2209 stepper_mmu_selector]
uart_pin: mmu:MMU_GEAR_UART
uart_address: 1 			# Only for EASY-BRD
run_current: 0.5			# ERCF BOM NEMA17 motor
hold_current: 0.2			# Can be small if not using "touch" movement (TMC stallguard)
interpolate: False
sense_resistor: 0.110
stealthchop_threshold: 0		# Stallguard "touch" movement (slower speeds) best done with stealthchop
#
# Uncomment two lines below if you have TMC and want to use selector "touch" movement
#diag_pin: ^mmu:MMU_SEL_DIAG 		# Set to MCU pin connected to TMC DIAG pin for selector stepper
#driver_SGTHRS: 75			# 255 is most sensitive value, 0 is least sensitive

[stepper_mmu_selector]
step_pin: mmu:MMU_SEL_STEP
dir_pin: mmu:MMU_SEL_DIR
enable_pin: !mmu:MMU_SEL_ENABLE
rotation_distance: 40
microsteps: 16 				# Don't need high fidelity
full_steps_per_rotation: 200		# 200 for 1.8 degree, 400 for 0.9 degree
endstop_pin: ^mmu:MMU_SEL_ENDSTOP	# Selector microswitch
endstop_name: mmu_sel_home
#
# Uncomment two lines below to give option of selector "touch" movement
#extra_endstop_pins: tmc2209_stepper_mmu_selector:virtual_endstop
#extra_endstop_names: mmu_sel_touch


# SELECTOR SERVO -------------------------------------------------------------------------------------------------------
# Basic servo PWM setup. If these values are changed then the angles defined for different positions will also change
#
[mmu_servo mmu_servo]
pin: mmu:MMU_SERVO
maximum_servo_angle: 180
minimum_pulse_width: 0.00085
maximum_pulse_width: 0.00215


# OPTIONAL GANTRY SERVO FOR FILAMETRIX FILAMENT CUTTER ----------------------------------------------------------------
# Basic servo PWM setup. If these values are changed then the angles defined for different positions will also change
#
# Uncomment only if you have gantry servo
#
#[mmu_servo mmu_gantry_servo]
#pin: 
#maximum_servo_angle:180
#minimum_pulse_width: 0.00075
#maximum_pulse_width: 0.00225
#initial_angle: 180


# ENCODER -------------------------------------------------------------------------------------------------------------
# Encoder measures distance, monitors for runout and clogging and constantly calculates % flow rate
# Note that the encoder_resolution set if is purely a default to get started.  It is set through calibration
# and stored in mmu_vars.cfg
#
[mmu_encoder mmu_encoder]
encoder_pin: ^mmu:MMU_ENCODER		# EASY-BRD: ^PA6, Flytech ERB: ^gpio22
encoder_resolution: 1.0			# This is just a starter value. Overriden by `mmu_encoder_resolution` in mmm_vars.cfg
desired_headroom: 5.0			# The clog/runout headroom that MMU attempts to maintain (closest point to triggering runout)
average_samples: 4			# The "damping" effect of last measurement (higher value means slower clog_length reduction)
flowrate_samples: 20			# How many extruder "movements" on the encoder to measure over for flowrate calc


# FILAMENT SENSORS -----------------------------------------------------------------------------------------------------
# Define the pins for optional sensors in the filament path. All but the pre-gate sensors will be automatically setup as
# both endstops (for homing) and sensors for visibility purposes.
#
# 'pre_gate_switch_pin_X' .. 'mmu_pre_gate_X` sensor detects filament at entry to MMU. X=gate number (0..N)
# 'gate_switch_pin'       .. 'mmu_gate' sensor detects filament at the gate of the MMU
# 'toolhead_switch_pin'   .. 'toolhead' sensor detects filament after extruder entry
# 'extruder_switch_pin'   .. 'extruder' sensor detects filament just before the extruder entry
#
# Sync motor feedback will typically have a tension switch (more important) or both tension and compression
# 'sync_feedback_tension_pin'     .. pin for switch activated when filament is under tension
# 'sync_feedback_compression_pin' .. pin for switch activated when filament is under compression
#
# Simply define pins for any sensor you want to enable, if pin is not set (or the alias is empty) it will be ignored.
# You can also just comment out what you are not using
#
[mmu_sensors]
pre_gate_switch_pin_0: ^mmu:MMU_PRE_GATE_0
pre_gate_switch_pin_1: ^mmu:MMU_PRE_GATE_1
pre_gate_switch_pin_2: ^mmu:MMU_PRE_GATE_2
pre_gate_switch_pin_3: ^mmu:MMU_PRE_GATE_3
pre_gate_switch_pin_4: ^mmu:MMU_PRE_GATE_4
pre_gate_switch_pin_5: ^mmu:MMU_PRE_GATE_5
pre_gate_switch_pin_6: ^mmu:MMU_PRE_GATE_6
pre_gate_switch_pin_7: ^mmu:MMU_PRE_GATE_7
pre_gate_switch_pin_8: ^mmu:MMU_PRE_GATE_8
pre_gate_switch_pin_9: ^mmu:MMU_PRE_GATE_9
pre_gate_switch_pin_10: ^mmu:MMU_PRE_GATE_10
pre_gate_switch_pin_11: ^mmu:MMU_PRE_GATE_11

gate_switch_pin: ^mmu:MMU_GATE_SENSOR
extruder_switch_pin: 
toolhead_switch_pin: 

sync_feedback_tension_pin: 
sync_feedback_compression_pin: 


## MMU OPTIONAL NEOPIXEL LED SUPPORT ------------------------------------------------------------------------------------
## Define the led connection, type and length
##
## (comment out this section if you don't have leds)
#[neopixel mmu_leds]
#pin: mmu:MMU_NEOPIXEL
#chain_count: 7			# Number gates x1 or x2 + 1 (if you want status)
#color_order: GRBW		# Set based on your particular neopixel specification
#
#
## MMU LED EFFECT SEGMENTS ----------------------------------------------------------------------------------------------
## Define neopixel LEDs for your MMU. The chain_count must be large enough for your desired ranges:
##   exit   .. this set of LEDs, one for every gate, usually would be mounted at the exit point of the gate
##   entry  .. this set of LEDs, one for every gate, could be mounted at the entry point of filament into the MMU/buffer
##   status .. this single LED represents the status of the currently selected filament
##
## Note that all sets are optional. You can opt simple to have just the 'exit' set for example. The advantage to having
## both entry and exit LEDs is, for example, so that 'entry' can display gate status while 'exit' displays the color
## 
## The effects requires the installation of Julian Schill's awesome LED effect module:
##   https://github.com/julianschill/klipper-led_effect
## LED's are indexed in the chain from 1..N. Thus to set up LED's on 'exit' and a single 'status' LED on a 4 gate MMU:
##   exit_range:   1-4
##   status_index: 5
## In this example no 'entry' set is configured.
##
## Note the range order is important and depends on your wiring. Thus 1-4 and 4-1 both represent the same LED range
## but mapped to increasing or decreasing gates respectively
##
## Note that Happy Hare provides a convenience wrapper [mmu_led_effect] that not only creates an effect on each of the
## [mmu_leds] specified segments but also each individual LED for atomic control. See mmu_leds.cfg for examples
##
## (this section is harmless and ignored if the 'led_strip' obove doesn't exist - LED support will simply be disabled)
#[mmu_leds]
#num_gates: 6
#led_strip: neopixel:mmu_leds
#exit_range: 1-6
##entry_range: 7-{mmu_num_leds}
#status_index: 7
#frame_rate: 24
#

mmu_parameters.cfg

########################################################################################################################
# Happy Hare main configuration parameters for the klipper module
#
# EDIT THIS FILE BASED ON YOUR SETUP
#
# Note that macro configuration is specifed separately in 'mmu_macro_vars.cfg'.
# Full details in https://github.com/moggieuk/Happy-Hare/tree/main/doc/configuration.md
#
[mmu]
happy_hare_version: 2.60	# Don't mess, used for upgrade detection
#
# The vendor and version config is important to define the capabilities of the MMU and basic CAD dimensions. These can
# all be overridden with the `cad` parameters detailed in the documentation but the vendor setting saves time.
#
# ERCF
# 1.1 original design, add "s" suffix for Sprigy, "b" for Binky, "t" for Triple-Decky
#     e.g. "1.1sb" for v1.1 with Springy mod and Binky encoder
#
# 2.0 new community ERCFv2
#
# Tradrack
# 1.0 add "e" if using encoder is fitted
#
# Prusa
#  - Comming soon (use Other for now)
#
# Other
#  - Generic setup that will require further customization of 'cad' parameters. See doc and section at the end
#
mmu_vendor: ERCF			# MMU family
mmu_version: 1.1s			# MMU hardware version number (add mod suffix documented above)
mmu_num_gates: 6 			# Number of selector gates


# MMU Hardware Limits --------------------------------------------------------------------------------------------------
#
# Define the physical limits of your MMU. These setings will be respected regardless of individual speed settings.
#
gear_max_velocity: 300			# Never to be exceeded gear velocity regardless of specific parameters
gear_max_accel: 1500			# Never to be exceeded gear accelaration regardless of specific parameters
selector_max_velocity: 250		# Never to be exceeded selector velocity regardless of specific parameters
selector_max_accel: 1200		# Never to be exceeded selector accelaration regardless of specific parameters


# Servo configuration  -------------------------------------------------------------------------------------------------
#
# Angle of the servo in three named positions
#   up   = tool is selected and filament is allowed to freely move through gate
#   down = to grip filament
#   move = ready the servo for selector move (optional - defaults to up)
# V2.4 on: These positions are only for initial config they are replaced with calibrated servo positions in `mmu_vars.cfg`
#
# Note that leaving the servo active when down can stress the electronics and is not recommended with EASY-BRD or ERB board
# unless the 5v power supply has been improved and it is not necessary with standard ERCF builds
# Make sure your hardware is suitable for the job!
#
servo_up_angle: 30			# ERCF: MG90S: 30  ; SAVOX SH0255MG: 140 ; Tradrack: 145
servo_down_angle: 140			# ERCF: MG90S: 140 ; SAVOX SH0255MG: 30  ; Tradrack: 1
servo_move_angle: 30			# Optional angle used when selector is moved (defaults to up position)
servo_duration: 0.2			# Duration of PWM burst sent to servo (default non-active mode, automatically turns off)
servo_dwell: 0.5			# Minimum time given to servo to complete movement prior to next move
servo_always_active: 0 			# CAUTION: 1=Force servo to always stay active, 0=Release after movement
servo_active_down: 0			# CAUTION: 1=Force servo to stay active when down only, 0=Release after movement
servo_buzz_gear_on_down: 3		# Whether to "buzz" the gear stepper on down to aid engagement


# Logging --------------------------------------------------------------------------------------------------------------
#
# log_level & logfile_level can be set to one of (0 = essential, 1 = info, 2 = debug, 3 = trace, 4 = stepper moves)
# Generally you can keep console logging to a minimal whilst still sending debug output to the mmu.log file
# Increasing the console log level is only really useful during initial setup to save having to constantly open the log file
# Note: that it is not recommended to keep logging at level greater that 2 (debug) if not debugging an issue because
# of the additional overhead
#
log_level: 1
log_file_level: 3			# Can also be set to -1 to disable log file completely
log_statistics: 1 			# 1 to log statistics on every toolchange (default), 0 to disable (but still recorded)
log_visual: 1				# 1 log visual representation of filament, 0 = disable
log_startup_status: 1			# Whether to log tool to gate status on startup, 1 = summary (default), 2 = full, 0 = disable


# Movement speeds ------------------------------------------------------------------------------------------------------
#
# Long moves are faster than the small ones and used for the bulk of the bowden movement. Note that you can set two fast
# load speeds depending on whether MMU thinks it is pulling from the buffer or from the spool. It is often helpful to
# use a lower speed when pulling from the spool because more force is required to overcome friction and this prevents
# loosing steps. 100mm/s should be "quiet" with the NEMA14 motor but you can go lower for really low noise
#
# NOTE: Encoder cannot keep up much above 350mm/s so make sure 'bowden_apply_correction' is off at very high speeds!
#
gear_from_buffer_speed: 150		# mm/s Normal speed when loading filament. Conservative is 100mm/s, Max around 300mm/s
gear_from_buffer_accel: 400		# Normal accelaration when loading filament
gear_from_spool_speed: 80		# mm/s Use (lower) speed when loading for the first time (i.e. pulling from spool)
gear_from_spool_accel: 100		# Accelaration when loading from spool
#
gear_short_move_speed: 80		# mm/s Speed when making short moves (like incremental retracts with encoder)
gear_short_move_accel: 600		# Usually the same as gear_from_buffer_accel (for short movements)
gear_short_move_threshold: 70		# Move distance that controls application of 'short_move' speed/accel
gear_homing_speed: 50			# mm/s Speed of gear stepper only homing moves (e.g. homing to gate or extruder)

# Speeds of extruder movement. The 'sync' speeds will be used when gear and extruder steppers are moving in sync
#
extruder_load_speed: 16			# mm/s speed of load move inside extruder from homing position to meltzone
extruder_unload_speed: 16		# mm/s speed of unload moves inside of extruder (very initial move from meltzone is 50% of this)
extruder_sync_load_speed: 18		# mm/s speed of synchronized extruder load moves
extruder_sync_unload_speed: 18		# mm/s speed of synchronized extruder unload moves
extruder_homing_speed: 18		# mm/s speed of extruder only homing moves (e.g. to toolhead sensor)

# Selector movement speeds. (Accelaration is defined by physical MMU limits set above and passed to selector stepper driver)
#
selector_move_speed: 100		# mm/s speed of selector movement (not touch)
selector_homing_speed: 60		# mm/s speed of initial selector homing move (not touch)
selector_touch_speed: 80		# mm/s speed of all touch selector moves (if stallguard configured)

# Selector touch (stallguard) operation. If stallguard is configured, then this can be used to switch on touch movement which
# can detect blocked filament path and try to recover automatically but it is more difficult to set up
#
selector_touch_enable: 0		# If selector touch operation configured this can be used to disable it 1=enabled, 0=disabled


# Gate loading/unloading -----------------------------------------------------------------------------------------------
#
# These setttings control the loading and unloading filament at the gate. The primary options are you use a endstop switch
# at the gate (ala TradRack) or an encoder (ERCF default).  You can even have both a gate sensor for loading/parking and
# still use the encoder for other move verification (see advanced 'gate_endstop_to_encoder' option).
# Note: the `encoder` method, due to the nature of its operation will overshoot a little. This is not a problem in practice
# because the overshoot will simply be compensated for in the subsequent fast bowden move.
# 
# Possible gate_homing_endtop names:
#   encoder  - Detect filament position using movement of the encoder
#   mmu_gate - Detect filament using a gate endstop if configured
#
gate_homing_endstop: encoder		# Name of gate endstop, "encoder" forces use of encoder for parking
gate_homing_max: 70			# Maximum move distance to home to the gate (actual move distance for encoder parking)
gate_unload_buffer: 50			# Amount to reduce the fast unload so that filament doesn't overshoot when parking
gate_load_retries: 2			# Number of times MMU will attempt to grab the filament on initial load (max 5)
gate_parking_distance: 23.0 		# Parking postion in the gate (distance back from gate endstop/encoder point)
gate_endstop_to_encoder: 0		# Distance between gate endstop and encoder (IF both fitted. +ve if encoder after endstop)
gate_autoload: 1			# If pre-gate sensor fitted this controls the automatic loading of the gate


# Bowden tube loading/unloading ----------------------------------------------------------------------------------------
#
# In addition to different bowden loading speeds for buffer and non-buffered filament it is possible to detect missed
# steps caused by "jerking" on a heavy spool. If bowden correction is enabled the driver with "believe" the encoder
# reading and make correction moves to bring the filament to within the 'bowden_allowable_load_delta' of the end of
# bowden position (this does require a reliable encoder and is not recommended for very high speed loading >350mm/s)
#
bowden_apply_correction: 1		# 1 to enable, 0 disabled. Requires Encoder
bowden_allowable_load_delta: 20.0	# How close in mm the correction moves will attempt to get to target. Requires Encoder

# This test verifies the filament is free of extruder before the fast bowden movement to reduce possibility of grinding filament
bowden_pre_unload_test: 1		# 1 to check for bowden movement before full pull (slower), 0 don't check (faster). Requires Encoder

# ADVANCED: If pre-unload test is enabled, this controls the detection of successful bowden pre-unload test and represents
# the fraction of allowable mismatch between actual movement and that seen by encoder. Setting to 50% tolerance usually
# works well. Increasing will make test more tolerent. Value of 100% essentially disables error detection
#
bowden_pre_unload_error_tolerance: 50


# Extruder homing -----------------------------------------------------------------------------------------------------
#
# Happy Hare needs a reference "homing point" close to the extruder from which to accurately complete the loading of
# the toolhead. This homing operation takes place after the fast bowden load and it is anticipated that that load
# operation will leave the filament just shy of the homing point. If using a toolhead sensor this initial extruder
# homing is unecessary (but can be forced) because the homing will occur inside the extruder for the optimum in accuracy.
#
# In addition to an entry sensor "mmu_extruder" it is possbile for Happy Hare to "feel" for the extruder gear entry
# by colliding with it. Because this method is not completely deterministic you might find have to find the sweetspot
# for your setup by adjusting the TMC current reduction. Also, touch (stallguard) sensing is possible to configure but
# unfortunately doesn't work well with some external mcu's. Note that reduced current during collision detection can
# also prevent unecessary filament griding
#
# Possible homing_endtop names:
#   collision      - Detect the collision with the extruder gear by monitoring encoder movement (Requires encoder)
#   mmu_gear_touch - Use touch detection when the gear stepper hits the extruder (Requires stallguard)
#   extruder       - If you have a "filament entry" endstop configured (Requires 'extruder' endstop)
#   none           - Don't attempt to home. Only possibiliy if lacking all sensor options (not recommended)
# Note: The homing_endstop will be ignored if a toolhead sensor is available unless `extruder_force_homing: 1`
#
extruder_homing_max: 80			# Maximum distance to advance in order to attempt to home the extruder
extruder_homing_endstop: collision	# Filament homing method/endstop name (fallback if toolhead sensor not available)
extruder_collision_homing_current: 30	# % gear_stepper current (10%-100%) to use when homing to extruder homing (100 to disable)

# In the absence of a toolhead sensor Happy Hare will automatically default to extruder entrance detection regardless
# of this setting, however if you have a toolhead sensor you can still force the additional (unecessary) step of
# initially homing to extruder entrance then home to the toolhead sensor
#
extruder_force_homing: 0


# Default toolhead loading and unloading ------------------------------------------------------------------------------
#
# It is possible to define highly customized loading and unloading sequences, however, unless you have a specialized
# setup it is probably easier to opt for the built-in toolhead loading and unloading sequence which already offers a
# high degree of customization. If you need even more control then edit the _MMU_LOAD_SEQUENCE and _MMU_UNLOAD_SEQUENCE
# macros in mmu_sequence.cfg - but be careful!
#
# An MMU must have a known point at the end of the bowden from which it can precisely load the extruder. Generally this
# will either be the extruder extrance (which is controlled with settings above) or by homing to toolhead sensor. If
# you have toolhead sensor it is past the extruder gear and the driver needs to know the max distance (from end of
# bowden move) to attempt homing
#
toolhead_homing_max: 40			# Maximum distance to advance in order to attempt to home to defined homing endstop

# IMPORTANT: These next three settings are based on the physical dimensions of your toolhead
# Once a homing position is determined, Happy Hare needs to know the final move distance to the nozzle. There is only
# one correct value for your setup - use 'toolhead_ooze_reduction' (which corresponds to the residual filament left in
# your nozzle) to control excessive oozing on load. See doc for table of proposed values for common configurations.
#
# NOTE: If you have a toolhead sensor you can automate the calculation of these parameters! Read about the
# `MMU_CALIBRATE_TOOLHEAD` command (https://github.com/moggieuk/Happy-Hare/wiki/Blobing-and-Stringing)
#
toolhead_extruder_to_nozzle: 74		# Distance from extruder gears (entrance) to nozzle
toolhead_sensor_to_nozzle: 62		# Distance from toolhead sensor to nozzle (ignored if not fitted)
toolhead_entry_to_extruder: 8		# Distance from extruder "entry" sensor to extruder gears (ignored if not fitted)

# TUNING: The is a tuning setting that represents how much residual filament is left behind in the nozzle when filament
# is removed, it is thus used to reduce the extruder loading length and prevent excessive ooze.
# It is important to tune this parameter and not the dimensions above which are shared by other logic. If using a wipetower
# and you experience blobs on it, increase this value (reduce the quantity of filament loaded). If you experience gaps,
# decrease this value. If gaps and already at 0 then perhaps the 'toolhead_extruder_to_nozzle' setting is incorrect.
# Also see 'toolchange_retract' for final in-print blob tuning.
#
# NOTE: If you have a toolhead sensor you can automate the calculation of this parameter! Read about the
# `MMU_CALIBRATE_TOOLHEAD` command (https://github.com/moggieuk/Happy-Hare/wiki/Blobing-and-Stringing)
#
toolhead_ooze_reduction: 0		# Reduction in extruder loading length to fine tune ooze (default: 0mm)

# Distance added to the extruder unload movement to ensure filament is free of extruder. This adds some degree of tolerance
# to slightly incorrect configuration or extruder slippage. However don't use as an excuse for incorrect toolhead settings
#
toolhead_unload_safety_margin: 10	# Extra movement saftey margin (default: 10mm)

# If not synchronizing gear and extruder and you experience a "false" clog detection immediately after the tool change
# it might be because of a long bowden and/or large internal diameter that causes slack in the filament. This optional
# move will tighten the filament after a load
#
toolhead_post_load_tighten: 1		# 1 to enable, 0 disabled. Ignored if 'sync_to_extruder: 1'

# ADVANCED: Controls the detection of successful extruder load/unload movement and represents the fraction of allowable
# mismatch between actual movement and that seen by encoder. Setting to 100% tolerance effectively turns off checking.
# Some designs of extruder have a short move distance that may not be picked up by encoder and cause false errors. This
# allows masking of those errors. However the error often indicates that your extruder load speed is too high or the
# friction is too high on the filament and in that case masking the error is not a good idea. Try reducing friction
# and lowering speed first!
#
toolhead_move_error_tolerance: 60


# Tip forming ---------------------------------------------------------------------------------------------------------
#
# Tip forming responsibity is typically split between slicer (in-print) and standalone macro (not in-print). Whilst
# there is an option to choose for every toolchange, setting 'force_form_tip_standalone: 1' will always do the
# standalone sequence.  Frankly it is usually recommended to disable tip forming in your slicer (except potentially
# the initial ramming) and to do it exclusively in Happy Hare so tuning only has to be done in one place.
#
# When Happy Hare is asked to form a tip it will run the referenced macro. Two are reference examples are provided:
#   _MMU_FORM_TIP .. default tip forming similar to popular slicers like Superslicer and Prusaslicer
#   _MMU_CUT_TIP  .. for Filametrix (ERCFv2) style toolhead filament cutting system
#
# Often it is useful to increase the current for the rapid movement to ensure high torque and no skipped steps
#
# If opting for slicer tip forming you must configure where the slicer leaves the filament in the extruder since
# there is no way to determine this. This can be ignored if all tip forming is performed by Happy Hare
#
force_form_tip_standalone: 0		 # 0 = Default smart behavior, 1 = Always do standalone tip forming (TURN SLICER OFF!)
form_tip_macro: _MMU_FORM_TIP            # Name of macro to call to perform the tip forming (or cutting) operation
extruder_form_tip_current: 100		 # % of extruder current (100%-150%) to use when forming tip (100 to disable)
slicer_tip_park_pos: 0			 # This specifies the position of filament in extruder after slicer tip forming move


# Synchronized gear/extruder movement ----------------------------------------------------------------------------------
#
# This controls whether the extruder and gear steppers are synchronized during printing operations
# If you normally run with maxed out gear stepper current consider reducing it with 'sync_gear_current'
# If equipped with TMC drivers the current of the gear and extruder motors can be controlled to optimize performance.
# This can be useful to control gear stepper temperature when printing with synchronized motor
#
sync_to_extruder: 0			# Gear motor is synchronized to extruder during print
sync_gear_current: 70			# % of gear_stepper current (10%-100%) to use when syncing with extruder during print
sync_form_tip: 0			# Synchronize during standalone tip formation (initial part of unload)

# Optionally it is possible to leverage feedback for a "compression/expansion" sensor in the bowden path from MMU to
# extruder to ensure that the two motors are kept in sync as viewed by the filament (the signal feedback state can be
# binary supplied by one or two switches: -1 (expanded) and 1 (compressed) of proportional value between -1.0 and 1.0
# Requires [mmu_sensors] setting
#
sync_feedback_enable: 0			# 0 = Turn off (even with fitted sensor), 1 = Turn on when printing
sync_multiplier_high: 1.05		# Maximum factor to apply to gear stepper `rotation_distance`
sync_multipler_low: 0.95		# Minimum factor to apply


# Filament Management Options ----------------------------------------------------------------------------------------
#
# - Clog detection is available when encoder is fitted and it can detect when filament is not moving and pause the print
# - EndlessSpool feature allows detection of runout on one spool and the automatic mapping of tool to an alternative
#   gate (spool). Set to '1', this feature requires clog detection or gate sensor or pre-gate sensors. EndlessSpool
#   functionality can optionally be extended to attempt to load an empty gate with 'endless_spool_on_load'. It can
#   also be configured to eject filament remains to a designated gate rather than defaulting to current gate. A custom
#   gate will disable pre-gate runout detection for EndlessSpool because filament end must completely pass through the
#   gate for selector to move
# - Spoolman support will use the SpoolId configured with the gate to load filament details and color from spoolman
#
enable_clog_detection: 2		# 0 = disable, 1 = static length clog detection, 2 = automatic length clog detection
enable_endless_spool: 1			# 0 = disable, 1 = enable endless spool
endless_spool_on_load: 0		# 0 = don't apply endless spool on load, 1 = run endless spool if gate is empty
endless_spool_final_eject: 50		# Extra unload distance on runout to prevent accidental reload
endless_spool_eject_gate: -1		# Which gate to eject the filament remains. -1 = current gate
enable_spoolman: 0			# 0 = disable spoolman support,  1 = enable spoolman (requires spoolman setup)
pending_spool_id_timeout: 20            # Seconds after which this pending spool_id (set with rfid) is voided
#endless_spool_groups:			# Default EndlessSpool groups (see later in file)


# Turn on behavior ---------------------------------------------------------------------------------------------------
#
# MMU can auto-initialize based on previous persisted state. There are 5 levels with each level bringing in
# additional state information requiring progressively less inital setup. The higher level assume that you don't touch
# MMU while it is offline and it can come back to life exactly where it left off!  If you do touch it or get confused
# then issue an appropriate reset command (E.g. MMU_RESET) to get state back to the defaults.
# Enabling `startup_status` is recommended if you use persisted state at level 2 and above
# Levels: 0 = start fresh every time except calibration data (the former default behavior)
#         1 = restore persisted endless spool groups
#         2 = additionally restore persisted tool-to-gate mapping
#         3 = additionally restore persisted gate status (filament availability, material and color, spoolID) (default)
#         4 = additionally restore persisted tool, gate and filament position! (Recommended when MMU is working well)
#
persistence_level: 3


# Print Statistics ---------------------------------------------------------------------------------------------------
#
# These parameters determine how print statistic data is shown in the console. This table shows a lot of data, and
# probably more than you'd want to see. Below you can enable/disable options to your needs.
# 
# +-----------+---------------------+----------------------+----------+
# |  114(46)  |      unloading      |       loading        | complete |
# |   swaps   | pre  |   -   | post | pre  |   -   | post  |   swap   |
# +-----------+------+-------+------+------+-------+-------+----------+
# | all time  | 0:07 | 47:19 | 0:00 | 0:01 | 37:11 | 33:39 |  2:00:38 |
# |     - avg | 0:00 |  0:24 | 0:00 | 0:00 |  0:19 |  0:17 |     1:03 |
# | this job  | 0:00 | 10:27 | 0:00 | 0:00 |  8:29 |  8:30 |    28:02 |
# |     - avg | 0:00 |  0:13 | 0:00 | 0:00 |  0:11 |  0:11 |     0:36 |
# |      last | 0:00 |  0:12 | 0:00 | 0:00 |  0:10 |  0:14 |     0:39 |
# +-----------+------+-------+------+------+-------+-------+----------+
#             Note: Only formats correctly on Python3
# 
# Comma separated list of desired columns
# Options: pre_unload, unload, post_unload, pre_load, load, post_load, total
console_stat_columns: pre_unload, unload, post_unload, pre_load, load, post_load, total

# Comma seperated list of rows. The order determines the order in which they're shown.
# Options: total, total_average, job, job_average, last
console_stat_rows: total, total_average, job, job_average, last

# How you'd want to see the state of the gates and how they're performing
#   string     - poor, good, perfect, etc..
#   percentage - rate of success
#   emoticon   - fun sad to happy faces (python3 only)
console_gate_stat: emoticon

# Always display the full statistics table
console_always_output_full: 1	# 1 = Show full table, 0 = Only show totals out of print


# Tool Change Blob and Stringing Control -----------------------------------------------------------------------------
#
# These parameters can be used to optimize stringing and blobs that can occur when changing tools. In addition to these
# controls, 'toolhead_ooze_reduction' can be used to reduce the loading length of filament into the extruder in all
# circumstances. IMPORTANT: So the config order would be:
#   1. Configure extruder dimensions like 'toolhead_extruder_to_nozzle', etc. These are based on geometry.
#   2. Tweak 'toolhead_ooze_reduction' only if necessary so that filament _just_ appears at the nozzle on load
#   3. Only then, adjust these settings to control stringing and blobs when tool changing in print
#
# NOTE: All of these settings operate IN PRINT ONLY
#
z_hop_height_toolchange: 1.0	# Height in mm of z_hop move on toolchange
z_hop_height_error: 2.0		# Height in mm of z_hop move on pause or error to avoid blob on print
z_hop_speed: 150		# Speed of z_hop move (mm/s). Should be fast (x,y travel speed) if 'z_hop_ramp' is set
z_hop_accel: 5000		# Accelaration of z_hop move (will be limited by printer maximums)
z_hop_ramp: 0                   # Horizontal distance in mm to travel during the lift. Can help break string. Direction is automatic
toolchange_retract: 2           # Retract / un-retract distance to prevent blobs when toolchanging
toolchange_retract_speed: 20    # Speed of the retract move in mm/s


# Misc configurable, but fairly fixed values -------------------------------------------------------------------------
#
extruder: extruder		# Name of the toolhead extruder that MMU is using
timeout_pause: 72000		# Idle time out in seconds used when in MMU pause state
disable_heater: 600		# Delay in seconds after which the hotend heater is disabled in the MMU_PAUSE state
default_extruder_temp: 200	# The baseline temperature for performing swaps and forming tips outside of a print
extruder_temp_variance: 2	# When waiting for extruder temperature this is the +/- permissible variance in degrees (>= 1)
auto_calibrate_gates: 0		# ADVANCED: Automated gate (not gate#0) calibration. 1=calibrated automatically on first load, 0=disabled
strict_filament_recovery: 0	# If enabled with MMU with toolhead sensor, this will cause filament position recovery to
				# perform extra moves to look for filament trapped in the space after extruder but before sensor
filament_recovery_on_pause: 1	# 1 = Run a quick check to determine current filament position on pause/error, 0 = disable
retry_tool_change_on_error: 0	# Whether to automatically retry a failed tool change. If enabled Happy Hare will perform
				# the equivalent of 'MMU_RECOVER' + 'Tx' commands which usually is all that is necessary
				# to recover. Note that enabling this can mask problems with your MMU
print_start_detection: 1	# ADVANCED: Enabled for Happy Hare to automatically detect start and end of print and call
				# _MMU_START_PRINT and _MMU_END_PRINT. Disable if you want to include in your own macros
show_error_dialog: 0		# 1 = show pop-up dialog in addition to console message, 0 = show error in console
encoder_move_validation: 1	# 1 = Normally Encoder validates move distances are within given tolerance
				# 0 = Validation is disabled for many moves (eliminates slight pause between moves but less safe)
gcode_load_sequence: 0		# VERY ADVANCED: Gcode loading sequence 1=enabled, 0=internal logic (default)
gcode_unload_sequence: 0	# VERY ADVANCED: Gcode unloading sequence, 1=enabled, 0=internal logic (default)


# ADVANCED: MMU macro overrides --- ONLY SET IF YOU'RE COMFORTABLE WITH KLIPPER MACROS -------------------------------
#
# 'pause_macro' defines what macro to call on MMU error (must put printer in paused state)
# Other macros are detailed in 'mmu_sequence.cfg'
#
pause_macro: PAUSE
action_changed_macro: _MMU_ACTION_CHANGED	    # Called when action (printer.mmu.action) changes
print_state_changed_macro: _MMU_PRINT_STATE_CHANGED # Called when print state (printer.mmu.print_state) changes
pre_unload_macro: _MMU_PRE_UNLOAD		    # Called before starting the unload
post_form_tip_macro: _MMU_POST_FORM_TIP		    # Called immediately after tip forming
post_unload_macro: _MMU_POST_UNLOAD		    # Called after unload completes
pre_load_macro: _MMU_PRE_LOAD			    # Called before starting the load
post_load_macro: _MMU_POST_LOAD			    # Called after the load is complete
unload_sequence_macro: _MMU_UNLOAD_SEQUENCE	    # VERY ADVANCED: Optionally called based on 'gcode_unload_sequence'
load_sequence_macro: _MMU_LOAD_SEQUENCE		    # VERY ADVANCED: Optionally called based on 'gcode_load_sequence'


# ADVANCED: See documentation for use of these -----------------------------------------------------------------------
#
# Examples...
# Gate:                #0      #1      #2      #3      #4      #5      #6      #7      #8
#gate_material:        PLA,    ABS,    ABS,    ABS+,   PLA,    PLA,    PETG,   TPU,    ABS
#gate_color:           red,    black,  yellow, green,  blue,   indigo, ffffff, grey,   black
#gate_spool_id:        3,      2,      1,      4,      5,      6,      7,      -1,     9
#gate_status:          1,      0,      1,      2,      2,     -1,     -1,      0,      1
#gate_speed_override:  100,    100,    100,    100,    100,    100,    100,    50,     100
#endless_spool_groups: 0,      1,      2,      1,      0,      0,      3,      4,      1
#
# Tool:                T0      T1      T2      T3      T4      T5      T6      T7      T8
#tool_to_gate_map:     0,      1,      2,      3,      4,      5,      6,      7,      8


# ADVANCED/CUSTOM MMU: See documentation for use of these ------------------------------------------------------------
#
# Normally all these settings are set based on your choice of 'mmu_vendor' and 'mmu_version', but they can be overridden.
# If you have selected a vendor of "Other" you must set these else you will get arbitary ERCFv1.1 defaults.
#
#cad_gate0_pos: 4.2			# Approximate distance from endstop to first gate. Used for rough calibration only
#cad_gate_width: 21.0			# Width of each gate
#cad_bypass_offset: 0			# Distance from limit of travel back to the bypass (ERCF v2.0)
#cad_last_gate_offset: 2.0		# Distance from limit of travel back to last gate
#cad_selector_tolerance: 10.0 		# How much extra selector movement to allow
#
#encoder_default_resolution: 0.676	# Approximate resolution(mm) of a single encoder "count". Not used for measurement

mmu_vars.cfg


mmu_macro_vars.cfg

########################################################################################################################
# Happy Hare supporting macro configuration
#
# EDIT THIS FILE BASED ON YOUR SETUP
#
# Supporting set of macros supplied with Happy Hare can be customized by editing the macro "variables" declared here.
#
# This configuration will automatically retained and upgraded between releases (a backup of previous config files will
# always be made for your reference). If you want to customize macros beyond what is possible through these variables
# it is highly recommended you copy the macro to a new name and change the callback macro name in 'mmu_parameters.cfg'
# That way the default macros can still be upgraded but your customization will be left intact
#


# PERSISTED STATE ---------------------------------------------------------
# Happy Hare stored configuration and state in the klipper variables file.
# Since there can only be a single 'save_variables' file, if you already
# have one you will need to merge the two and point this appropriately
#
[save_variables]
filename: /home/pi/printer_data/config/mmu/mmu_vars.cfg


# PRINT START/END ---------------------------------------------------------
#   (base/mmu_software.cfg)
#
[gcode_macro _MMU_SOFTWARE_VARS]
description: Happy Hare optional configuration for print start/end checks
gcode: # Leave empty

# These variables control the behavor of the optional MMU_START_SETUP and MMU_START_LOAD_INITIAL_TOOL macros
variable_user_pre_initialize_extension      : "G28"	; Executed at start of MMU_START_SETUP. Commonly G28 to home
variable_octoprint_compat                   : True	; True to force compatibility with Octoprint print job streaming
variable_home_mmu                           : False	; True/False, Whether to home mmu before print starts
variable_check_gates                        : True	; True/False, Whether to check filament is loaded in all gates used
variable_load_initial_tool                  : True	; True/False, Whether to automatically load initial tool

# These variables control the behavor of the optional MMU_END macro
variable_eject_tool                         : True	; True/False, Whether to eject the tool at the end of the print
variable_reset_ttg                          : False	; True/False, Whether reset TTG map at end of print
variable_dump_stats                         : True	; True/False, Whether to display print stats at end of print


# STATE MACHINE CHANGES ---------------------------------------------------
#   (base/mmu_state.cfg)
#
[gcode_macro _MMU_STATE_VARS]
description: Happy Hare configuration for state change hooks
gcode: # Leave empty

# You can extend functionality to all Happy Hare state change macros by
# adding a command (or call to your gcode macro). E.g for additional
# LED logic
variable_user_action_changed_extension      : ''	; Executed after default logic with duplicate params
variable_user_print_state_changed_extension : ''	; Executed after default logic with duplicate params
variable_user_gate_map_changed_extension    : ''	; Executed after default logic with duplicate params


# LED CONTROL -------------------------------------------------------------
# Only configure if you have LEDs installed
#   (base/mmu_led.cfg)
#
[gcode_macro _MMU_LED_VARS]
description: Happy Hare led macro configuration variables
gcode: # Leave empty

# Default effects for LED segments when not providing action status
# This can be any effect name, 'r,g,b' color, or built-in functional effects:
#   'off'             - LED's off
#   'on'              - LED's white
#   'gate_status'     - indicate gate availability
#   'filament_color'  - indicate filament color
#   'slicer_color'    - display slicer defined set color for each gate (printer.mmu.slicer_color_rgb)
variable_led_enable             : True			; Whether LEDs are enabled at startup (MMU_LED can control)
variable_default_exit_effect    : "gate_status"		;    off|gate_status|filament_color|slicer_color
variable_default_entry_effect   : "filament_color"	;    off|gate_status|filament_color|slicer_color
variable_default_status_effect  : "filament_color"	; on|off|gate_status|filament_color|slicer_color
variable_white_light            : (1, 1, 1)		; RGB color for static white light
variable_black_light            : (.01, 0, .02)		; RGB color used to represent "black" (filament)
variable_empty_light            : (0, 0, 0)		; RGB color used to represent empty gate


# SEQUENCE MACRO - PARKING MOVEMENT CONTROL -------------------------------
# Configure carefully if you 'enable_park: True'
#   (base/mmu_sequence.cfg)
#
[gcode_macro _MMU_SEQUENCE_VARS]
description: Happy Hare sequence macro configuration variables
gcode: # Leave empty

# These contol the movement of the toolhead during toolchange.
# If 'enable_park: False' all movement is disabled in print except when
# handling runout where 'enable_runout_park' controls parking. Allows for
# parking just for runout handling or exclude runout. Parking when out of
# a print is controlled by 'enable_standalone_park'. If parking is enabled
# the 'restore_xy_pos' allows the restoration of toolhead x,y position to
# be deferred to the slicer. This results in less dwell time on the print
# (caution: the z-height will always be restored)
#
variable_enable_park            : True		; True = Enable parking move when printing (not runout), False = disable
variable_enable_park_runout     : True		; True = Enable parking move during runout handling, False = disable
variable_enable_park_standalone : True		; True = Enable parking move when not printing, False = disable
variable_restore_xy_pos         : "last"	; last|next|none - What x,y position the toolhead should travel to after a toolchange
variable_park_xy                : 170, 170	; Coordinates of park position for toolchange
variable_park_z_hop             : 1.0		; Additional Z_hop (mm) when toolchanging (works in and out of print)
variable_travel_speed           : 200		; XY travel speed in mm/s
variable_lift_speed             : 15		; Z travel speed in mm/s
variable_auto_home              : True		; True = Automatically home if necessary, False = disable
variable_park_after_form_tip    : False		; True = if tip cutting to delay move to park position, False = park immediately
variable_timelapse              : False		; True = take frame snapshot after load, False = disable

# You can extend functionality to all Happy Hare sequence macros by adding
# a command (or call to your gcode macro)
variable_user_pre_unload_extension  : ''	; Executed after default logic
variable_user_post_unload_extension : ''	; Executed after default logic
variable_user_pre_load_extension    : ''	; Executed after default logic
variable_user_post_load_extension   : ''	; Executed after default logic but before restoring toolhead position


# CUT_TIP -----------------------------------------------------------------
# Don't need to configure if using tip forming
#   (base/mmu_cut_tip.cfg)
#
[gcode_macro _MMU_CUT_TIP_VARS]
description: Happy Hare toolhead tip cutting macro configuration variables
gcode: # Leave empty

# Whether the toolhead tip cutting macro will return toolhead to initial
# position (usually wipetower) after the cut is complete. If using parking
# logic you may want to disable this and set 'park_after_form_tip: True'
variable_restore_position       : True		; True = return to initial position, False = don't return

# Distance from the internal nozzle tip to the cutting blade. This dimension
# is based on your toolhead and should not be used for tuning
# Note: If you have a toolhead sensor this variable can be automatically determined!
# Read https://github.com/moggieuk/Happy-Hare/wiki/Blobing-and-Stringing
variable_blade_pos              : 37.5		; Distance in mm from internal nozzle tip

# Distance to retract prior to making the cut, this reduces wasted filament
# (left behind in extruder) but might cause clog if set too large and/or if
# there are gaps in the hotend assembly.  This must be less than 'blade_pos'
variable_retract_length         : 32.5		; (5mm less than 'blade_pos' is a good starting point)

# Whether to perform a simple tip forming move after the initial retraction 
# Enabling this adds some time to the cutting but gives some additional cooling
# time of molten filament and avoids potential clogging on some hotends
variable_simple_tip_forming     : True		; True = Perform simple tip forming, False = skip

# This should be the position of the toolhead where the cutter arm just
# lightly touches the depressor pin
variable_pin_loc_xy             : 14, 250	; x,y coordinates of depressor pin

# This distance is added to 'pin_loc_x' to determine the starting position
# and to create a small saftely distance that aids in generating momentum
variable_pin_park_x_dist        : 5.0		; Distance in mm

# Position of the toolhead when the cutter is fully compressed. Should leave
# a small headroom (should be a bit larger than 0, or whatever xmin is) to
# avoid banging the toolhead or gantry
variable_pin_loc_x_compressed   : 0.5		; x coordinate

# Retract length and speed after the cut so that the cutter blade doesn't
# get stuck on return to origin position
variable_rip_length             : 1.0		; Distance in mm to retract to aid lever decompression (>= 0)
variable_rip_speed              : 3		; Speed mm/s

# Pushback of the remaining tip from the cold end into the hotend. This does
# not have to push back all the way, just sufficient to ensure filament
# fragment stays in hot end. Cannot be larger than 'retract_length'
variable_pushback_length        : 5.0		; Distance in mm
variable_pushback_dwell_time    : 0		; Time in ms to dwell after the pushback

# Speed related settings for tip cutting
# Note that if the cut speed is too fast, the steppers can lose steps.
# Therefore, for a cut:
# - We first make a fast move to accumulate some momentum and get the cut
#   blade to the initial contact with the filament
# - We then make a slow move for the actual cut to happen 
variable_travel_speed           : 150		; Speed mm/s
variable_cut_fast_move_speed    : 32		; Speed mm/s
variable_cut_slow_move_speed    : 8		; Speed mm/s
variable_evacuate_speed         : 150		; Speed mm/s
variable_cut_dwell_time         : 50		; Time in ms to dwell at the cut point
variable_cut_fast_move_fraction : 1.0		; Fraction of the move that uses fast move 
variable_extruder_move_speed    : 25		; Speed mm/s for all extruder movement

# Safety margin for fast vs slow travel. When traveling to the pin location
# we make a safer but longer move if we are closer to the pin than this
# specified margin. Usually setting these to the size of the toolhead
# (plus a small margin) should be good enough 
variable_safe_margin_xy         : 30, 30	; Approx toolhead width +5mm, height +5mm)

# If gantry servo option is installed, enable the servo and set up and down
# angle positions
variable_gantry_servo_enabled   : True		; True = enabled, False = disabled
variable_gantry_servo_down_angle: 55		; Angle for when pin is deployed
variable_gantry_servo_up_angle  : 180		; Angle for when pin is retracted


# FORM_TIP ----------------------------------------------------------------
# Don't need to configure if using tip cutting
#   (base/mmu_form_tip.cfg)
#
[gcode_macro _MMU_FORM_TIP_VARS]
description: Happy Hare tip forming macro configuration variables
gcode: # Leave empty

# Step 1 - Ramming
# Ramming is the initial squeeze of filament prior to cooling moves and is
# described in terms of total volume and progression of squeeze intensity
# printing/standalone. This can be separately controlled when printing or
# standalone
variable_ramming_volume            : 0		; Volume in mm^3, 0 = disabled (optionally let slicer do it)
variable_ramming_volume_standalone : 0		; Volume in mm^3, 0 = disabled

# Optionally set for temperature change (reduction). The wait will occur
# before nozzle separation if 'use_fast_skinnydip: False' else after cooling
# moves. Temperature will be restored after tip creation is complete
variable_toolchange_temp        : 0		; 0 = don't change temp, else temp to set
variable_toolchange_fan_assist  : False		; Whether to use part cooling fan for quicker temp change
variable_toolchange_fan_speed   : 50		; Fan speed % if using fan_assist enabled

# Step 2 - Nozzle Separation
# The filament is then quickly separated from the meltzone by a fast movement
# before then slowing to travel the remaining distance to cooling tube. The
# initial fast movement should be as fast as extruder can comfortably perform.
# A good starting point# for slower move is unloading_speed_start/cooling_moves.
# Too fast a slower movement can lead to excessively long tips or hairs
variable_unloading_speed_start  : 80		; Speed in mm/s for initial fast movement
variable_unloading_speed        : 18		; Speed in mm/s for slow move to cooling zone

# Step 3 - Cooling Moves
# The cooling move allows the filament to harden while constantly moving back
# and forth in the cooling tube portion of the extruder to prevent a bulbous
# tip forming. The cooling tube position is measured from the internal nozzle
# to just past the top of the heater block (often it is beneficial to add a
# couple of mm to ensure the tip is in the cooling section. The cooling tube
# length is then the distance from here to top of heatsink (this is the length
# length of the cooling moves). The final cooling move is a fast movement to
# break the string formed.
variable_cooling_tube_position  : 35		; Start of cooling tube. DragonST:35, DragonHF:30, Mosquito:30, Revo:35, RapidoHF:27
variable_cooling_tube_length    : 10		; Movement length. DragonST:15, DragonHF:10, Mosquito:20, Revo:10, RapidoHF:10
variable_initial_cooling_speed  : 10		; Inital slow movement (mm/s) to solidify tip and cool string if formed
variable_final_cooling_speed    : 50		; Fast movement (mm/s) Too fast: tip deformation on eject, Too Slow: long string/no seperation
variable_cooling_moves          : 4		; Number of back and forth cooling moves to make (2-4 is a good start)

# Step 4 - Skinnydip
# Skinnydip is an advanced final move that may have benefit with some
# material like PLA to burn off persistent very fine hairs. To work the
# depth of insertion is critical (start with it disabled and tune last)
# For reference the internal nozzle would be at a distance of
# cooling_tube_position + cooling_tube_length, the top of the heater
# block would be cooling_tube_length away.
variable_use_skinnydip          : True		; True = enable skinnydip, False = skinnydip move disabled
variable_skinnydip_distance     : 30		; Distance to reinsert filament into hotend starting from end of cooling tube
variable_dip_insertion_speed    : 30		; Medium/Slow insertion speed mm/s - Just long enough to melt the fine hairs, too slow will pull up molten filament
variable_dip_extraction_speed   : 70		; Speed mm/s - Around 2x Insertion speed to prevents forming new hairs
variable_melt_zone_pause        : 0		; Pause if melt zone in ms. Default 0
variable_cooling_zone_pause     : 0		; Pause if cooling zone after dip in ms. Default 0
variable_use_fast_skinnydip     : False		; False = Skip the toolhead temp change wait during skinnydip move

# Step 5 - Parking
# Park filament ready to eject
variable_parking_distance       : 0		; Position mm to park the filament at end of tip forming, 0 = leave where filament ends up after tip forming
variable_extruder_eject_speed   : 25		; Speed mm/s used for parking_distance (and final_eject when testing)


# CLIENT MACROS -----------------------------------------------------------
# If using the recommended PAUSE/RESUME/CANCEL_PRINT macros shipped with
# Happy Hare these variables allow for customization and basic extension
#   (optional/client_macros.cfg)
#
[gcode_macro _MMU_CLIENT_VARS]
description: Happy Hare client macro configuration variables
gcode: # Leave empty

variable_retract                : 1.0		; Distance in mm to retract on pause or cancel
variable_retract_speed          : 30		; Speed mm/s of retraction movement
variable_unretract              : 1.0		; Distance in mm to extruder to undo retraction
variable_unretract_speed        : 30		; Speed mm/s of extrusion movement

# You can extend functionality by adding a command (or call to your gcode
# macro). E.g. for additional LED control or custom operations
variable_user_pause_extension   : ''		; Executed after the klipper base pause
variable_user_resume_extension  : ''		; Executed before the klipper base resume
variable_user_cancel_extension  : ''		; Executed before the klipper base cancel_print


###########################################################################
# Tool change macros
# This is automatically created on installation but you can increase or
# reduce this list to match your number of tools in operation
# Note: it is annoying to have to do this but interfaces like Mainsail rely
# on real macro definitions for tools to be visible in the UI
#
[gcode_macro T0]
gcode: MMU_CHANGE_TOOL TOOL=0
[gcode_macro T1]
gcode: MMU_CHANGE_TOOL TOOL=1
[gcode_macro T2]
gcode: MMU_CHANGE_TOOL TOOL=2
[gcode_macro T3]
gcode: MMU_CHANGE_TOOL TOOL=3
[gcode_macro T4]
gcode: MMU_CHANGE_TOOL TOOL=4
[gcode_macro T5]
gcode: MMU_CHANGE_TOOL TOOL=5

mmu.cfg

###########################################################################
# Happy Hare MMU hardware pin config
#
# EDIT THIS FILE BASED ON YOUR SETUP
#
# This contains aliases for pins for MCU type EASY-BRD
#
[mcu mmu]
serial: /dev/serial/by-id/usb-Klipper_samd21g18a_3C629AB95130545120202046190A08FF-if00	# Change to `canbus_uuid: 1234567890` for CANbus setups

# Section to create alias for pins used by MMU for easier integration into Klippain and RatOS.
# The names match those referenced in the mmu_hardware.cfg file. If you get into difficulty
# you can also comment out this aliases definition and configure the pin names directly
# into mmu_hardware.cfg.
#
[board_pins mmu]
mcu: mmu # Assuming using an external / extra mcu dedicated to MMU
aliases:
    MMU_GEAR_UART=PA8,
    MMU_GEAR_STEP=PA4,
    MMU_GEAR_DIR=PA10,
    MMU_GEAR_ENABLE=PA2,
    MMU_GEAR_DIAG=,
    MMU_SEL_UART=PA8,
    MMU_SEL_STEP=PA9,
    MMU_SEL_DIR=PB8,
    MMU_SEL_ENABLE=PA11,
    MMU_SEL_DIAG=PA7,
    MMU_SEL_ENDSTOP=PB9,
    MMU_SERVO=PA5,
    MMU_ENCODER=PA6,
    MMU_GATE_SENSOR=,
    MMU_NEOPIXEL=,
    MMU_PRE_GATE_0=,
    MMU_PRE_GATE_1=,
    MMU_PRE_GATE_2=,
    MMU_PRE_GATE_3=,
    MMU_PRE_GATE_4=,
    MMU_PRE_GATE_5=,
    MMU_PRE_GATE_6=,
    MMU_PRE_GATE_7=,
    MMU_PRE_GATE_8=,
    MMU_PRE_GATE_9=,
    MMU_PRE_GATE_10=,
    MMU_PRE_GATE_11=,

PrusaSlicer 0.4mm開始Gcode

G90 ; use absolute coordinates
M83 ; extruder relative mode
M140 S[first_layer_bed_temperature] ; set bed temp
M190 S[first_layer_bed_temperature] ; wait for bed temp

M104 S170 ; set extruder temp for bed leveling
;
; MBL
;
G28 ; home all without mesh bed level
BED_MESH_CALIBRATE AREA_START={first_layer_print_min[0]},{first_layer_print_min[1]} AREA_END={first_layer_print_max[0]},{first_layer_print_max[1]} 
BED_MESH_PROFILE LOAD=default
M104 S[first_layer_temperature] ; set extruder temp
M109 S[first_layer_temperature] ; wait for extruder temp
G0 X-7 F3000
G0 Z1 F720
G92 E0
;
G1 E10 F720
;
G0 X0 F3000
G0 X-7 F3000
G0 X0 F3000
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32)} Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 4.5} Z{30} F4800

G0 Z0.2 F720
; move right
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32) + 32} E{32 * 0.15} F1000
; move down
G1 Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 4.5 - 1.5} E{1.5 * 0.15} F1000
; move left
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32)} E{32 * 0.30} F800
G92 E0
M221 S95 ; set flow to 95%

PrusaSlicer 0.4mm終了Gcode

END_PRINT

PrusaSlicer ERCF使用時0.4mm開始Gcode

G90 ; use absolute coordinates
M83 ; extruder relative mode
M140 S[first_layer_bed_temperature] ; set bed temp
G28
{if filament_type[initial_tool]=="PC" or filament_type[initial_tool]=="NYLON"}
M104 S{first_layer_temperature[initial_tool]-25} ; set extruder temp for bed leveling
M109 S{first_layer_temperature[initial_tool]-25} ; wait for temp
{elsif filament_type[initial_tool]=="FLEX"}
M104 S210 ; set extruder temp for bed leveling
M109 S210 ; wait for temp
{else}
M104 S170 ; set extruder temp for bed leveling
M109 S170 ; wait for temp
{endif}
G0 X0 Z15 F4800

M190 S[first_layer_bed_temperature] ; wait for bed temp
G0 X-7 F3000
G0 Z1 F720
G0 X0 F3000
G0 X-7 F3000
G0 X0 F3000
;
; MBL
;
G28 ; home all without mesh bed level
BED_MESH_CALIBRATE AREA_START={first_layer_print_min[0]},{first_layer_print_min[1]} AREA_END={first_layer_print_max[0]},{first_layer_print_max[1]} 
BED_MESH_PROFILE LOAD=default
G0 X20 Z4 F720
M104 S[first_layer_temperature] ; set extruder temp
M109 S[first_layer_temperature] ; wait for extruder temp
G1 E-0.9 F1000
T{initial_tool}
G0 X-8 F3000
G0 Z1 F720
FILAMENT_PURGE
G1 E-0.9 F1000
G92 E0
;
; Extrude purge line
;
G0 X0 F3000
G0 X-7 F3000
G0 X0 F3000
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32) + 32} Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 4.5} Z{30} F4800

G0 Z0.2 F720
; move right
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32)} E{32 * 0.15} F1000
; move down
G1 Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 4.5 - 1.5} E{1.5 * 0.15} F1000
; move left
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32) + 32} E{32 * 0.30} F800
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32) + 32 + 3} Z{0.05} F{8000} ; wipe, move close to the bed
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32) + 32 + 3 * 2}  Z0.2 F{8000} ; wipe, move quickly away from the bed
G92 E0
M221 S95 ; set flow to 95%

PrusaSlicer ERCF使用時0.4mm終了Gcode

END_PRINT_ERCF

おれは直角(内回り)

G90 ; use absolute coordinates
M83 ; extruder relative mode
M140 S[first_layer_bed_temperature] ; set bed temp
G28
{if filament_type[initial_tool]=="PC" or filament_type[initial_tool]=="NYLON"}
M104 S{first_layer_temperature[initial_tool]-25} ; set extruder temp for bed leveling
M109 S{first_layer_temperature[initial_tool]-25} ; wait for temp
{elsif filament_type[initial_tool]=="FLEX"}
M104 S210 ; set extruder temp for bed leveling
M109 S210 ; wait for temp
{else}
M104 S170 ; set extruder temp for bed leveling
M109 S170 ; wait for temp
{endif}
G0 X0 Z15 F4800

M190 S[first_layer_bed_temperature] ; wait for bed temp
G0 X-7 F3000
G0 Z1 F720
G0 X0 F3000
G0 X-7 F3000
G0 X0 F3000
;
; MBL
;
G28 ; home all without mesh bed level
BED_MESH_CALIBRATE AREA_START={first_layer_print_min[0]},{first_layer_print_min[1]} AREA_END={first_layer_print_max[0]},{first_layer_print_max[1]} 
BED_MESH_PROFILE LOAD=default
G0 X20 Z4 F720
M104 S[first_layer_temperature] ; set extruder temp
M109 S[first_layer_temperature] ; wait for extruder temp
T{initial_tool}
G0 X-8 F3000
G0 Z1 F720
FILAMENT_PURGE
G1 E-0.9 F1000
G92 E0
;
; Extrude purge line
;
G0 X0 F3000
G0 X-7 F3000
G0 X0 F3000
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32 - 4.5) + 32} Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 4.5} Z{30} F4800
G0 Z0.2 F720
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32 - 4.5)} E{32 * 0.15} F1000
G1 Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 4.5 + 32} E{32 * 0.15} F1000
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32 - 4.5) - 1.5} E{1.5 * 0.15} F1000
G1 Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 4.5 - 1.5} E{33.5 * 0.30} F800
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32 - 4.5) + 32} E{33.5  * 0.30} F800
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32) + 32 - 4.5 + 3} Z{0.05} F{8000}
 ; wipe, move close to the bed
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32) + 32 - 4.5  + 3 * 2}  Z0.2 F{8000} ; wipe, move quickly away from the bed
G92 E0
M221 S95 ; set flow to 95%

おれは直角(外回り)

G90 ; use absolute coordinates
M83 ; extruder relative mode
M140 S[first_layer_bed_temperature] ; set bed temp
G28
{if filament_type[initial_tool]=="PC" or filament_type[initial_tool]=="NYLON"}
M104 S{first_layer_temperature[initial_tool]-25} ; set extruder temp for bed leveling
M109 S{first_layer_temperature[initial_tool]-25} ; wait for temp
{elsif filament_type[initial_tool]=="FLEX"}
M104 S210 ; set extruder temp for bed leveling
M109 S210 ; wait for temp
{else}
M104 S170 ; set extruder temp for bed leveling
M109 S170 ; wait for temp
{endif}
G0 X0 Z15 F4800

M190 S[first_layer_bed_temperature] ; wait for bed temp
G0 X-7 F3000
G0 Z1 F720
G0 X0 F3000
G0 X-7 F3000
G0 X0 F3000
;
; MBL
;
G28 ; home all without mesh bed level
BED_MESH_CALIBRATE AREA_START={first_layer_print_min[0]},{first_layer_print_min[1]} AREA_END={first_layer_print_max[0]},{first_layer_print_max[1]} 
BED_MESH_PROFILE LOAD=default
G0 X20 Z4 F720
M104 S[first_layer_temperature] ; set extruder temp
M109 S[first_layer_temperature] ; wait for extruder temp
T{initial_tool}
G0 X-8 F3000
G0 Z1 F720
FILAMENT_PURGE
G1 E-0.9 F1000
G92 E0
;
; Extrude purge line
;
G0 X0 F3000
G0 X-7 F3000
G0 X0 F3000
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32 - 4.5) + 32} Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 6} Z{30} F4800
G0 Z0.2 F720
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32 - 4.5 - 1.5)} E{33.5 * 0.15} F1000
G1 Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 6 + 32} E{33.5 * 0.15} F1000
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32) - 4.5} E{1.5 * 0.15} F1000
G1 Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 4.5} E{32 * 0.30} F800
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32 - 4.5) + 32} E{32 * 0.30} F800
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32) + 32 - 4.5 + 3} Z{0.05} F{8000}
 ; wipe, move close to the bed
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32) + 32 - 4.5  + 3 * 2}  Z0.2 F{8000} ; wipe, move quickly away from the bed
G92 E0
M221 S95 ; set flow to 95%
G90 ; use absolute coordinates
M83 ; extruder relative mode
M140 S[first_layer_bed_temperature] ; set bed temp
{if filament_type[initial_tool]=="PC" or filament_type[initial_tool]=="NYLON"}
M104 S{first_layer_temperature[initial_tool]-25} ; set extruder temp for bed leveling
GATES_PRECHECK REFERENCED_TOOLS=!referenced_tools! INITIAL_TOOL={initial_tool} ...the other parameters...
G28
M109 S{first_layer_temperature[initial_tool]-25} ; wait for temp
{elsif filament_type[initial_tool]=="FLEX"}
M104 S210 ; set extruder temp for bed leveling
M109 S210 ; wait for temp
{else}
M104 S170 ; set extruder temp for bed leveling
GATES_PRECHECK REFERENCED_TOOLS=!referenced_tools! INITIAL_TOOL={initial_tool} ...the other parameters...
G28
M109 S170 ; wait for temp
{endif}
G0 X0 Z15 F4800

M190 S[first_layer_bed_temperature] ; wait for bed temp
G0 X-7 F3000
G0 Z1 F720
G0 X0 F3000
G0 X-7 F3000
G0 X0 F3000
;
; MBL
;
G28 ; home all without mesh bed level
BED_MESH_CALIBRATE AREA_START={first_layer_print_min[0]},{first_layer_print_min[1]} AREA_END={first_layer_print_max[0]},{first_layer_print_max[1]} 
BED_MESH_PROFILE LOAD=default
G0 X20 Z4 F720
M104 S[first_layer_temperature] ; set extruder temp
M109 S[first_layer_temperature] ; wait for extruder temp
T{initial_tool}
G0 X-8 F3000
G0 Z1 F720
FILAMENT_PURGE
G1 E-0.9 F1000
G92 E0
;
; Extrude purge line
;
G0 X0 F3000
G0 X-7 F3000
G0 X0 F3000
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32 - 4.5) + 32} Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 4.5} Z{30} F4800
G0 Z0.2 F720
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32 - 4.5)} E{32 * 0.15} F1000
G1 Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 4.5 + 32} E{32 * 0.15} F1000
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32 - 4.5) - 1.5} E{1.5 * 0.15} F1000
G1 Y{(max(0, first_layer_print_min[1]) - 4) + 4 - 4.5 - 1.5} E{33.5 * 0.30} F800
G1 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32 - 4.5) + 32} E{33.5  * 0.30} F800
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32) + 32 - 4.5 + 3} Z{0.05} F{8000}
 ; wipe, move close to the bed
G0 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32) + 32 - 4.5  + 3 * 2}  Z0.2 F{8000} ; wipe, move quickly away from the bed
G92 E0
M221 S95 ; set flow to 95%
macro.cfgにある
[gcode_macro START_PRINT]X_printer.cfgに移して
下記をmmu_root.cfgに追記する
[gcode_macro GATES_PRECHECK]
description: Check the gate before starting
gcode:
    {% set REFERENCED_TOOLS = params.REFERENCED_TOOLS|default("")|string %}
    {% set INITIAL_TOOL = params.INITIAL_TOOL|default(0)|int %}

    {% if REFERENCED_TOOLS == "!referenced_tools!" %}
        RESPOND MSG="Happy Hare gcode pre-processor is diabled"
        {% set REFERENCED_TOOLS = INITIAL_TOOL %}
    {% elif REFERENCED_TOOLS == "" %}
        RESPOND MSG="Happy Hare single color print"
        {% set REFERENCED_TOOLS = INITIAL_TOOL %}
    {% endif %}

    MMU_CHECK_GATE TOOLS={REFERENCED_TOOLS}


この記事が気に入ったらサポートをしてみませんか?