Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library for CircuitPython 5 may not be working, CLUE sensor issues #16

Closed
TheKitty opened this issue Feb 10, 2020 · 7 comments
Closed

Comments

@TheKitty
Copy link

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.

@geekmomprojects
Copy link

geekmomprojects commented Feb 10, 2020

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")

@ladyada
Copy link
Member

ladyada commented Feb 10, 2020

OK! the detection is off by 90 degrees cause the sensor is rotated on the CLUE compared to a breakout

@TheKitty TheKitty changed the title Library for CLUE and CircuitPython 5 may not be currently functional Library for CircuitPython 5 may not be working, CLUE sensor issues Feb 13, 2020
@dastels
Copy link
Collaborator

dastels commented Feb 13, 2020

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.

@kevinjwalters
Copy link

kevinjwalters commented Feb 29, 2020

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.

@kattni
Copy link

kattni commented May 4, 2020

I've created two new issues for the two related issues mentioned in this thread.

@kattni
Copy link

kattni commented May 4, 2020

@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.

@kattni kattni closed this as completed May 4, 2020
@kevinjwalters
Copy link

As mentioned, looks like #25 dealt with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants