Skip to content

Commit 637de6b

Browse files
committed
change proximity to a property
1 parent d27d181 commit 637de6b

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Usage Example
7272
apds.enable_proximity_interrupt = True
7373
7474
while True:
75-
print(apds.proximity())
75+
print(apds.proximity)
7676
apds.clear_interrupt()
7777
7878
Hardware Set-up
@@ -153,7 +153,7 @@ To check for a object in proximity, see if a gesture is available first, then ge
153153
154154
while True:
155155
if not interrupt_pin.value:
156-
print(apds.proximity())
156+
print(apds.proximity)
157157
158158
# clear the interrupt
159159
apds.clear_interrupt()

adafruit_apds9960/apds9960.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,9 @@ def gesture_proximity_threshold(self):
320320
def gesture_proximity_threshold(self, thresh):
321321
self._write8(APDS9960_GPENTH, thresh & 0xff)
322322

323+
@property
323324
def proximity(self):
324-
"""proximity value: range 0-255"""
325+
"""Proximity value: range 0-255"""
325326
return self._read8(APDS9960_PDATA)
326327

327328
def clear_interrupt(self):

examples/apds9960_proximity_simpletest.py

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

1919
# clear the interrupt
2020
apds.clear_interrupt()

examples/apds9960_simpletest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import time
2+
import board
3+
import busio
4+
from adafruit_apds9960.apds9960 import APDS9960
5+
6+
i2c = busio.I2C(board.SCL, board.SDA)
7+
apds = APDS9960(i2c)
8+
9+
apds.enable_proximity = True
10+
11+
while True:
12+
print(apds.proximity)
13+
time.sleep(0.2)

0 commit comments

Comments
 (0)