APDS9999 Proximity Logic Mode Test (Servo Automated)
=====================================================
Hardware: Servo on A0, INT on D2

APDS9999 found!

=== PHASE 1: CALIBRATION ===
Baseline (servo away): 1
High prox (servo close): 167
Threshold (50%): 84
PHASE 1: PASS - Good calibration range

=== PHASE 2: LOGIC MODE OFF (LATCHING) ===
Logic mode set to OFF: OK
INT before crossing (should be HIGH): HIGH - OK
Moving servo to close position...
INT after crossing (should be LOW): LOW - OK
INT still latched LOW: LOW - OK (latched)
Reading status to clear interrupt...
INT after status clear (should be HIGH): LOW - FAIL
PHASE 2: FAIL - Latching behavior incorrect

=== PHASE 3: LOGIC MODE ON (FOLLOWING) ===
Logic mode set to ON: OK
Servo AWAY -> INT (should be HIGH): LOW - FAIL
Servo CLOSE -> INT (should be LOW): LOW - OK
Servo AWAY again -> INT (should be HIGH, no latch): LOW - FAIL (still latched!)
Second cycle - CLOSE: LOW, AWAY: LOW
PHASE 3: FAIL - Following behavior incorrect

========== TEST SUMMARY ==========
Phase 1 (Calibration):      PASS
Phase 2 (Logic Mode OFF):   FAIL
Phase 3 (Logic Mode ON):    FAIL
==================================
OVERALL: FAIL

Cleaning up...
Servo detached. Test complete.
