# This file contains stock 2021/2022 Artillery Sidewinder X2 configuration.

# To use this config, during "make menuconfig" select
# the STM32F401 with a "No bootloader".
# Flash this firmware by usb connection.
# Set the physical bridge between +3.3V and Boot0 PIN on Artillery_Ruby mainboard.
# Then running the command:
# make flash FLASH_DEVICE=/dev/serial/by-id/usb-Klipper_stm32f401xc_4F006F000351383532393535-if00

# See more description here: https://blog.freakydu.de/posts/2022-10-01-klipper_with_artillery_sidewinderx2/
# See docs/Config_Reference.md for a description of parameters.

# Inpput shaper auto-calibration:
# accelerometer configuration
#[include adxl345.cfg]

[include macros.cfg]

[mcu]
serial: /dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.4:1.0
#serial: /dev/ttyACM0
#serial: /dev/serial/by-id/usb-Klipper_stm32f401xc_480066001251383435373136-if00
restart_method: command

[printer]
kinematics: cartesian
max_velocity: 250
max_accel: 1500
max_z_velocity: 50  ## xy / 5
max_z_accel: 400 ## xy / 5
square_corner_velocity: 5.0

[stepper_x]
step_pin: !PB14
dir_pin: PB13
enable_pin: !PB15
microsteps: 16
rotation_distance: 40
endstop_pin: !PA2
position_endstop: 0
position_max: 310
homing_speed: 50
homing_retract_dist: 5.0
second_homing_speed: 10

[stepper_y]
step_pin: PB10
dir_pin: PB2
enable_pin: !PB12
microsteps: 16
rotation_distance: 40
endstop_pin: !PA1
position_endstop: 0
position_max: 310
homing_speed: 50
homing_retract_dist: 5.0
second_homing_speed: 10

[stepper_z]
step_pin: PB0
dir_pin: !PC5
enable_pin: !PB1
microsteps: 16
rotation_distance: 8
endstop_pin: probe:z_virtual_endstop
position_max: 400
position_min: -2  # The Z carriage may need to travel below the Z=0. homing point if the bed has a significant tilt.
homing_speed: 10 ## xy / 5 results in same stepper motor speed like x or y stepper
homing_retract_dist: 5.0
second_homing_speed: 2 ## xy / 5 results in same stepper motor speed like x or y stepper

[extruder]
step_pin: PA7
dir_pin: PA6
enable_pin: !PC4
microsteps: 16
gear_ratio: 3:1
rotation_distance: 20.925 # with gear ration 3:1 configured
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PC9
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC0
#control = pid
#pid_kp = 20.860
#pid_ki = 1.131
#pid_kd = 96.218
min_temp: 0
max_temp: 255
#pressure_advance: 0.11375
pressure_advance: 0.0654 # Calculated on 5/03/24 - Geeetech White PLA - 200°c
max_extrude_only_distance: 101

[bltouch]
sensor_pin: PC2
control_pin: PC3
#x_offset:27.25
x_offset:29
#y_offset:-12.8
y_offset:-37
#z_offset = 3.0
speed:5
samples: 3
samples_result: average
samples_tolerance: 0.050
samples_tolerance_retries: 3

[heater_bed]
heater_pin: PA8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC1
#control = pid
#pid_kp = 42.365
#pid_ki = 0.545
#pid_kd = 822.940
min_temp: 0
max_temp: 130

[fan]
# filament_cooling
pin: PC8
off_below: 0.1

[heater_fan extruder]
# fan on hotend/extruder
pin: PC7
heater: extruder
heater_temp: 50.0
off_below: 0.2

[controller_fan case]
# mainboard, artillery case
pin: PC6
off_below: 0.3
idle_speed: 0.0

[bed_mesh]
speed: 100
mesh_min: 29.25, 12.8
mesh_max: 272.75, 263
algorithm: bicubic
probe_count: 5,5
mesh_pps: 3
fade_start: 1
fade_end: 10

[bed_screws]
# Nozzle / Screws alignment
screw1: 50,50
screw1_name: front left
screw2: 250,50
screw2_name: front right
screw3: 250,250
screw3_name: back right
screw4: 50,250
screw4_name: back left
speed: 100.0

[screws_tilt_adjust]
# BLTouch / Screws alignment
screw1: 21,82
screw1_name: front left
screw2: 231,82
screw2_name: front right
screw3: 231,287
screw3_name: back left
screw4: 21,287
screw4_name: back right
speed: 100.0
screw_thread: CW-M5

[safe_z_home]
home_xy_position: 150,150
z_hop: 15

[neopixel extruder]
pin: PB7
initial_RED: 1.0
initial_GREEN: 1.0
initial_BLUE: 1.0

[temperature_sensor mainboard]
# stm32 temperature sensor
sensor_type: temperature_mcu
min_temp: 10
max_temp: 60

[filament_switch_sensor filament]
pause_on_runout: True # Starts the PAUSE g-code script if filament runs out
runout_gcode: M117 Filament runout # Optional
insert_gcode: M117 Filament insert # Optional
switch_pin: PA0 # the z-endstop pin

# Support for M117 gcode (message display)
[display_status]

# Enable the "M118" and "RESPOND" extended commands.
[respond]

# Support for gcode arc (G2/G3) commands.
[gcode_arcs]
#resolution: 1.0
#   An arc will be split into segments. Each segment's length will
#   equal the resolution in mm set above. Lower values will produce a
#   finer arc, but also more work for your machine. Arcs smaller than
#   the configured value will become straight lines. The default is
#   1mm.

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [bltouch]
#*# z_offset = 2.999
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 	-0.230833, -0.156667, -0.135000, -0.115833, -0.074167
#*# 	-0.223333, -0.133333, -0.064167, -0.008333, 0.050000
#*# 	-0.240000, -0.113333, 0.008333, 0.087500, 0.173333
#*# 	-0.152500, -0.042500, 0.047500, 0.117500, 0.187500
#*# 	-0.359167, -0.287500, -0.123333, -0.020833, 0.074167
#*# x_count = 5
#*# y_count = 5
#*# mesh_x_pps = 3
#*# mesh_y_pps = 3
#*# algo = bicubic
#*# tension = 0.2
#*# min_x = 29.25
#*# max_x = 272.72
#*# min_y = 12.8
#*# max_y = 263.0
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 24.672
#*# pid_ki = 1.394
#*# pid_kd = 109.173
#*#
#*# [heater_bed]
#*# control = pid
#*# pid_kp = 38.998
#*# pid_ki = 0.341
#*# pid_kd = 1114.359
#*#
#*# [input_shaper]
#*# shaper_type_x = mzv
#*# shaper_freq_x = 49.4
