o sub ; Move tool carousel best direction to pocket P ; Parameter #3989 is used to track if the carousel is homed (M13) (volatile) ; Parameter #3990 is used to track the current tool pocket (persistently) ; #: The number of pockets in the ATC is automaticity pulled from the INI via #<_ini[atc]pockets> (PRINT, o P#

) o100 if [#3989 NE 1] M13 o100 endif ; default to a 12 pocket ATC (matching DynATC Widget behaviour), then update based on INI settings # = 12 o110 if [EXISTS[#<_ini[atc]pockets>]] # = #<_ini[atc]pockets> o110 endif # = [#3990 - #

] (PRINT, o P#

, steps=#) o120 if [# GT [# / 2]] #=[# - #] o120 endif o130 if [# LT -[# / 2]] #=[# + #] o130 endif o140 if [# GT 0] M12 P[#] o140 elseif [# LT 0] #=[# * -1] M11 P[#] o140 endif (PRINT, o endsub) o endsub [1] M2