adafruit / Adafruit_APDS9960

Arduino drivers for APDS9960 gesture sensor
Other
37 stars 45 forks source link

Adjustment of the gesture detection #36

Open Herodotmaximus94 opened 2 years ago

Herodotmaximus94 commented 2 years ago

Hello, I state the problem, that I want to achieve a gesture detection with a proximity adjustment. The proximity value will not reach 0 and will be above 130 so no gesture is read. Is there anyone who could help me and is there a way to do so in the code? I am using the gesture example right now and tested around with the setGestureGain and setADCGain functions with no result. If I use the proximity mode, I got values between 130 and 255 so it is still working as intended. Thank you for the answers.

#include "Adafruit_APDS9960.h"
Adafruit_APDS9960 apds;

// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(115200);

  if(!apds.begin()){
    Serial.println("failed to initialize device! Please check your wiring.");
  }
  else Serial.println("Device initialized!");

  //gesture mode will be entered once proximity mode senses something close
  //apds.enableProximity(true);
  apds.enableGesture(true);

  //apds.setGestureProximityThreshold(135);
  apds.setGestureGain(0x02); //sets gesture gain to 4x
  apds.setADCGain(0x03); //sets ambientlight gain to 64x

}

// the loop function runs over and over again forever
void loop() {
  //read a gesture from the device
    uint8_t gesture = apds.readGesture();
    if(gesture == APDS9960_DOWN) Serial.println("RIGHT");
    if(gesture == APDS9960_UP) Serial.println("RIGHT");
    if(gesture == APDS9960_LEFT) Serial.println("LEFT");
    if(gesture == APDS9960_RIGHT) Serial.println("LEFT");
}