Add proximity function and minor changes on the gesture function#1
Add proximity function and minor changes on the gesture function#1noqman wants to merge 2 commits intodeshipu:mainfrom
Conversation
paj7620.py
Outdated
| CW = CW | ||
| CCW = CCW | ||
| WAVE = WAVE | ||
| NONE = 0x00 |
There was a problem hiding this comment.
why do you need to duplicate this?
There was a problem hiding this comment.
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.
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.
this doesn't seem to be used anywhere?
There was a problem hiding this comment.
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] |
paj7620.py
Outdated
| device.write(self.buf) | ||
|
|
||
| def read(self): | ||
| def gesture(self): |
There was a problem hiding this comment.
can you leave the original method name for backward compatibility?
There was a problem hiding this comment.
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.
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.
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.
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.
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!