Skip to content

Commit

Permalink
Bugfix flexplate, start_print order changed, added more magnets and d…
Browse files Browse the repository at this point in the history
…ynamic leveling
  • Loading branch information
OXERY committed Jan 14, 2022
1 parent 177f9e0 commit 7c93c3a
Show file tree
Hide file tree
Showing 12 changed files with 217 additions and 741 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,17 @@ color_order: RGB

# Set RGB values on boot up for each Neopixel.
# Index 1 = display, Index 2 and 3 = Knob
[delayed_gcode setdisplayneopixel]

[gcode_macro SET_LED_DISPLAY]
gcode:
SET_LED LED=display RED=1 GREEN=0 BLUE=0 INDEX=1 TRANSMIT=0
SET_LED LED=display RED=1 GREEN=0 BLUE=0 INDEX=2 TRANSMIT=0
SET_LED LED=display RED=1 GREEN=0.49 BLUE=0.83 INDEX=3

[delayed_gcode _setdisplayneopixel]
initial_duration: 1
gcode:
SET_LED LED=display RED=1 GREEN=0 BLUE=0 INDEX=1 TRANSMIT=0
SET_LED LED=display RED=1 GREEN=0 BLUE=0 INDEX=2 TRANSMIT=0
SET_LED LED=display RED=1 GREEN=0.49 BLUE=0.83 INDEX=3
SET_LED_DISPLAY

#####################################################################
# ADXL On SPI port Octopus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ gcode:
{% set plate_offset_z = plates[index][1] %}
SET_GCODE_OFFSET Z=0
{% if move == 'true' %}
SET_GCODE_OFFSET Z_ADJUST={plate_offset_z|float} MOVE=1
SET_GCODE_OFFSET Z={plate_offset_z|float} MOVE=1
{% else %}
SET_GCODE_OFFSET Z_ADJUST={plate_offset_z|float}
SET_GCODE_OFFSET Z={plate_offset_z|float}
{% endif %}
{% endif %}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ gcode:
{% endif %}
{% endif %}
{% if printer.bed_mesh.profile_name == "" or printer["gcode_macro _always_mesh"].alwaysmesh|int == 1%}
G80
{% if params.AREA_START and params.AREA_END %}
DYNAMIC_LEVELING AREA_START={params.AREA_START} AREA_END={params.AREA_END}
{% else %}
G80
{% endif %}
{% endif %}
# clear pause
CLEAR_PAUSE
Expand Down
86 changes: 85 additions & 1 deletion Klipper_cfg/Prusa_Universal_Config_Revised/Macros/macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,96 @@ gcode:
{% endfor %}
{action_respond_info(parameters.output)}

# https://github.com/kmarty/Dynamic_BED_MESH_CALIBRATE
# to make dynamic meshing work, change start_print in slicer to
# START_PRINT BED_TEMP=[first_layer_bed_temperature] EXTRUDER_TEMP=[first_layer_temperature] AREA_START={first_layer_print_min[0]},{first_layer_print_min[1]} AREA_END={first_layer_print_max[0]},{first_layer_print_max[1]}
[gcode_macro DYNAMIC_LEVELING]
; the clearance between print area and probe area
variable_mesh_area_offset : 5.0
; minimum probe count
variable_min_probe_count : 3
; scale up the probe count, should be 1.0 ~ < variable_max_probe_count/variable_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 meshPoints = bedMeshConfig.probe_count.split(",") %}
{% set meshPointX = meshPoints[0]|int %}
{% set meshPointY = meshPoints[1]|int if meshPoints.__len__() > 1 else meshPointX %}
{% set meshMaxPointX = meshPointX %}
{% set meshMaxPointY = meshPointY %}

{% if (bedMeshConfig.algorithm == "bicubic") and (min_probe_count < 4) %}
{% set min_probe_count = 4 %}
{% endif %}

