Feedback-controlled tuning, switching, and locking of photonic integrated circuits