Skip to content

Commit 75a055c

Browse files
committed
fixed proximity repeat zeros and ones
1 parent 18ee608 commit 75a055c

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

adafruit_apds9960/apds9960.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ def gesture(self): #pylint: disable-msg=too-many-branches
190190
buffer = bytearray(129)
191191
buffer[0] = APDS9960_GFIFO_U
192192
if not self._gesture_valid:
193-
# print("no valid data")
194193
return 0
195194

196195
time_mark = 0
@@ -324,7 +323,8 @@ def proximity_interrupt_threshold(self):
324323
"""Returns a tuple containing low and high threshold
325324
followed by the proximity interrupt persistance.
326325
Set the proximity interrupt threshold values using a tuple of zero to
327-
three values: low threshold, high threshold, persistance """
326+
three values: low threshold, high threshold, persistance.
327+
persistance defaults to 4 if not provided"""
328328
return self.read8(APDS9960_PILT), \
329329
self.read8(APDS9960_PIHT), \
330330
self._proximity_persistance
@@ -335,8 +335,10 @@ def proximity_interrupt_threshold(self, setting_tuple):
335335
self.write8(APDS9960_PILT, setting_tuple[0])
336336
if len(setting_tuple) > 1:
337337
self.write8(APDS9960_PIHT, setting_tuple[1])
338+
persist = 4 # default 4
338339
if len(setting_tuple) > 2:
339-
self._proximity_persistance = setting_tuple[2]
340+
persist = min(setting_tuple[2], 7)
341+
self._proximity_persistance = persist
340342

341343

342344
@property
@@ -381,7 +383,6 @@ def write8(self, command, abyte):
381383
buf = bytearray(2)
382384
buf[0] = command
383385
buf[1] = abyte
384-
print(buf)
385386
with self.i2c_device as i2c:
386387
i2c.write(buf)
387388

adafruit_apds9960/colorutility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def calculate_color_temperature(r, g, b):
4444
xchrome = x / (x + y + z)
4545
ychrome = y / (x + y + z)
4646

47-
# 3. Use McCamy's formula to determine the CCT
47+
# 3. Use to determine the CCT
4848
n = (xchrome - 0.3320) / (0.1858 - ychrome)
4949

5050
# 4. Calculate the final CCT

examples/proximity.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
while True:
1515
# print the proximity reading when the interrupt pin goes low
1616
if not int_pin.value:
17-
prox_value = apds.proximity()
18-
if prox_value:
19-
print(prox_value)
17+
print(apds.proximity())
2018

2119
# clear the interrupt
2220
apds.clear_interrupt()

0 commit comments

Comments
 (0)