{% if bedMeshConfig.relative_reference_index %}
{% set relative_reference_index = bedMeshConfig.relative_reference_index %}
{% else %}
{% set relative_reference_index = 0 %}
{% endif %}

{% if (area_min_x < area_max_x) and (area_min_y < area_max_y) %}
{% set area_min_x = [area_min_x - mesh_area_offset, safe_min_x]|max %}
{% set area_min_y = [area_min_y - mesh_area_offset, safe_min_y]|max %}
{% set area_max_x = [area_max_x + mesh_area_offset, safe_max_x]|min %}
{% set area_max_y = [area_max_y + mesh_area_offset, safe_max_y]|min %}

{% set meshPointX = (meshPointX * (area_max_x - area_min_x) / (safe_max_x - safe_min_x) * probe_count_scale_factor)|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 )|round(0)|int %}
{% if meshPointY < min_probe_count %}
{% set meshPointY = min_probe_count %}
{% endif %}

{% if meshPointY > meshMaxPointY %}
{% set meshPointY = meshMaxPointY %}
{% endif %}

{ action_respond_info("mesh_min: %s,%s" % (area_min_x, area_min_y)) }
{ action_respond_info("mesh_max: %s,%s" % (area_max_x, area_max_y)) }
{ action_respond_info("probe_count: %s,%s" % (meshPointX, meshPointY)) }

{% if relative_reference_index > 0 %}
{% set relative_reference_index = ((meshPointX * meshPointY - 1) / 2)|int|string %}
{ action_respond_info("relative_reference_index: %s" % relative_reference_index) }
{% set RRI_PH = "relative_reference_index=" + relative_reference_index %}
{% else %}
{% set RRI_PH = "" %}
{% endif %}

M118 Starting Dynamic Bed Mesh
BED_MESH_CALIBRATE mesh_min={area_min_x},{area_min_y} mesh_max={area_max_x},{area_max_y} probe_count={meshPointX},{meshPointY} {RRI_PH}
{% else %}
M118 Starting normal Bed Mesh
BED_MESH_CALIBRATE
{% endif %}
{% else %}
M118 Starting normal Bed Mesh
BED_MESH_CALIBRATE
{% endif %}

[gcode_macro G80]
gcode:
BED_MESH_CALIBRATE
BED_MESH_PROFILE SAVE=Mesh
G1 X0 Y0 Z0.4 F4000

[gcode_macro G29]
gcode:
BED_MESH_CALIBRATE
Expand Down
78 changes: 78 additions & 0 deletions Klipper_cfg/Prusa_Universal_Config_Revised/Macros/mesh_magnets.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#####################################################################
# Mesh
#####################################################################
[bed_mesh]
speed: 150.0
mesh_min: 24, 1
mesh_max: 231,212
move_check_distance: 3.0
split_delta_z: .025
# Odd number of probe points per dimension (3x3, 5x5, 7x7) is better as then the area near the center screw is probed
#probe_count: 7,7
#probe_count: 5,5
probe_count: 3,3
mesh_pps: 2,2 #Only 2 interpolations per point
algorithm: bicubic
#relative_reference_index: 24 # 7x7
#relative_reference_index: 12 # 5x5
relative_reference_index: 4 # 3x3
fade_start: 1.0
fade_end: 10.0

