Skip to content

Change proximity to a property #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Usage Example
apds.enable_proximity_interrupt = True

while True:
print(apds.proximity())
print(apds.proximity)
apds.clear_interrupt()

Hardware Set-up
Expand Down Expand Up @@ -153,7 +153,7 @@ To check for a object in proximity, see if a gesture is available first, then ge

while True:
if not interrupt_pin.value:
print(apds.proximity())
print(apds.proximity)

# clear the interrupt
apds.clear_interrupt()
Expand Down
3 changes: 2 additions & 1 deletion adafruit_apds9960/apds9960.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,9 @@ def gesture_proximity_threshold(self):
def gesture_proximity_threshold(self, thresh):
self._write8(APDS9960_GPENTH, thresh & 0xff)

@property
def proximity(self):
"""proximity value: range 0-255"""
"""Proximity value: range 0-255"""
return self._read8(APDS9960_PDATA)

def clear_interrupt(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/apds9960_proximity_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
while True:
# print the proximity reading when the interrupt pin goes low
if not int_pin.value:
print(apds.proximity())
print(apds.proximity)

# clear the interrupt
apds.clear_interrupt()
13 changes: 13 additions & 0 deletions examples/apds9960_simpletest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import time
import board
import busio
from adafruit_apds9960.apds9960 import APDS9960

i2c = busio.I2C(board.SCL, board.SDA)
apds = APDS9960(i2c)

apds.enable_proximity = True

while True:
print(apds.proximity)
time.sleep(0.2)