Skip to content

Fixes issue #7 whereby the read method should be renamed to raw_uv #8

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 2 commits into from
May 11, 2019
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
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Usage Example

# take 10 readings
for j in range(10):
uv_raw = uv.read
uv_raw = uv.uv_raw
risk_level = uv.get_index(uv_raw)
print('Reading: {0} | Risk Level: {1}'.format(uv_raw, risk_level))
time.sleep(1)
Expand Down
18 changes: 8 additions & 10 deletions adafruit_veml6070.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class VEML6070:

# take 10 readings
for j in range(10):
uv_raw = uv.read
uv_raw = uv.uv_raw
risk_level = uv.get_index(uv_raw)
print('Reading: ', uv_raw, ' | Risk Level: ', risk_level)
time.sleep(1)
Expand Down Expand Up @@ -145,20 +145,18 @@ def __init__(self, i2c_bus, _veml6070_it="VEML6070_1_T", ack=False):


@property
def read(self):
def uv_raw(self):
"""
Reads and returns the value of the UV intensity.
"""
read_buf = bytearray(2)
buffer = bytearray(2)
with self.i2c_low as i2c_low:
i2c_low.readinto(read_buf, end=1)
i2c_low.readinto(buffer, end=1)

with self.i2c_high as i2c_high:
i2c_high.readinto(read_buf, start=1)
i2c_high.readinto(buffer, start=1)

uvi = read_buf[1] << 8 | read_buf[0]

return uvi
return buffer[1] << 8 | buffer[0]

@property
def ack(self):
Expand Down Expand Up @@ -231,7 +229,7 @@ def sleep(self):

def wake(self):
"""
Wakes the VEML6070 from sleep. ``[veml6070].read`` will also wake from sleep.
Wakes the VEML6070 from sleep. ``[veml6070].uv_raw`` will also wake from sleep.
"""
self.buf[0] = (self._ack << 5 | self._ack_thd << 4 |
_VEML6070_INTEGRATION_TIME[self._it][0] << 2 | 0x02)
Expand All @@ -241,7 +239,7 @@ def wake(self):
def get_index(self, _raw):
"""
Calculates the UV Risk Level based on the captured UV reading. Requres the ``_raw``
argument (from ``veml6070.read``). Risk level is available for Integration Times (IT)
argument (from ``veml6070.uv_raw``). Risk level is available for Integration Times (IT)
1, 2, & 4. The result is automatically scaled to the current IT setting.

LEVEL* UV Index
Expand Down
2 changes: 1 addition & 1 deletion examples/veml6070_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# take 10 readings
for j in range(10):
uv_raw = uv.read
uv_raw = uv.uv_raw
risk_level = uv.get_index(uv_raw)
print('Reading: {0} | Risk Level: {1}'.format(uv_raw, risk_level))
time.sleep(1)