Skip to content

Commit b7fbce5

Browse files
committed
update functions to use property & setter structure
1 parent 13f6407 commit b7fbce5

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

adafruit_veml6070.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,17 @@ def read(self):
161161

162162
return uvi
163163

164-
def set_ack(self, new_ack=False):
164+
@property
165+
def ack(self):
165166
"""
166167
Turns on or off the ACKnowledge function of the sensor. The ACK function will send
167168
a signal to the host when the value of the sensed UV light changes beyond the
168-
programmed threshold. Use ``[veml6070].set_ack_threshold`` to change between the two
169-
available threshold settings.
169+
programmed threshold.
170170
"""
171+
return self._ack
172+
173+
@ack.setter
174+
def ack(self, new_ack=False):
171175
if new_ack not in (True, False):
172176
raise ValueError("ACK must be 'True' or 'False'.")
173177
self._ack = int(new_ack)
@@ -176,12 +180,17 @@ def set_ack(self, new_ack=False):
176180
with self.i2c_cmd as i2c_cmd:
177181
i2c_cmd.write(self.buf)
178182

179-
def set_ack_threshold(self, new_ack_thd=0):
183+
@property
184+
def ack_threshold(self):
180185
"""
181-
Sets the ACKnowledge Threshold, which alerts the host controller to value changes
186+
The ACKnowledge Threshold, which alerts the host controller to value changes
182187
greater than the threshold. Available settings are: ``0`` = 102 steps; ``1`` = 145 steps.
183188
``0`` is the default setting.
184189
"""
190+
return self._ack_thd
191+
192+
@ack_threshold.setter
193+
def ack_threshold(self, new_ack_thd=0):
185194
if new_ack_thd not in (0, 1):
186195
raise ValueError("ACK Threshold must be '0' or '1'.")
187196
self._ack_thd = int(new_ack_thd)
@@ -190,14 +199,18 @@ def set_ack_threshold(self, new_ack_thd=0):
190199
with self.i2c_cmd as i2c_cmd:
191200
i2c_cmd.write(self.buf)
192201

193-
194-
def set_integration_time(self, new_it):
202+
@property
203+
def integration_time(self):
195204
"""
196-
Sets the Integration Time of the sensor. This is the refresh interval of the
205+
The Integration Time of the sensor, which is the refresh interval of the
197206
sensor. The higher the refresh interval, the more accurate the reading is (at
198207
the cost of less sampling). The available settings are: ``VEML6070_HALF_T``,
199208
``VEML6070_1_T``, ``VEML6070_2_T``, ``VEML6070_4_T``.
200209
"""
210+
return self._it
211+
212+
@integration_time.setter
213+
def integration_time(self, new_it):
201214
if new_it not in _VEML6070_INTEGRATION_TIME:
202215
raise ValueError("Integration Time invalid. Valid values are: ",
203216
_VEML6070_INTEGRATION_TIME.keys())

0 commit comments

Comments
 (0)