Sub Process_Globals
Dim Accelerometer As PhoneAccelerometer
Dim Orientation As PhoneOrientation
' NOTA: El acelerómetro y la orientación también se pueden utilizar
' mediante PhoneSensors y su correspondiente TYPE_
' Para ver los datos utilizaremos Values.
Dim Magnetic As PhoneSensors
Dim Proximidad As PhoneSensors
Dim timer1 As Timer
' Juan Antonio Villalpando
' juana1991@yahoo.com
' junio 2014
End Sub
Sub Globals
Dim Label1, Label2, Label3 As Label
Dim Label4, Label5, Label6 As Label
Dim Label7, Label8, Label9 As Label
Dim Label10 As Label
' Dim X, Y, Z As Double
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("layout")
If FirstTime Then
timer1.Initialize("Timer1",30)
Magnetic.Initialize(Magnetic.TYPE_MAGNETIC_FIELD)
Proximidad.Initialize(Proximidad.TYPE_PROXIMITY)
End If
timer1.Enabled = True
End Sub
Sub Activity_Resume
Accelerometer.StartListening("Accelerometer")
Orientation.StartListening("Orientation")
Magnetic.StartListening("Magnetic")
Proximidad.StartListening("Proximidad")
timer1.Enabled = True
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Accelerometer.StopListening
Orientation.StopListening
Magnetic.StopListening
Proximidad.StopListening
timer1.Enabled = False
End Sub
Sub Timer1_Tick
' Label1.text = X & " " & Y & " " & Z
' Label1.Text = "Juan Antonio"
End Sub
Sub Accelerometer_AccelerometerChanged (X As Float, Y As Float, Z As Float)
Label1.text = "X = " & X
Label2.text = "Y = " & Y
Label3.text = "Z = " & Z
End Sub
Sub Orientation_OrientationChanged (X As Float, Y As Float, Z As Float)
Label4.text = "X = " & X
Label5.text = "Y = " & Y
Label6.text = "Z = " & Z
End Sub
' La forma utilizando TYPE_ y Values sería la mejor manera de hacerlo.
' para el Acelerómetro y para la Orientación.
Sub Magnetic_SensorChanged (Values() As Float)
Label7.Text = "X = " & NumberFormat(Values(0), 0, 3)
Label8.text = "Y = " & NumberFormat(Values(1), 0, 3)
Label9.Text ="Z = " & NumberFormat(Values(2), 0, 3)
End Sub
Sub Proximidad_SensorChanged (Values() As Float)
Label10.Text = "X = " & NumberFormat(Values(0), 0, 3)
End Sub