light sensor

Cor

Active Member
Licensed User
Longtime User
This code will not show up the lightevent

Am I missing something?

B4X:
Dim pSensor As PhoneSensors

 pSensor.Initialize(psensor.TYPE_LIGHT)   
  Log(pSensor.MaxValue)
  If pSensor.StartListening("LightEvent")= True Then
    Log("light sensor supported")
  End If

Sub LightEvent
 Log(pSensor.MaxValue)
End Sub
 

Cor

Active Member
Licensed User
Longtime User
thanks,

but i could not find this information in the documentation

can you show me where i can find it
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Upvote 0

Cor

Active Member
Licensed User
Longtime User
light sensor is working but giving only 75 lux and 210 lux

seems on/off values


when just there is a little light into the sensor it goes to 75 lux


Test with other sensor apps are getting more values between 75 and 210

using huawei s7 latest capacitive version
 
Upvote 0

appie21

Active Member
Licensed User
Longtime User
Hello

I want the actial light status of my room
so I made
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
Dim pSensor As PhoneSensors

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
pSensor.Initialize(pSensor.TYPE_LIGHT)
  Log(pSensor.MaxValue)
  If pSensor.StartListening("LightEvent")= True Then
    Log("light sensor supported")
End If

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub LightEvent
Log(pSensor.MaxValue)
End Sub
Sub LightEvent_SensorChanged (Values() As Float)
    Log (Values)
End Sub
But when i add Log (Values) my program stopps
What i want is get the actual light in real time

B4X:
Installing file.
PackageAdded: package:com.avestudio.ver
** Activity (main) Create, isFirst = true **
32768
light sensor supported
** Activity (main) Resume **
Error occurred on line: 47 (main)
java.lang.RuntimeException: Method: NumberToString not matched.
    at anywheresoftware.b4a.shell.Shell.getMethod(Shell.java:424)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:484)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:229)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:174)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:157)
    at anywheresoftware.b4a.phone.Phone$PhoneSensors$1.onSensorChanged(Phone.java:1088)
    at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:418)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:138)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
 
Upvote 0

appie21

Active Member
Licensed User
Longtime User
Hi does nobody know why i can't do something with the
Sub LightEvent_SensorChanged (Values() AsFloat) event?
 
Upvote 0
Top