Skip to content

Fixing Pylint Short Names #67

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
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
88 changes: 45 additions & 43 deletions adafruit_bme280/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,36 +284,36 @@ class Adafruit_BME280_I2C(Adafruit_BME280_Advanced):

**Quickstart: Importing and using the BME280**

Here is an example of using the :class:`Adafruit_BME280_I2C`.
First you will need to import the libraries to use the sensor
Here is an example of using the :class:`Adafruit_BME280_I2C`.
First you will need to import the libraries to use the sensor

.. code-block:: python
.. code-block:: python

import board
import adafruit_bme280.advanced as adafruit_bme280
import board
import adafruit_bme280.advanced as adafruit_bme280

Once this is done you can define your `board.I2C` object and define your sensor object
Once this is done you can define your `board.I2C` object and define your sensor object

.. code-block:: python
.. code-block:: python

i2c = board.I2C() # uses board.SCL and board.SDA
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
i2c = board.I2C() # uses board.SCL and board.SDA
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)

You need to setup the pressure at sea level
You need to setup the pressure at sea level

.. code-block:: python
.. code-block:: python

bme280.sea_level_pressure = 1013.25
bme280.sea_level_pressure = 1013.25

Now you have access to the :attr:`temperature`, :attr:`relative_humidity`
:attr:`pressure` and :attr:`altitude` attributes
Now you have access to the :attr:`temperature`, :attr:`relative_humidity`
:attr:`pressure` and :attr:`altitude` attributes

.. code-block:: python
.. code-block:: python

temperature = bme280.temperature
relative_humidity = bme280.relative_humidity
pressure = bme280.pressure
altitude = bme280.altitude
temperature = bme280.temperature
relative_humidity = bme280.relative_humidity
pressure = bme280.pressure
altitude = bme280.altitude

"""

Expand All @@ -325,7 +325,7 @@ class Adafruit_BME280_SPI(Adafruit_BME280_Advanced):
"""Driver for BME280 connected over SPI

:param ~busio.SPI spi: SPI device
:param ~digitalio.DigitalInOut cs: Chip Select
:param ~digitalio.DigitalInOut chip_select: Chip Select
:param int baudrate: Clock rate, default is 100000. Can be changed with :meth:`baudrate`

.. note::
Expand All @@ -334,40 +334,42 @@ class Adafruit_BME280_SPI(Adafruit_BME280_Advanced):

**Quickstart: Importing and using the BME280**

Here is an example of using the :class:`Adafruit_BME280_SPI` class.
First you will need to import the libraries to use the sensor
Here is an example of using the :class:`Adafruit_BME280_SPI` class.
First you will need to import the libraries to use the sensor

.. code-block:: python
.. code-block:: python

import board
from digitalio import DigitalInOut
import adafruit_bme280.advanced as adafruit_bme280
import board
from digitalio import DigitalInOut
import adafruit_bme280.advanced as adafruit_bme280

Once this is done you can define your `board.SPI` object and define your sensor object
Once this is done you can define your `board.SPI` object and define your sensor object

.. code-block:: python
.. code-block:: python

cs = digitalio.DigitalInOut(board.D10)
spi = board.SPI()
bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, cs)
chip_select = digitalio.DigitalInOut(board.D10)
spi = board.SPI()
bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, chip_select)

You need to setup the pressure at sea level
You need to setup the pressure at sea level

.. code-block:: python
.. code-block:: python

bme280.sea_level_pressure = 1013.25
bme280.sea_level_pressure = 1013.25

Now you have access to the :attr:`temperature`, :attr:`relative_humidity`
:attr:`pressure` and :attr:`altitude` attributes
Now you have access to the :attr:`temperature`, :attr:`relative_humidity`
:attr:`pressure` and :attr:`altitude` attributes

.. code-block:: python
.. code-block:: python

temperature = bme280.temperature
relative_humidity = bme280.relative_humidity
pressure = bme280.pressure
altitude = bme280.altitude
temperature = bme280.temperature
relative_humidity = bme280.relative_humidity
pressure = bme280.pressure
altitude = bme280.altitude

