Skip to content

Add param types to docstrings, use tables #25

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 2 commits into from
Feb 24, 2022
Merged
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
59 changes: 37 additions & 22 deletions adafruit_vl6180x.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ class VL6180X:
"""Create an instance of the VL6180X distance sensor. You must pass in
the following parameters:

:param i2c: An instance of the I2C bus connected to the sensor.
:param ~I2C i2c: An instance of the I2C bus connected to the sensor.

Optionally you can specify:

:param address: The I2C address of the sensor. If not specified the sensor's
:param int address: The I2C address of the sensor. If not specified the sensor's
default value will be assumed.
:param int offset: The offset to be applied to measurements, in mm
"""

def __init__(
Expand Down Expand Up @@ -168,7 +169,8 @@ def range_history_enabled(self) -> bool:

def start_range_continuous(self, period: int = 100) -> None:
"""Start continuous range mode
:param period: Time delay between measurements in ms

:param int period: Time delay between measurements, in milliseconds
"""
# Set range between measurements
period_reg: int = 0
Expand Down Expand Up @@ -230,14 +232,22 @@ def _read_range_continuous(self) -> int:
def read_lux(self, gain: int) -> float:
"""Read the lux (light value) from the sensor and return it. Must
specify the gain value to use for the lux reading:
- ALS_GAIN_1 = 1x
- ALS_GAIN_1_25 = 1.25x
- ALS_GAIN_1_67 = 1.67x
- ALS_GAIN_2_5 = 2.5x
- ALS_GAIN_5 = 5x
- ALS_GAIN_10 = 10x
- ALS_GAIN_20 = 20x
- ALS_GAIN_40 = 40x

================= =====
Setting Value
================= =====
``ALS_GAIN_1`` 1x
``ALS_GAIN_1_25`` 1.25x
``ALS_GAIN_1_67`` 1.67x
``ALS_GAIN_2_5`` 2.5x
``ALS_GAIN_5`` 5x
``ALS_GAIN_10`` 10x
``ALS_GAIN_20`` 20x
``ALS_GAIN_40`` 40x
================= =====

:param int gain: The gain value to use

"""
reg = self._read_8(_VL6180X_REG_SYSTEM_INTERRUPT_CONFIG)
reg &= ~0x38
Expand Down Expand Up @@ -286,17 +296,22 @@ def range_status(self) -> int:
"""Retrieve the status/error from a previous range read. This will
return a constant value such as:

- ERROR_NONE - No error
- ERROR_SYSERR_1 - System error 1 (see datasheet)
- ERROR_SYSERR_5 - System error 5 (see datasheet)
- ERROR_ECEFAIL - ECE failure
- ERROR_NOCONVERGE - No convergence
- ERROR_RANGEIGNORE - Outside range ignored
- ERROR_SNR - Too much noise
- ERROR_RAWUFLOW - Raw value underflow
- ERROR_RAWOFLOW - Raw value overflow
- ERROR_RANGEUFLOW - Range underflow
- ERROR_RANGEOFLOW - Range overflow
===================== ==============================
Error Description
===================== ==============================
``ERROR_NONE`` No error
``ERROR_SYSERR_1`` System error 1 (see datasheet)
``ERROR_SYSERR_5`` System error 5 (see datasheet)
``ERROR_ECEFAIL`` ECE failure
``ERROR_NOCONVERGE`` No convergence
``ERROR_RANGEIGNORE`` Outside range ignored
``ERROR_SNR`` Too much noise
``ERROR_RAWUFLOW`` Raw value underflow
``ERROR_RAWOFLOW`` Raw value overflow
``ERROR_RANGEUFLOW`` Range underflow
``ERROR_RANGEOFLOW`` Range overflow
===================== ==============================

"""
return self._read_8(_VL6180X_REG_RESULT_RANGE_STATUS) >> 4

Expand Down