Skip to content

Commit 785f8f6

Browse files
authored
Merge pull request #37 from anecdata/main
Revert #31 to re-enable chip-internal interrupt features
2 parents 0f10cef + 70917cb commit 785f8f6

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

adafruit_veml7700.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
import time
3535

3636
import adafruit_bus_device.i2c_device as i2cdevice
37-
from adafruit_register.i2c_bit import RWBit
37+
from adafruit_register.i2c_bit import ROBit, RWBit
3838
from adafruit_register.i2c_bits import RWBits
39-
from adafruit_register.i2c_struct import ROUnaryStruct
39+
from adafruit_register.i2c_struct import ROUnaryStruct, UnaryStruct
4040
from micropython import const
4141

4242
try:
@@ -144,9 +144,11 @@ class VEML7700:
144144
time.sleep(0.1)
145145
"""
146146

147-
# ALS_CONF_0 - ALS gain, integration time, shutdown.
147+
# ALS_CONF_0 - ALS gain, integration time, interrupt, and shutdown.
148148
light_shutdown = RWBit(0x00, 0, register_width=2)
149149
"""Ambient light sensor shutdown. When ``True``, ambient light sensor is disabled."""
150+
light_interrupt = RWBit(0x00, 1, register_width=2)
151+
"""Enable interrupt. ``True`` to enable, ``False`` to disable."""
150152
light_gain = RWBits(2, 0x00, 11, register_width=2)
151153
"""Ambient light gain setting. Gain settings are 2, 1, 1/4 and 1/8. Settings options are:
152154
ALS_GAIN_2, ALS_GAIN_1, ALS_GAIN_1_4, ALS_GAIN_1_8.
@@ -193,6 +195,18 @@ class VEML7700:
193195
194196
"""
195197

198+
# ALS_WH - ALS high threshold window setting
199+
light_high_threshold = UnaryStruct(0x01, "<H")
200+
"""Ambient light sensor interrupt high threshold setting."""
201+
# ALS_WL - ALS low threshold window setting
202+
light_low_threshold = UnaryStruct(0x02, "<H")
203+
"""Ambient light sensor interrupt low threshold setting."""
204+
# ALS_INT - ALS INT trigger event
205+
light_interrupt_high = ROBit(0x06, 14, register_width=2)
206+
"""Ambient light high threshold interrupt flag. Triggered when high threshold exceeded."""
207+
light_interrupt_low = ROBit(0x06, 15, register_width=2)
208+
"""Ambient light low threshold interrupt flag. Triggered when low threshold exceeded."""
209+
196210
def __init__(self, i2c_bus: I2C, address: int = 0x10) -> None:
197211
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
198212
for _ in range(3):

0 commit comments

Comments
 (0)