# Avoid magnets
faulty_region_1_min: 2.672, 2.876
faulty_region_1_max: 9.172, 29.876
faulty_region_2_min: 1.922, 33.376
faulty_region_2_max: 8.422, 60.376
faulty_region_3_min: 2.205, 62.701
faulty_region_3_max: 8.705, 89.701
faulty_region_4_min: 3.205, 124.194
faulty_region_4_max: 9.705, 151.194
faulty_region_5_min: 2.672, 156.620
faulty_region_5_max: 9.172, 183.620
faulty_region_6_min: 1.197, 187.317
faulty_region_6_max: 7.697, 214.317
faulty_region_7_min: 1.439, 217.126
faulty_region_7_max: 28.439, 223.626
faulty_region_8_min: 64.180, 216.052
faulty_region_8_max: 91.180, 222.552
faulty_region_9_min: 108.083, 194.876
faulty_region_9_max: 114.583, 221.876
faulty_region_10_min: 158.164, 216.052
faulty_region_10_max: 185.164, 222.552
faulty_region_11_min: 219.731, 216.911
faulty_region_11_max: 246.731, 223.411
faulty_region_12_min: 240.922, 154.748
faulty_region_12_max: 247.422, 181.748
faulty_region_13_min: 240.639, 123.974
faulty_region_13_max: 247.139, 150.974
faulty_region_14_min: 240.639, 63.110
faulty_region_14_max: 247.139, 90.110
faulty_region_15_min: 240.922, 29.429
faulty_region_15_max: 247.422, 56.429
faulty_region_16_min: 194.761, -14.374
faulty_region_16_max: 221.761, -7.874
faulty_region_17_min: 162.261, -14.374
faulty_region_17_max: 189.261, -7.874
faulty_region_18_min: 133.172, -10.624
faulty_region_18_max: 139.672, 16.376
faulty_region_19_min: 61.083, -14.374
faulty_region_19_max: 88.083, -7.874
faulty_region_20_min: 28.583, -14.374
faulty_region_20_max: 55.583, -7.874
faulty_region_21_min: 199.761, 12.626
faulty_region_21_max: 226.761, 19.126
faulty_region_22_min: 121.922, 47.376
faulty_region_22_max: 128.422, 74.376
faulty_region_23_min: 28.922, 94.626
faulty_region_23_max: 35.422, 121.626
faulty_region_24_min: 61.672, 104.876
faulty_region_24_max: 88.672, 111.376
faulty_region_25_min: 161.672, 104.876
faulty_region_25_max: 188.672, 111.376
faulty_region_26_min: 212.636, 94.626
faulty_region_26_max: 219.136, 121.626
faulty_region_27_min: 121.922, 141.876
faulty_region_27_max: 128.422, 168.876
faulty_region_28_min: 183.677, 198.894
faulty_region_28_max: 210.677, 205.394
24 changes: 13 additions & 11 deletions Klipper_cfg/Prusa_Universal_Config_Revised/Macros/start_print.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ gcode:
M83
# start with the fan off
M107
# home the printer
# {% if "xyz" not in printer.toolhead.homed_axes %}
G28
# {% endif %}
G0 Y0 X0 Z20 F3000
# start bed heating
M117 Bed to {BED_TEMP}
M140 S{BED_TEMP}
# home the printer
# {% if "xyz" not in printer.toolhead.homed_axes %}
G28
# {% endif %}
G0 Y0 X0 Z20 F3000
# set extruder temp to 170°C to avoid filament dripping
{% if printer.extruder.temperature|int > 170 %}
M117 Nozzle temp +170 - cooling
Expand All @@ -44,20 +44,22 @@ gcode:
{% endif %}
# move up to have room to clean nozzle if needed
G0 Z100 F1000
# set bed temp
M140 S{BED_TEMP}
CUSTOM_HEATING_BED_START BED_TEMP={BED_TEMP} EXTRUDER_TEMP={EXTRUDER_TEMP}
# wait for bed temp
CUSTOM_HEATING_BED_START BED_TEMP={BED_TEMP} EXTRUDER_TEMP={EXTRUDER_TEMP}
M190 S{BED_TEMP}
CUSTOM_HEATING_BED_FINISHED BED_TEMP={BED_TEMP} EXTRUDER_TEMP={EXTRUDER_TEMP}
# Z_Tilt + mesh
{% if printer["gcode_macro _ztilt"].ztilting|int == 1 %}
{% if printer.z_tilt.applied is false %}
Z_TILT_ADJUST
Z_TILT_ADJUST
{% endif %}
{% endif %}
{% if printer.bed_mesh.profile_name == "" or printer["gcode_macro _always_mesh"].alwaysmesh|int == 1%}
G80
{% if printer.bed_mesh.profile_name == "" or printer["gcode_macro _always_mesh"].alwaysmesh|int == 1 %}
{% if params.AREA_START and params.AREA_END %}
DYNAMIC_LEVELING AREA_START={params.AREA_START} AREA_END={params.AREA_END}
{% else %}
G80
{% endif %}
{% endif %}
G0 Y0 X0 Z20 F3000
# clear pause
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ default_type: command
#[include Macros/tasmotaswitch.cfg] # Tasmota Power switch control with Idle timeout
[include Macros/mesh.cfg] # Mesh config including ignoring faulty regions due magnets
#[include Macros/mesh_fade.cfg] # Mesh config as above, but with fade enabled - fading mesh results over height of the print
#[include Macros/mesh_magnets.cfg] # Mesh config as above, but with additional magnet coordinates added, e.g. for 7x7 mesh
#[include Macros/mesh_old.cfg] # Mesh config classic way as i am not convinced of the new method
[include Macros/homing.cfg] # Homing routine
[include Macros/print_time.cfg] # Statistics about total print time and save the to file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ default_type: command
#[include Macros/tasmotaswitch.cfg] # Tasmota Power switch control with Idle timeout
[include Macros/mesh.cfg] # Mesh config including ignoring faulty regions due magnets
#[include Macros/mesh_fade.cfg] # Mesh config as above, but with fade enabled - fading mesh results over height of the print
#[include Macros/mesh_magnets.cfg] # Mesh config as above, but with additional magnet coordinates added, e.g. for 7x7 mesh
#[include Macros/mesh_old.cfg] # Mesh config classic way as i am not convinced of the new method
[include Macros/homing.cfg] # Homing routine
[include Macros/print_time.cfg] # Statistics about total print time and save the to file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ default_type: command
#[include Macros/tasmotaswitch.cfg] # Tasmota Power switch control with Idle timeout
[include Macros/mesh.cfg] # Mesh config including ignoring faulty regions due magnets
#[include Macros/mesh_fade.cfg] # Mesh config as above, but with fade enabled - fading mesh results over height of the print
#[include Macros/mesh_magnets.cfg] # Mesh config as above, but with additional magnet coordinates added, e.g. for 7x7 mesh
#[include Macros/mesh_old.cfg] # Mesh config classic way as i am not convinced of the new method
[include Macros/homing.cfg] # Homing routine
[include Macros/print_time.cfg] # Statistics about total print time and save the to file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ default_type: command
#[include Macros/tasmotaswitch.cfg] # Tasmota Power switch control with Idle timeout
[include Macros/mesh.cfg] # Mesh config including ignoring faulty regions due magnets
#[include Macros/mesh_fade.cfg] # Mesh config as above, but with fade enabled - fading mesh results over height of the print
#[include Macros/mesh_magnets.cfg] # Mesh config as above, but with additional magnet coordinates added, e.g. for 7x7 mesh
#[include Macros/mesh_old.cfg] # Mesh config classic way as i am not convinced of the new method
[include Macros/homing.cfg] # Homing routine
[include Macros/print_time.cfg] # Statistics about total print time and save the to file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ default_type: command
#[include Macros/tasmotaswitch.cfg] # Tasmota Power switch control with Idle timeout
[include Macros/mesh.cfg] # Mesh config including ignoring faulty regions due magnets
#[include Macros/mesh_fade.cfg] # Mesh config as above, but with fade enabled - fading mesh results over height of the print
#[include Macros/mesh_magnets.cfg] # Mesh config as above, but with additional magnet coordinates added, e.g. for 7x7 mesh
#[include Macros/mesh_old.cfg] # Mesh config classic way as i am not convinced of the new method
[include Macros/homing.cfg] # Homing routine
[include Macros/print_time.cfg] # Statistics about total print time and save the to file
Expand Down
Loading

0 comments on commit 7c93c3a

Please sign in to comment.