B4R Library rAPDS9960 - Gesture Sensor

APDS 9960 gesture and RGB sensor: https://www.sparkfun.com/products/12787

This library is based on: https://github.com/sparkfun/SparkFun_APDS-9960_Sensor_Arduino_Library/tree/V_1.4.2


Note that you need to use a 3.3v board such as Arduino Due, Arduino 101 or ESP8266.
The 4 connections:
Gnd
VCC - 3.3v
SDA and SCL

Example:
B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Private apd As APDS9960
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   If apd.Initialize("apd_Gesture") Then
     Log("APDS initialized successfully.")
   Else
     Log("Failed to initialize APDS module.")
     Return
   End If
   apd.EnableGestureSensor
End Sub

Sub apd_Gesture(Gesture As Int)
   Select Gesture
     Case apd.DIR_ALL
       Log("All")
     Case apd.DIR_DOWN
       Log("Down")
     Case apd.DIR_FAR
       Log("Far")
     Case apd.DIR_LEFT
       Log("Left")
     Case apd.DIR_NEAR
       Log("Near")
     Case apd.DIR_RIGHT
       Log("Right")
     Case apd.DIR_UP
       Log("Up")
   End Select
End Sub

Example of reading the proximity and RGB values:
B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Private apd As APDS9960
   Private timer1 As Timer
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   If apd.Initialize(Null) Then
     Log("APDS initialized successfully.")
   Else
     Log("Failed to initialize APDS module.")
     Return
   End If
   apd.EnableLightSensor
   apd.EnableProximitySensor
   timer1.Initialize("timer1_Tick", 100)
   timer1.Enabled = True
End Sub

Sub Timer1_Tick
   Log("Proximity: ", apd.ReadProximity)
   Log("R: ", apd.ReadRedLight)
   Log("G: ", apd.ReadGreenLight)
   Log("B: ", apd.ReadBlueLight)
End Sub

The B4A and B4R programs from the video above are attached. The B4R program is based on rBLECurie which is specific to Arduino 101. Shouldn't be difficult to change the communication implementation.
 

Attachments

  • GestureSensorWithBLE_B4R.zip
    919 bytes · Views: 522
  • GestureSensorWithBLE_B4A.zip
    8.3 KB · Views: 546
  • rAPDS9960.zip
    12.9 KB · Views: 533
Top