The PhoneSensors, particularly the orientation sensor from the PhoneSensors, already give you that.
Since it is only the tilt angles you want (i.e. orientation angles), you can use directly a PhoneOrientation object from the Phone library.
Below an example that shows how to use a PhoneOrientation object:
Sub Globals
Dim PO As PhoneOrientation
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim label1 As Label
label1.Initialize("")
Activity.AddView(label1, 0, 0, 100%x, 100%y)
End Sub
Sub Activity_Resume
PO.StartListening("PO")
End Sub
Sub Activity_Pause
PO.StopListening
End Sub
Sub PO_OrientationChanged(Azimuth As Float, Pitch As Float, Roll As Float)
label1.Text = Azimuth & CRLF & Pitch & CRLF & Roll
End Sub
Note that Azimuth is the tilt angle in the horizontal plane, Roll is the tilt angle in the vertical plane, and Pitch is the tilt angle between the horizontal and vertical planes.