-
Notifications
You must be signed in to change notification settings - Fork 8
Update Functions To Use @property & setter Structure #5
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
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,13 +161,17 @@ 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. | ||
""" | ||
return self._ack | ||
|
||
@ack.setter | ||
def ack(self, new_ack=False): | ||
if new_ack not in (True, False): | ||
raise ValueError("ACK must be 'True' or 'False'.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be replaced with a |
||
self._ack = int(new_ack) | ||
|
@@ -176,12 +180,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 | ||
tannewt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@ack_threshold.setter | ||
def ack_threshold(self, new_ack_thd=0): | ||
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 +199,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()) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the default value since its a setter.