"""

def __init__(self, spi: SPI, cs: DigitalInOut, baudrate: int = 100000) -> None:
super().__init__(SPI_Impl(spi, cs, baudrate))
def __init__(
self, spi: SPI, chip_select: DigitalInOut, baudrate: int = 100000
) -> None:
super().__init__(SPI_Impl(spi, chip_select, baudrate))
50 changes: 26 additions & 24 deletions adafruit_bme280/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,36 +331,36 @@ class Adafruit_BME280_I2C(Adafruit_BME280):

**Quickstart: Importing and using the BME280**

Here is an example of using the :class:`Adafruit_BME280_I2C`.
First you will need to import the libraries to use the sensor
Here is an example of using the :class:`Adafruit_BME280_I2C`.
First you will need to import the libraries to use the sensor

.. code-block:: python
.. code-block:: python

import board
from adafruit_bme280 import basic as adafruit_bme280
import board
from adafruit_bme280 import basic as adafruit_bme280

Once this is done you can define your `board.I2C` object and define your sensor object
Once this is done you can define your `board.I2C` object and define your sensor object

.. code-block:: python
.. code-block:: python

i2c = board.I2C() # uses board.SCL and board.SDA
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
i2c = board.I2C() # uses board.SCL and board.SDA
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)

You need to setup the pressure at sea level
You need to setup the pressure at sea level

.. code-block:: python
.. code-block:: python

bme280.sea_level_pressure = 1013.25
bme280.sea_level_pressure = 1013.25

Now you have access to the :attr:`temperature`, :attr:`relative_humidity`
:attr:`pressure` and :attr:`altitude` attributes
Now you have access to the :attr:`temperature`, :attr:`relative_humidity`
:attr:`pressure` and :attr:`altitude` attributes

.. code-block:: python
.. code-block:: python

temperature = bme280.temperature
relative_humidity = bme280.relative_humidity
pressure = bme280.pressure
altitude = bme280.altitude
temperature = bme280.temperature
relative_humidity = bme280.relative_humidity
pressure = bme280.pressure
altitude = bme280.altitude

"""

Expand All @@ -373,7 +373,7 @@ class Adafruit_BME280_SPI(Adafruit_BME280):
"""Driver for BME280 connected over SPI

:param ~busio.SPI spi: SPI device
:param ~digitalio.DigitalInOut cs: Chip Select
:param ~digitalio.DigitalInOut chip_select: Chip Select
:param int baudrate: Clock rate, default is 100000. Can be changed with :meth:`baudrate`

.. note::
Expand All @@ -395,9 +395,9 @@ class Adafruit_BME280_SPI(Adafruit_BME280):

.. code-block:: python

cs = digitalio.DigitalInOut(board.D10)
chip_select = digitalio.DigitalInOut(board.D10)
spi = board.SPI()
bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, cs)
bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, chip_select)

You need to setup the pressure at sea level

Expand All @@ -417,5 +417,7 @@ class Adafruit_BME280_SPI(Adafruit_BME280):

"""

def __init__(self, spi: SPI, cs: DigitalInOut, baudrate: int = 100000) -> None:
super().__init__(SPI_Impl(spi, cs, baudrate))
def __init__(
self, spi: SPI, chip_select: DigitalInOut, baudrate: int = 100000
) -> None:
super().__init__(SPI_Impl(spi, chip_select, baudrate))
8 changes: 4 additions & 4 deletions adafruit_bme280/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ def read_register(self, register: int, length: int) -> bytearray:
return result

def write_register_byte(self, register: int, value: int) -> None:
"Write to the device register."
"""Write to the device register"""
with self._i2c as i2c:
i2c.write(bytes([register & 0xFF, value & 0xFF]))


class SPI_Impl:
"Protocol implemenation for the SPI bus."
"""Protocol implemenation for the SPI bus."""

def __init__(
self,
spi: SPI,
cs: DigitalInOut, # pylint: disable=invalid-name
chip_select: DigitalInOut,
baudrate: int = 100000,
) -> None:
from adafruit_bus_device import ( # pylint: disable=import-outside-toplevel
spi_device,
)

self._spi = spi_device.SPIDevice(spi, cs, baudrate=baudrate)
self._spi = spi_device.SPIDevice(spi, chip_select, baudrate=baudrate)

def read_register(self, register: int, length: int) -> bytearray:
"Read from the device register."
Expand Down
3 changes: 3 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@

.. automodule:: adafruit_bme280.advanced
:members:

.. automodule:: adafruit_bme280.protocol
:members: