Skip to content

Commit dbb04b6

Browse files
committedDec 28, 2013
Update Adafruit_VCNL4000.py
add a function to read ambient light from VCNL4000 sensor
1 parent 2d4678f commit dbb04b6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎Adafruit_VCNL4000/Adafruit_VCNL4000.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,11 @@ def read_proximity(self):
5151
return self.i2c.readU16(VCNL4000_PROXIMITYDATA)
5252
time.sleep(0.001)
5353

54-
54+
# Read data from ambient sensor
55+
def read_ambient(self):
56+
self.i2c.write8(VCNL4000_COMMAND, VCNL4000_MEASUREAMBIENT)
57+
while True:
58+
result = self.i2c.readU8(VCNL4000_COMMAND)
59+
if (result and VCNL4000_AMBIENTREADY):
60+
return self.i2c.readU16(VCNL4000_AMBIENTDATA)
61+
time.sleep(0.001)

0 commit comments

Comments
 (0)