Skip to content

Coerce led_current to be between 4-258mA. #4

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

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions adafruit_as7341.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

* Author(s): Bryan Siepert

Implementation Notes
Implementation NotesF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this typo

--------------------

**Hardware:**
Expand Down Expand Up @@ -200,8 +200,8 @@ class AS7341: # pylint:disable=too-many-instance-attributes
"""Library for the AS7341 Sensor


:param ~busio.I2C i2c_bus: The I2C bus the AS7341 is connected to.
:param address: The I2C address of the sensor
:param ~busio.I2C i2c_bus: The I2C bus the AS7341 is connected to.
:param address: The I2C address of the sensor

"""

Expand Down Expand Up @@ -583,8 +583,7 @@ def _set_smux(self, smux_addr, smux_out1, smux_out2):

@property
def gain(self):
"""The ADC gain multiplier. Must be a valid `adafruit_as7341.Gain`
"""
"""The ADC gain multiplier. Must be a valid `adafruit_as7341.Gain`"""
return self._gain

@gain.setter
Expand Down Expand Up @@ -616,7 +615,9 @@ def led_current(self):
@led_current.setter
@_low_bank
def led_current(self, led_curent):
new_current = int((led_curent - 4) / 2)
"""set the LED current supplied by the chip. Values are coerced to the range
4-258mA. Fractional values rounded to nearest valid number"""
new_current = int((min(258, max(4, led_curent)) - 4) / 2)
self._led_current_bits = new_current

@property
Expand Down