Klipper CR10s Pro v2 Config w/BL Touch and Micro Swiss + Satsana

# This file contains pin mappings for the Creality CR-10S Pro V2. To use
# this config, the firmware should be compiled for the AVR atmega2560.

[gcode_macro G29]
gcode:
    #G28
    BED_MESH_CALIBRATE
    G0 X0 Y0 Z10 F6000

[bltouch]
sensor_pin: ^ar19
control_pin: ar11
stow_on_each_sample: False
probe_with_touch_mode: True
x_offset: -48
y_offset: -15
#z_offset = 2.000
z_offset = 1.900
speed: 4.0
samples: 2
sample_retract_dist: 3.0


[virtual_sdcard]
path: ~/gcode_files

[display_status]

[pause_resume]

[bed_mesh]
speed: 120
horizontal_move_z: 5
mesh_min: 5, 5
mesh_max: 268, 300
probe_count: 5,5
fade_start: 1
fade_end: 10

[stepper_x]
step_pin: ar54
dir_pin: ar55
enable_pin: !ar38
rotation_distance: 40
microsteps: 16
full_steps_per_rotation: 200
endstop_pin: ^ar3
position_endstop: -10
position_min: -10
position_max: 355
homing_speed: 50
homing_retract_dist: 5

[stepper_y]
step_pin: ar60
dir_pin: !ar61
enable_pin: !ar56
rotation_distance: 40
microsteps: 16
full_steps_per_rotation: 200
endstop_pin: ^ar14
position_endstop: 0
position_min: 0
position_max: 315
homing_speed: 50
homing_retract_dist: 5

[stepper_z]
step_pin: ar46
dir_pin: !ar48
enable_pin: !ar62
rotation_distance: 8
microsteps: 16
full_steps_per_rotation: 200
endstop_pin: probe:z_virtual_endstop
position_min: -5
position_max: 351

[extruder]
pressure_advance: 0.0775
step_pin: ar26
dir_pin: ar28
enable_pin: !ar24
microsteps: 16
rotation_distance: 24.395
full_steps_per_rotation: 200
nozzle_diameter: 0.400
filament_diameter: 1.750
max_extrude_only_distance: 500.0
max_extrude_only_velocity: 70.0
max_extrude_only_accel: 1000.0
heater_pin: ar10
sensor_type: EPCOS 100K B57560G104F
sensor_pin: analog13
control: pid
pid_Kp: 22.2
pid_Ki: 1.08
pid_Kd: 114
min_extrude_temp: 170
min_temp: 5
max_temp: 275

[heater_bed]
heater_pin: ar8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: analog14
control: pid
pid_Kp: 690.34
pid_Ki: 111.47
pid_Kd: 1068.83
min_temp: 5
max_temp: 140

[fan]
pin: ar9

[mcu]
serial: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AR0JSH3K-if00-port0
pin_map: arduino

[printer]
kinematics: cartesian
max_velocity: 200
max_accel: 1500
max_z_velocity: 10
max_z_accel: 100

[safe_z_home]
home_xy_position: 177,155
speed: 80.0
z_hop: 10.0
z_hop_speed: 5.0

[filament_switch_sensor e0_sensor]
switch_pin: ar2
pause_on_runout: False
runout_gcode:
  PAUSE_PARK

[pause_resume]

[respond]
default_type: echo

[t5uid1]
firmware: dgus_reloaded
machine_name: CR-10S Pro V2
volume: 60
brightness: 50
z_min: 0
z_max: 350

# https://github.com/Desuuuu/klipper-macros
# If you want to use these macros, follow the instructions from the repository
# and uncomment the following lines.

#[save_variables]
#filename: ~/variables.cfg
#
#[delayed_gcode macros_initialize]
#initial_duration: 1
#gcode:
#  INITIALIZE_VARIABLE VARIABLE=park_x VALUE=20
#  INITIALIZE_VARIABLE VARIABLE=park_y VALUE=290
#  INITIALIZE_VARIABLE VARIABLE=bowden_len VALUE=400
#
#[include macros/*.cfg]
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
# change this if you need more or less extrusion
variable_extrude: 1.0
gcode:
  ##### read E from pause macro #####
  {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  ##### set park positon for x and y #####
  # default is your max posion from your printer.cfg
  {% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
  {% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
  ##### calculate save lift position #####
  {% set max_z = printer.toolhead.axis_maximum.z|float %}
  {% set act_z = printer.toolhead.position.z|float %}
  {% if act_z < (max_z - 2.0) %}
      {% set z_safe = 2.0 %}
  {% else %}
      {% set z_safe = max_z - act_z %}
  {% endif %}
  ##### end of definitions #####
  PAUSE_BASE
  G91
  {% if printer.extruder.can_extrude|lower == 'true' %}
    G1 E-{E} F2100
  {% else %}
    {action_respond_info("Extruder not hot enough")}
  {% endif %}
  {% if "xyz" in printer.toolhead.homed_axes %}
    G1 Z{z_safe} F900
    G90
    G1 X{x_park} Y{y_park} F6000
  {% else %}
    {action_respond_info("Printer not homed")}
  {% endif %} 

[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
  ##### read E from pause macro #####
  {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  #### get VELOCITY parameter if specified ####
  {% if 'VELOCITY' in params|upper %}
    {% set get_params = ('VELOCITY=' + params.VELOCITY)  %}
  {%else %}
    {% set get_params = "" %}
  {% endif %}
  ##### end of definitions #####
  {% if printer.extruder.can_extrude|lower == 'true' %}
    G91
    G1 E{E} F2100
  {% else %}
    {action_respond_info("Extruder not hot enough")}
  {% endif %}  
  RESUME_BASE {get_params}

[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
  TURN_OFF_HEATERS
  CANCEL_PRINT_BASE