# This file contains common pin mappings for the BIGTREETECH Manta M4P
# To use this config, the firmware should be compiled for the
# STM32G0B1 with a "8KiB bootloader" and USB communication.

# See docs/Config_Reference.md for a description of parameters.

[printer]
kinematics: cartesian
max_velocity: 180
max_accel: 3000
max_z_velocity: 100
max_z_accel: 100

[mcu]
serial: /dev/serial/by-id/usb-Klipper_stm32g0b1xx_hurakan-if00


[mcu EBBCan]
  canbus_uuid: 82edf63bd1a9

[include toolhead.cfg]

[stepper_x]
  step_pin: PC6
  dir_pin: !PA14
  enable_pin: !PC7
  microsteps: 16
  rotation_distance: 40
  endstop_pin: ^!PC0
  position_endstop: 0
  position_max: 230
  homing_speed: 80

[stepper_y]
  step_pin: PB10
  dir_pin: PB2
  enable_pin: !PB11
  microsteps: 16
  rotation_distance: 40
  endstop_pin: ^!PC1
  position_endstop: 230
  position_max: 230
  homing_speed: 80

[stepper_z]
  step_pin: PB0
  dir_pin: !PC5
  enable_pin: !PB1
  microsteps: 16
  rotation_distance: 8
  endstop_pin: ^!PC2
  position_endstop: 207.890
  position_max: 232
  position_min: -10
  homing_speed: 40

[extruder]
  step_pin: PB3
  dir_pin: PB4
  enable_pin: !PD5
  microsteps: 16
  rotation_distance: 10.07
  nozzle_diameter: 0.400
  filament_diameter: 1.74
  heater_pin: EBBCan: PB13
  control: pid
  pid_Kp: 21.527
  pid_Ki: 1.063
  pid_Kd: 108.982
  min_temp: 0 
  max_temp: 270
  sensor_type:MAX31865
  sensor_pin: EBBCan: PA4
  spi_bus: spi1
  rtd_nominal_r: 100
  rtd_reference_r: 430
  rtd_num_of_wires: 2
  pressure_advance: 0.78

[filament_switch_sensor extruder_filament_sensor]
  switch_pin: ^!PC15

# [heater_bed]
#   heater_pin: PD8
#   sensor_type: Generic 3950
#   sensor_pin: PC4
#   control = pid
#   pid_kp = 62.901
#   pid_ki = 1.808
#   pid_kd = 547.241
#   min_temp: 0
#   max_temp: 120

[fan]
pin: PD2

[led WhiteLeds]
white_pin: PD4
initial_WHITE: 0.7




##############################
#        bed leveling        #
##############################

[bed_screws]
  screw1: 120, 185
  screw1_name: "rear mid screw"
  screw2: 20 ,20
  screw2_name: "front left screw"
  screw3: 220, 20
  screw3_name: "front right screw"
  horizontal_move_z: 5

[bed_mesh]
  speed: 120
  horizontal_move_z: 5
  mesh_min: 15, 50
  mesh_max: 190, 200
  probe_count: 3, 3

########################################
# TMC2209 configuration
########################################

[tmc2209 stepper_x]
  uart_pin: PB12
  run_current: 0.800

[tmc2209 stepper_y]
  uart_pin: PC10
  run_current: 0.800

[tmc2209 stepper_z]
  uart_pin: PC9
  run_current: 0.800

[tmc2209 extruder]
  uart_pin: PA13
  run_current: 0.600



[include mainsail.cfg]

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*#
#*# [extruder]
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 	  0.725000, 0.715000, 0.660000, 0.610000, 0.570000
#*# 	  0.660000, 0.650000, 0.600000, 0.575000, 0.485000
#*# 	  0.695000, 0.650000, 0.605000, 0.585000, 0.495000
#*# x_count = 5
#*# y_count = 3
#*# mesh_x_pps = 2
#*# mesh_y_pps = 2
#*# algo = lagrange
#*# tension = 0.2
#*# min_x = 15.0
#*# max_x = 190.0
#*# min_y = 50.0
#*# max_y = 200.0