liske / python-apds9960

Python APDS-9960 Library
GNU General Public License v3.0
78 stars 27 forks source link

Problems in readGesture() #5

Closed zixiiu closed 6 years ago

zixiiu commented 6 years ago

Here is what I get when i try to use your sample code for RPi.

Traceback (most recent call last):
  File "test.py", line 39, in <module>
    motion = apds.readGesture()
  File "/home/pi/.local/lib/python2.7/site-packages/apds9960/device.py", line 192, in readGesture
    self.gesture_data_.u_data[self.gesture_data_.index] = fifo_data[i + 0]
IndexError: list assignment index out of range

Here is what I get when I try to print the list and the index (last 2 loop):

[137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 0]
31
[137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137]
32

looks like self.gesture_data_.u_data has 32 item and self.gesture_data_.index doing +1 in each loop.

zixiiu commented 6 years ago

Turn out to be I actually brought a wrong sensor. Please close my issue.