I think I found a way that works without knowing the font widths 🙂
[for sake of easy readability, I removed the initialisation:
- heat up bed and hotends
- let the user clean the nozzles
- remove the print plate
- move the bed to measurement position]
; move to reference screw in centre back
G1 H2 X0 Y86 ; move
M400 ; wait for the motion to finish
var ZReference = 0
; 1. measure and correct z value
while iterations <=6
G4 P200 ; wait 0,2s
G30 S-1 K0 ; measure z
set var.ZReference = var.ZReference + sensors.probes[0].lastStopHeight
G1 H2 Z5 F3000 ; move back up
set var.ZReference = var.ZReference / 6
; move hotend to probe point at front left
G1 X-115 Y94 F3000 ; move
M400 ; wait for the motion to finish
; measure error and let the user correct it
; start loop
var Measurement1 = false
var loopcount = 0
; message timeout *must* be adapted to probing speed as good as possible. To avoid message buffer
; overflows, message (und thus measuring) interval should be significantly slower than 1s to let the
; Duet catch up if needed.
while var.Measurement1 = false
set var.loopcount = 0
G4 P200 ; wait 0.2s
G30 S-1 K0 ; measure Z
; A "case" command, a kingdom for a "case" command... but we only have "if"...
if sensors.probes[0].lastStopHeight > 0.5
M291 S1 T1.4 P"=>|<==========-..-==========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight <= 0.5 && sensors.probes[0].lastStopHeight > 0.45
M291 S1 T1.4 P"=>|<=========-..-==========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight <= 0.45 && sensors.probes[0].lastStopHeight > 0.4
M291 S1 T1.4 P"==>|<========-..-==========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight <= 0.4 && sensors.probes[0].lastStopHeight > 0.35
M291 S1 T1.4 P"===>|<=======-..-==========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight <= 0.35 && sensors.probes[0].lastStopHeight > 0.3
M291 S1 T1.4 P"====>|<======-..-==========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight <= 0.3 && sensors.probes[0].lastStopHeight > 0.25
M291 S1 T1.4 P"=====>|<=====-..-==========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight <= 0.25 && sensors.probes[0].lastStopHeight > 0.2
M291 S1 T1.4 P"======>|<====-..-==========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight <= 0.2 && sensors.probes[0].lastStopHeight > 0.15
M291 S1 T1.4 P"=======>|<===-..-==========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight <= 0.15 && sensors.probes[0].lastStopHeight > 0.1
M291 S1 T1.4 P"========>|<==-..-==========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight <= 0.1 && sensors.probes[0].lastStopHeight > 0.05
M291 S1 T1.4 P"=========>|<=-..-==========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight <= 0.05 && sensors.probes[0].lastStopHeight > 0.03
M291 S1 T1.4 P"==========>|<-..-==========" R"turn left bed screw"
; There is no non-blocking and time-out-able message the user can acknowledge
; Workaround: verify measurement several times, then display a blocking message
elif sensors.probes[0].lastStopHeight <= 0.03 && sensors.probes[0].lastStopHeight >= -0.03
while sensors.probes[0].lastStopHeight <= 0.03 && sensors.probes[0].lastStopHeight >= -0.03 && var.loopcount <= 10 ; okay, but verify some times...
if iterations > 0 ; not for the first loop
G4 P200 ; wait 0.2s
G30 S-1 K0 ; measure z
G1 H2 Z5 F3000 ; move back up
if sensors.probes[0].lastStopHeight <= 0.03 && sensors.probes[0].lastStopHeight > 0.01 ; just okay
M291 S1 T1.4 P"==========->|<..-==========" R"turn left bed screw"
set var.loopcount = var.loopcount + 1
elif sensors.probes[0].lastStopHeight <= 0.01 && sensors.probes[0].lastStopHeight >= -0.01 ; perfect
M291 S1 T1.4 P"==========-.>|<.-==========" R"turn left bed screw"
set var.loopcount = var.loopcount + 1
elif sensors.probes[0].lastStopHeight < -0.01 && sensors.probes[0].lastStopHeight >= -0.03 ; just okay
M291 S1 T1.4 P"==========-..>|<-==========" R"turn left bed screw"
set var.loopcount = var.loopcount + 1
if var.loopcount = 10 && sensors.probes[0].lastStopHeight <= 0.03 && sensors.probes[0].lastStopHeight >= -0.03
M300 S2000 P200 ; B
G4 P200 ; e
M300 S2500 P300 ; e
G4 P300 ; p
M291 S4 K{"OK","Repeat"} T1 P"Bed screw adjusted! End measurement?" R"Left bed screw adjusted"
if input = 0
set var.Messung1 = true
set var.loopcount = 99
if input = 1
set var.loopcount = 0
elif sensors.probes[0].lastStopHeight < -0.03 && sensors.probes[0].lastStopHeight >= -0.05
M291 S1 T1.4 P"==========-..->|<==========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight < -0.05 && sensors.probes[0].lastStopHeight >= -0.1
M291 S1 T1.4 P"==========-..-=>|<=========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight < -0.1 && sensors.probes[0].lastStopHeight >= -0.15
M291 S1 T1.4 P"==========-..-==>|<========" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight < -0.15 && sensors.probes[0].lastStopHeight >= -0.2
M291 S1 T1.4 P"==========-..-===>|<=======" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight < -0.2 && sensors.probes[0].lastStopHeight >= -0.25
M291 S1 T1.4 P"==========-..-====>|<======" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight < -0.25 && sensors.probes[0].lastStopHeight >= -0.3
M291 S1 T1.4 P"==========-..-=====>|<=====" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight < -0.3 && sensors.probes[0].lastStopHeight >= -0.35
M291 S1 T1.4 P"==========-..-======>|<====" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight < -0.35 && sensors.probes[0].lastStopHeight >= -0.4
M291 S1 T1.4 P"==========-..-=======>|<===" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight < -0.4 && sensors.probes[0].lastStopHeight >= -0.45
M291 S1 T1.4 P"==========-..-========>|<==" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight < -0.45 && sensors.probes[0].lastStopHeight >= -0.5
M291 S1 T1.4 P"==========-..-=========>|<=" R"turn left bed screw"
elif sensors.probes[0].lastStopHeight < -0.5
M291 S1 T1.4 P"==========-..-==========>|<" R"turn left bed screw"
[the same will be repeated then with the third probe point. Finally, save the updated z value and bring the printer back to a safe position]
Edit: fixed a generous amount of stupid typos, changed message type to S1 since the PanelDue does not seem to display S0 messages at all. Anything below "start loop" works now if I feed it with dummy data - for the rest I need the Duet built into the printer 🙂
2nd edit: updated to reflect how the script actually runs now, in case someone stumbles upon this and wants to use it.