Here is the code I have so far. It's close to finished. At least it is functional. What I have left to complete, is a dialog to set some temperature parameters and I need to define speeds for all of the move gcodes. An issue I still have is turning off the heat if someone exist in the middle. I had to use gcodes that wait for the target temperature. The only way out of these is to use an M108 to cancel the waits. But if the user doesn't have EMERGANCY_PARSER enabled in Marlin, then they have to wait for the temperatures to be reached before it will exit. Maybe you have a better way to handle the Wait For Temp that can be exited. Other than a long LOOP. I would appreciate it if you could look through the code and let me know if you see anything that could be improved. Once completed, is there a topic on the Forum for sharing Wizards? Anyway ... here is what I have so far. Oh yeah. I don't see a link to upload files.
; Wizard to set Z-Offset on a catesian printer.
@dialogStart "Insure bed is Clear" "Adjusting Z-Offset"
@dialogButton "Cancel"
@dialogButton "Continue" "@call getOffset"
@dialogShow
@func getOffset
@monitorCall getOff 'M851 .Z(\S)' 5000 hitOff missOff
M851 ; Get Current Z-Offset
@endfunc
@func hitOff Z ; A successful hit on this function launches the remainder of the wizardso all exits come through here.
@deleteMonitorCall getOff
@set global.probeOffset {{float(local.Z)}}
@set global.exitCalled 0
@call homeNHeatBed
@unset global.exitCalled
@endfunc
@func missOff
@deleteMonitorCall getOff
@error "Unable to retrieve current Z-Offset.
@endfunc
@func homeNHeatBed
@dialogStart "Homing X and Y And Heating Bed. Please wait." "Adjusting Z-Offset"
@dialogButton "Cancel" "@call exit"
@dialogShow
M140 S50 ; Set Bed Temp
; M104 S200 ; Set Hotend Temp
G28 X Y ; Home X and Y
@if {{global.exitCalled == 1}}
@return
@endif
M190 S50 ; Verify Bed Temp and wait
G28 Y
@dialogHideAll
@call homeNHeatNozzle
@endfunc
@func homeNHeatNozzle
@if {{global.exitCalled == 1}}
@return
@endif
@dialogStart "Homing Z and Heating Nozzle. Please wait. While Nozel is heating, place a piece of paper under the nozzle but not under the probe." "Adjusting Z-Offset"
@dialogButton "Cancel" "@call exit"
@dialogShow
M104 S200 ; Set Hotend Temp
G28 Z ; Home Z
@if {{global.exitCalled == 1}}
@return
@endif
M109 S200 ; Set Hotend Temp and wait
G1 Z0 ; Move Z to 0
@set global.totalAdjustment 0
@dialogHideAll
@call adjust
@endfunc
@func adjust
@if {{global.exitCalled == 1}}
@return
@endif
@dialogStart "Adjust nozzle up or down until paper moves under the nozzle with resistance. Current offset = {{global.probeOffset + global.totalAdjustment}}mm" "Adjusting Z-Offset"
@dialogButton "0.01 mm" "@call move 0.01"
@dialogButton "0.10 mm" "@call move 0.10"
@dialogButton "1.00 mm" "@call move 1.00"
@dialogButton "Home Z" "@call homeZ"
@dialogButton "-0.01 mm" "@call move -0.01"
@dialogButton "-0.10 mm" "@call move -0.10"
@dialogButton "-1.00 mm" "@call move -1.00"
@dialogButton "Cancel" "@call exit"
@dialogButton "Save Offset" "@call saveOffset"
@dialogShow
@endfunc
@func homeZ
M851 Z{{fixed(global.probeOffset + global.totalAdjustment,2)}} ; Set Z-Offset
G28 Z ; Home Z
G1 Z0 ; Set Z to new 0 offset
@call adjust
@endfunc
@func move change
@set global.totalAdjustment {{fixed(global.totalAdjustment + local.change,2)}}
G1 Z{{global.totalAdjustment}}
@call adjust
@endfunc
@func saveOffset
@set global.probeOffset {{fixed(global.probeOffset + global.totalAdjustment,2)}}
M851 Z{{global.probeOffset}}
@set global.totalAdjustment 0
@echo "Z-Offset set to {{global.probeOffset}}"
M500 ; Save settings
@call exit
@endfunc
@func exit
@set global.exitCalled 1
@if {{global.totalAdjustment != 0}}
M851 Z{{global.probeOffset}}
@endif
@unset global.probeOffset
@unset global.totalAdjustment
@unset local.Z
M108 ; Cancel wait for heating
G1 Z20 X10 Y{{config.bed_y_max - 20}}
M109 S0 ; Turn Off Hotend Temp
M190 S0 ; Turn Off Bed Temp
@endfunc