''' APT Constants and Registries Thomas Ales | Feb 2026 ''' from enum import IntFlag class StatusBits(IntFlag): MOT_SB_CWHARDLIMIT = 0x01 MOT_SB_CCWHARDLIMIT = 0x02 MOT_SB_INMOTIONCW = 0x10 MOT_SB_INMOTIONCCW = 0x20 MOT_SB_HOMING = 0x200 MOT_SB_HOMED = 0x400 MOT_SB_TRACKING = 0x1000 MOT_SB_SETTLED = 0x2000 MOT_SB_POSITIONERROR = 0x4000 MOT_SB_INSTRERROR = 0x8000 MOT_SB_INTERLOCK = 0x10000 MOT_SB_OVERTEMP = 0x20000 MOT_SB_BUSVOLTFAULT = 0x40000 MOT_SB_COMMUTATIONERROR = 0x80000 MOT_SB_DIGIP1 = 0x100000 MOT_SB_OVERLOAD = 0x1000000 MOT_SB_POWEROK = 0x10000000 MOT_SB_ERROR = 0x40000000 MOT_SB_ENABLED = 0x80000000 # combined masks for checking various # states MOT_ANY_MOVE = MOT_SB_INMOTIONCW | MOT_SB_INMOTIONCCW MOT_ANY_ERR = (MOT_SB_OVERTEMP | MOT_SB_BUSVOLTFAULT | MOT_SB_COMMUTATIONERROR | MOT_SB_OVERLOAD | MOT_SB_ERROR | MOT_SB_INSTRERROR) class TriggerBitsServo(IntFlag): TRIGIN_HIGH = 0x01 TRIGIN_RELMOVE = 0x02 TRIGIN_ABSMOVE = 0x04 TRIGIN_HOMEMOVE = 0x08 TRIGOUT_HIGH = 0x10 TRIGOUT_INMOTION = 0x20 TRIGOUT_MOTIONCOMPLETE = 0x40 TRIGOUT_MAXVELOCITY = 0x80 TRIGOUT_MAXV = TRIGOUT_HIGH | TRIGOUT_MAXVELOCITY # Gate off: no trigger-out function selected, so the pin idles inactive. # # Treat this as unverified until it has been checked on the rig. §7.6 of # docs/hardware/BBD203_Communications_Protocol.md documents `mode` as an # enumeration capping at 0x11, which flatly contradicts the bitmask this # driver actually sends (TRIGOUT_MAXV = 0x90, known working), so the doc # cannot settle what makes the pin idle low. Under the bitmask reading 0x00 # clears everything and the pin sits low. If instead TRIGOUT_HIGH is an # active-high *polarity* bit, clearing it means active-low and the pin idles # HIGH — which in burst mode floods the acquisition with flyback frames. # ScanEngine's gate-off preflight catches that; if it trips, change this to # TriggerBitsServo.TRIGOUT_HIGH. TRIGOUT_GATE_OFF = TriggerBitsServo(0)