o sub (we change feed, metric/in and potentially G90) (so record current modal state) (M73 is not useful here because it reverts G43 on return too) # = #<_metric> # = #<_absolute> # = #<_feed> G21 (TLO and toolchange position is in mm as per ini) G90 (absolute) ; stop spindle M5 ; wait for spindle @ zero M66 P21 L3 Q5 ;see if we timed out O100 if [#5399 EQ -1] O call [#] [#] [#] O100 return [-1] ; indicate timeout failure to epilog O100 endif ; de-energise spindle and drill relays M65 P0 M65 P17 M65 P18 M65 P19 ; pause for quarter second G4 P0.25 ; move Z to zero G53 G0 Z0.0 ; pause for one second G4 P1 ; raise all tools O call ; pause for half second G4 P0.5 ; if T0, cleanup done so restore and return O110 if [#<_selected_tool> EQ 0] O call [#] [#] [#] O110 return [1] O110 endif ; lower selected tool M64 P #<_selected_tool> O120 if [#<_selected_tool> LT 20] M64 P0 O120 else M64 P [#<_selected_tool> - 3] ; energise selected tool relay G4 P1 O120 endif ; restore g20/21, g90/g91, feed O call [#] [#] [#] ; succeed by returning a positive value o endsub [1] m2