changed the way the gesture method handles reading when no data.

This commit is contained in:
mrmcwethy 2018-01-01 12:43:39 -07:00
parent 69082fc3f6
commit 2f28492443

View file

@ -204,12 +204,10 @@ class APDS9960:
up_down_diff = 0
left_right_diff = 0
gesture_received = 0
time.sleep(0.030) # 30 ms
n_recs = self._read8(APDS9960_GFLVL)
if not n_recs:
continue
if n_recs:
with self.i2c_device as i2c:
i2c.write(buffer, end=1, stop=False)
@ -255,7 +253,7 @@ class APDS9960:
self._saw_left_start += 1
# saw a leading or trailing edge; start timer
if up_down_diff != 0 or left_right_diff != 0:
if up_down_diff or left_right_diff:
time_mark = time.monotonic()
# finished when a gesture is detected or ran out of time (300ms)