Skip to content

Commit 7b6fa1d

Browse files
authored
Merge pull request #8 from WindFishDiety/UVReadRaw
Fixes issue #7 whereby the read method should be renamed to raw_uv
2 parents dbdec4c + a4a3e47 commit 7b6fa1d

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Usage Example
4545
4646
# take 10 readings
4747
for j in range(10):
48-
uv_raw = uv.read
48+
uv_raw = uv.uv_raw
4949
risk_level = uv.get_index(uv_raw)
5050
print('Reading: {0} | Risk Level: {1}'.format(uv_raw, risk_level))
5151
time.sleep(1)

adafruit_veml6070.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class VEML6070:
105105
106106
# take 10 readings
107107
for j in range(10):
108-
uv_raw = uv.read
108+
uv_raw = uv.uv_raw
109109
risk_level = uv.get_index(uv_raw)
110110
print('Reading: ', uv_raw, ' | Risk Level: ', risk_level)
111111
time.sleep(1)
@@ -145,20 +145,18 @@ def __init__(self, i2c_bus, _veml6070_it="VEML6070_1_T", ack=False):
145145

146146

147147
@property
148-
def read(self):
148+
def uv_raw(self):
149149
"""
150150
Reads and returns the value of the UV intensity.
151151
"""
152-
read_buf = bytearray(2)
152+
buffer = bytearray(2)
153153
with self.i2c_low as i2c_low:
154-
i2c_low.readinto(read_buf, end=1)
154+
i2c_low.readinto(buffer, end=1)
155155

156156
with self.i2c_high as i2c_high:
157-
i2c_high.readinto(read_buf, start=1)
157+
i2c_high.readinto(buffer, start=1)
158158

159-
uvi = read_buf[1] << 8 | read_buf[0]
160-
161-
return uvi
159+
return buffer[1] << 8 | buffer[0]
162160

163161
@property
164162
def ack(self):
@@ -231,7 +229,7 @@ def sleep(self):
231229

232230
def wake(self):
233231
"""
234-
Wakes the VEML6070 from sleep. ``[veml6070].read`` will also wake from sleep.
232+
Wakes the VEML6070 from sleep. ``[veml6070].uv_raw`` will also wake from sleep.
235233
"""
236234
self.buf[0] = (self._ack << 5 | self._ack_thd << 4 |
237235
_VEML6070_INTEGRATION_TIME[self._it][0] << 2 | 0x02)
@@ -241,7 +239,7 @@ def wake(self):
241239
def get_index(self, _raw):
242240
"""
243241
Calculates the UV Risk Level based on the captured UV reading. Requres the ``_raw``
244-
argument (from ``veml6070.read``). Risk level is available for Integration Times (IT)
242+
argument (from ``veml6070.uv_raw``). Risk level is available for Integration Times (IT)
245243
1, 2, & 4. The result is automatically scaled to the current IT setting.
246244
247245
LEVEL* UV Index

examples/veml6070_simpletest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

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

0 commit comments

Comments
 (0)