Closed TheKitty closed 4 years ago
As suggested, tried the simpletest.py example from the APDS9960 repo.
It's an improvement. With the simpletest.py example, CLUE is able to detect gestures from further away and has a higher detection rate, but still misses a lot of gestures. The CLUE sensor orientation relative to the example code is off by 90 degrees (up/down is actually left/right), which is no big deal.
I filmed a demo which draws a circle on the TFT indicating the detected gesture (as described in previous paragraph, the orientation is off by 90 degrees). You can see the detection is a bit spotty. Link to video here: https://photos.app.goo.gl/UeAvNZfYXnDgnF4z7
Code running in demo is below:
import board
import busio
import displayio
from adafruit_apds9960.apds9960 import APDS9960
from adafruit_display_shapes.circle import Circle
LEFT = 20
MIDDLE = 100
RIGHT = 160
TOP = 20
BOTTOM = 160
i2c = busio.I2C(board.SCL, board.SDA)
apds = APDS9960(i2c)
apds.enable_proximity = True
apds.enable_gesture = True
splash = displayio.Group(max_size=2)
display = board.DISPLAY
display.show(splash)
color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0xFFFFFF
bg_sprite = displayio.TileGrid(color_bitmap,x=0,y=0,pixel_shader=color_palette)
splash.append(bg_sprite)
circle = Circle(120, 120, 30, fill=0xFF0000, outline=0xFF00FF)
splash.append(circle)
fill_list = [0xFF0000, 0X00FF00]
fill_index = 0
while True:
gesture = apds.gesture()
if (gesture):
fill_index = (fill_index + 1) % 2
circle.fill = fill_list[fill_index]
if gesture == 0x01:
circle.x = MIDDLE
circle.y = TOP
#print("top")
elif gesture == 0x02:
circle.x = MIDDLE
circle.y = BOTTOM
#print("bottom")
elif gesture == 0x03:
circle.x = LEFT
circle.y = MIDDLE
#print("left")
elif gesture == 0x04:
circle.x = RIGHT
circle.y = MIDDLE
#print("right")
OK! the detection is off by 90 degrees cause the sensor is rotated on the CLUE compared to a breakout
Related: gestures being triggered (prox > gesture_proximity_threshold) freeze the returned proximity value. E.g. if the threshold is at the default 50, the returned proximity value to 'lock in' when it reaches 51. Setting teh threshold to 255 allows proximity to work property throughout it's full 0-255 range.
FYI, If the RGBC values are of interest, the current defauls set the ADC Integration Time Register (0x81) register to 0x01
which equates to 708.9ms integration time giving updates only ~ 1.4Hz. Page 20 of the datasheet has a slight error on how this value is treated, it says 256 - TIME / 2.78 ms
. I'm pretty sure it means (256 - TIME) * 2.78
. There's an integration_time
property which can be used to adjust this.
I've also noticed clue.color()
values getting "stuck" on REPL on the CLUE but I've only seen this once. foamyguy on discord has also seen this.
I've created two new issues for the two related issues mentioned in this thread.
@TheKitty @geekmomprojects The gesture sensor is not great. It requires a learning curve involving things like moving slowly etc. I'm closing this issue as the initial report is not something that can be resolved - it is how the sensor works. I will be creating a new issue to add rotation to this library to be able to implement in the CLUE library to handle the sensor rotation.
As mentioned, looks like https://github.com/adafruit/Adafruit_CircuitPython_APDS9960/issues/25 dealt with this.
Debra (@geekmomprojects on Twitter) has been trying to use the Light + Gesture + Proximity: APDS9960 on CLUE and it has been either returning no value (distance) or irregular values (gesture). This library is quite old (9/2017) and may not be entirely functional under CircuitPython 5. I also posted in the CLUE library.