-
Notifications
You must be signed in to change notification settings - Fork 1
Add proximity function and minor changes on the gesture function #1
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
base: main
Are you sure you want to change the base?
Conversation
paj7620.py
Outdated
| CW = CW | ||
| CCW = CCW | ||
| WAVE = WAVE | ||
| NONE = 0x00 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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|
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. |
|
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): |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange comment.
| return 0 # This line was the primary indentation issue. | |
| return 0 |
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:
Gesture constants (UP, DOWN, etc.) are now class attributes for easier access:
Added NONE = 0x00 constant for no gesture detected
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( )
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!