adafruit / Adafruit_APDS9960

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

Gesture Sensing & Code Blocking #29

Open epiller opened 3 years ago

epiller commented 3 years ago

Is there any possibility to make the gesture sensing non-blocking? At the moment, when gestures are enabled and something is in close proximity of the sensor, everything in the program is blocked. Assuming there's no blocking functions in the user's code, could a function, say, "apds.update()" that's running in the loop function achieve the same functionality without blocking everything else? Is this a sensor hardware/firmware limitation or just the way the library was written?

Brok0lis commented 3 years ago

@epiller There is a while loop in readGesture(). I think that is the issue. I also find the blocking part annoying, but it is also present in the SparkFun library. What I am considering is trying to rewrite it somehow, but I would like to think that it is not as easy as I suspect, since apparently 2 sets of engineers have written a blocking implementation.

The weird thing to me is that ADC conversion for 2 pairs takes 1.3ms according to the datasheet, and FIFO can hold 32 datasets, so why would it be written blocking? Even with 16Mhz on something like an arduino you should have plenty of time to read it every now and then. If I make something sensible I will leave a message here.

ladyada commented 3 years ago

if someone can do a PR where the engine uses the FIFO that would be great!

epiller commented 3 years ago

@Brok0lis Would be pretty awesome if you could pull that off, especially since the same changes could be made on the SparkFun library as well! Keep us posted