Hm the function "ang()" simply returns the shifted camera angle, have you checked the manual already?

camera.pan = ang(camera.pan); //now camera.pan is between -180...180

You can use the following code to smoothly turn the camera to your target angle:
camera.pan += ang(target_pan - camera.pan)/2*time_step;


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends