diff --git a/adafruit_veml6070.py b/adafruit_veml6070.py index db8fb98..edb6940 100644 --- a/adafruit_veml6070.py +++ b/adafruit_veml6070.py @@ -144,7 +144,6 @@ def __init__(self, i2c_bus, _veml6070_it="VEML6070_1_T", ack=False): i2c_cmd.write(self.buf) - @property def read(self): """ @@ -161,14 +160,18 @@ def read(self): return uvi - def set_ack(self, new_ack=False): + @property + def ack(self): """ Turns on or off the ACKnowledge function of the sensor. The ACK function will send a signal to the host when the value of the sensed UV light changes beyond the - programmed threshold. Use ``[veml6070].set_ack_threshold`` to change between the two - available threshold settings. + programmed threshold. """ - if new_ack not in (True, False): + return self._ack + + @ack.setter + def ack(self, new_ack): + if new_ack != bool(new_ack): raise ValueError("ACK must be 'True' or 'False'.") self._ack = int(new_ack) self.buf[0] = (self._ack << 5 | self._ack_thd << 4 | @@ -176,12 +179,17 @@ def set_ack(self, new_ack=False): with self.i2c_cmd as i2c_cmd: i2c_cmd.write(self.buf) - def set_ack_threshold(self, new_ack_thd=0): + @property + def ack_threshold(self): """ - Sets the ACKnowledge Threshold, which alerts the host controller to value changes + The ACKnowledge Threshold, which alerts the host controller to value changes greater than the threshold. Available settings are: ``0`` = 102 steps; ``1`` = 145 steps. ``0`` is the default setting. """ + return self._ack_thd + + @ack_threshold.setter + def ack_threshold(self, new_ack_thd): if new_ack_thd not in (0, 1): raise ValueError("ACK Threshold must be '0' or '1'.") self._ack_thd = int(new_ack_thd) @@ -190,14 +198,18 @@ def set_ack_threshold(self, new_ack_thd=0): with self.i2c_cmd as i2c_cmd: i2c_cmd.write(self.buf) - - def set_integration_time(self, new_it): + @property + def integration_time(self): """ - Sets the Integration Time of the sensor. This is the refresh interval of the + The Integration Time of the sensor, which is the refresh interval of the sensor. The higher the refresh interval, the more accurate the reading is (at the cost of less sampling). The available settings are: ``VEML6070_HALF_T``, ``VEML6070_1_T``, ``VEML6070_2_T``, ``VEML6070_4_T``. """ + return self._it + + @integration_time.setter + def integration_time(self, new_it): if new_it not in _VEML6070_INTEGRATION_TIME: raise ValueError("Integration Time invalid. Valid values are: ", _VEML6070_INTEGRATION_TIME.keys())