[include mainsail.cfg]
[mcu]
serial: /dev/serial/by-path/platform-5200000.usb-usb-0:1.1:1.0-port0

[virtual_sdcard]
path: /home/orangepi/firefly_data/gcodes
on_error_gcode: CANCEL_PRINT


[stepper_x]
step_pin: PF0
dir_pin: PF1
enable_pin: !PD7
microsteps: 16
rotation_distance: 40
endstop_pin: ^PE5
position_endstop: 0
position_max: 520
homing_speed: 50

[stepper_y]
step_pin: PF6
dir_pin: PF7
enable_pin: !PF2
microsteps: 16
rotation_distance: 40
endstop_pin: ^PJ1
position_endstop: 0
position_max: 520
homing_speed: 50

[stepper_z]
step_pin: PL3
dir_pin: !PL1
enable_pin: !PK0
microsteps: 16
rotation_distance: 8
endstop_pin: probe:z_virtual_endstop
#position_endstop: 0
position_max: 500

[extruder]
step_pin: PA4
dir_pin: PA6
enable_pin: !PA2
microsteps: 16
rotation_distance: 33.683
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PB4
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK5
control: pid
pid_Kp: 22.2
pid_Ki: 1.08
pid_Kd: 114
min_temp: 0
max_temp: 250

[heater_bed]
heater_pin: PH5
sensor_type: ATC Semitec 104GT-2
sensor_pin: PK6
control: pid
pid_Kp: 690.34
pid_Ki: 111.47
pid_Kd: 1068.83
min_temp: 0
max_temp: 80

[fan]
pin: PH6

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 500
max_z_velocity: 5
max_z_accel: 100

[bltouch]
sensor_pin: ^PD3
control_pin: PB5
x_offset: -36
y_offset: -3
samples: 3
samples_result: average
samples_tolerance_retries: 3
sample_retract_dist: 5
z_offset: 3.2
# [bltouch]
# z_offset = 0.600

[filament_switch_sensor RunoutSensor]
pause_on_runout: True
runout_gcode:
    SAVE_GCODE_STATE NAME=PAUSE_state
    BASE_PAUSE
    G91
    G1 E-5 F2100
    G1 Z10
    G90
    G1 X0 Y0 F6000
insert_gcode: RESUME
switch_pin: !PE4

[safe_z_home]
home_xy_position: 250, 250 # Change coordinates to the center of your print bed
speed: 50
z_hop: 10                 # Move up 10mm
z_hop_speed: 5

[display]
lcd_type: st7920
cs_pin: PH1
sclk_pin: PA1
sid_pin: PH0
encoder_pins: ^PC4, ^PC6
click_pin: ^!PC2

[bed_mesh]
speed: 200
horizontal_move_z: 5
mesh_min: 20, 35
mesh_max: 480, 465
probe_count: 15, 15
algorithm: bicubic
move_check_distance: 5
split_delta_z: .025

[screws_tilt_adjust]
horizontal_move_z: 5
screw1: 121,425
screw1_name: back left
screw2: 461,425
screw2_name: back right
screw3: 121,85
screw3_name: front left
screw4: 461,85
screw4_name: front right
screw_thread: CCW-M3

[gcode_macro M420]
gcode:
    BED_MESH_PROFILE LOAD=default

[gcode_macro _CLIENT_VARIABLE]
variable_use_custom_pos: True
variable_custom_park_x: 5.0
variable_custom_park_y: 5.0
gcode:

[gcode_macro FILAMENT_LOAD]
gcode:
    M83                   # Put the extruder into relative mode
    G92 E0.0              # Reset the extruder so that it thinks it is at position zero
    G1 E120 F350          # Move the extruder forward 120mm at a speed of 350mm/minute
    G92 E0.0              # Reset the extruder again
    M82                   # Put the extruder back into absolute mode.

[gcode_macro FILAMENT_UNLOAD]
gcode:
    M83                   # Put the extruder into relative mode
    G92 E0.0              # Reset the extruder so that it thinks it is at position zero
    G1 E-120 F350          # Move the extruder forward 120mm at a speed of 350mm/minute
    G92 E0.0              # Reset the extruder again
    M82                   # Put the extruder back into absolute mode.

[gcode_arcs]
resolution: 1.0