Skip to content

Conversation

@noqman
Copy link

@noqman noqman commented Dec 2, 2025

Hello! 👋
I am using the PAJ7620 sensor in my project, and I need both gesture and proximity features. The current library only has gesture, so I decided to make some changes and add proximity support.

Changes:

  1. Added proximity reading methods:
proximity_raw()   # raw register value from register 0x6C (S_AvgY[8:1])
proximity()       # remapped thevalue to 0–255 scale 
  1. Gesture constants (UP, DOWN, etc.) are now class attributes for easier access:

  2. Added NONE = 0x00 constant for no gesture detected

  3. Renamed driver class from PAJ7620Gesture ➜ PAJ7620 since the sensor handles both gesture + proximity sensing. I also rename the function to read the gesture data from read( ) to gesture( )

  4. Added _write_u8() helper for possible future register writes

I already tested the library, and it works fine. This update still works with your example code but in line 15 need to change from gesture = sensor.read() to gesture = sensor.gesture()

Let me know if anything needs adjustment — happy to update!

paj7620.py Outdated
CW = CW
CCW = CCW
WAVE = WAVE
NONE = 0x00
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need to duplicate this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the idea of this to make the flag constants also available through the class since. but it’s not a big deal, I can remove it

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to add NONE to the original set then.

paj7620.py Outdated
with self.device as device:
self.buf[0] = reg & 0xFF
self.buf[1] = value & 0xFF
device.write(self.buf)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem to be used anywhere?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part actually I use other block, but I forgot to remove it when cleaning up the code. sorry

paj7620.py Outdated

with self.device as device:
device.write_then_readinto(bytes([0x6C]), self.buf, in_end=1)
raw_value = self.buf[0]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the with block could end here

paj7620.py Outdated
device.write(self.buf)

def read(self):
def gesture(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you leave the original method name for backward compatibility?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I put it like this? it will become backward compatibility but yeah, it is a bit repetitive

def read(self):
    return self.gesture()

but if that’s not okay, no worries I can revert back to the original

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a big problem with this, but I'm also fine with leaving it as read and not having gesture at all. I understand the desire for clarity, but this is primarily a gesture sensor after all, so I don't think we need the rename.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be done more compactly as

read = gesture

@deshipu
Copy link
Owner

deshipu commented Dec 2, 2025

This pull request looks like it was generated using automatic code generation tools without much checking afterwards. Please don't do that. Next time just send the prompt.

@noqman
Copy link
Author

noqman commented Dec 3, 2025

I’m very sorry about all of that. Actually, my team is working on a guidebook for our Pico 2 expansion board, and the PAJ7620 is one of the IC that we use. Since your library is already included in the CircuitPython community bundle libraries, it would be great if our users can get the libraries needed for the guide in the CircuitPython community bundle.

I'll revise the code as per your comment and check everything thoroughly first before request for PR.

paj7620.py Outdated
device.write(self.buf)

def read(self):
def gesture(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be done more compactly as

read = gesture

paj7620.py Outdated
raw_value = self.buf[0]
# Map raw_value from 70-255 to 0-255; clamp values below 70 to 0
if raw_value < 70:
return 0 # This line was the primary indentation issue.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange comment.

Suggested change
return 0 # This line was the primary indentation issue.
return 0

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

Successfully merging this pull request may close these issues.

3 participants