@@ -144,7 +144,6 @@ def __init__(self, i2c_bus, _veml6070_it="VEML6070_1_T", ack=False):
144
144
i2c_cmd .write (self .buf )
145
145
146
146
147
-
148
147
@property
149
148
def read (self ):
150
149
"""
@@ -161,27 +160,36 @@ def read(self):
161
160
162
161
return uvi
163
162
164
- def set_ack (self , new_ack = False ):
163
+ @property
164
+ def ack (self ):
165
165
"""
166
166
Turns on or off the ACKnowledge function of the sensor. The ACK function will send
167
167
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.
168
+ programmed threshold.
170
169
"""
171
- if new_ack not in (True , False ):
170
+ return self ._ack
171
+
172
+ @ack .setter
173
+ def ack (self , new_ack ):
174
+ if new_ack != bool (new_ack ):
172
175
raise ValueError ("ACK must be 'True' or 'False'." )
173
176
self ._ack = int (new_ack )
174
177
self .buf [0 ] = (self ._ack << 5 | self ._ack_thd << 4 |
175
178
_VEML6070_INTEGRATION_TIME [self ._it ][0 ] << 2 | 0x02 )
176
179
with self .i2c_cmd as i2c_cmd :
177
180
i2c_cmd .write (self .buf )
178
181
179
- def set_ack_threshold (self , new_ack_thd = 0 ):
182
+ @property
183
+ def ack_threshold (self ):
180
184
"""
181
- Sets the ACKnowledge Threshold, which alerts the host controller to value changes
185
+ The ACKnowledge Threshold, which alerts the host controller to value changes
182
186
greater than the threshold. Available settings are: ``0`` = 102 steps; ``1`` = 145 steps.
183
187
``0`` is the default setting.
184
188
"""
189
+ return self ._ack_thd
190
+
191
+ @ack_threshold .setter
192
+ def ack_threshold (self , new_ack_thd ):
185
193
if new_ack_thd not in (0 , 1 ):
186
194
raise ValueError ("ACK Threshold must be '0' or '1'." )
187
195
self ._ack_thd = int (new_ack_thd )
@@ -190,14 +198,18 @@ def set_ack_threshold(self, new_ack_thd=0):
190
198
with self .i2c_cmd as i2c_cmd :
191
199
i2c_cmd .write (self .buf )
192
200
193
-
194
- def set_integration_time (self , new_it ):
201
+ @ property
202
+ def integration_time (self ):
195
203
"""
196
- Sets the Integration Time of the sensor. This is the refresh interval of the
204
+ The Integration Time of the sensor, which is the refresh interval of the
197
205
sensor. The higher the refresh interval, the more accurate the reading is (at
198
206
the cost of less sampling). The available settings are: ``VEML6070_HALF_T``,
199
207
``VEML6070_1_T``, ``VEML6070_2_T``, ``VEML6070_4_T``.
200
208
"""
209
+ return self ._it
210
+
211
+ @integration_time .setter
212
+ def integration_time (self , new_it ):
201
213
if new_it not in _VEML6070_INTEGRATION_TIME :
202
214
raise ValueError ("Integration Time invalid. Valid values are: " ,
203
215
_VEML6070_INTEGRATION_TIME .keys ())
0 commit comments