diff --git a/.pylintrc b/.pylintrc index c35c98f..8c81d71 100644 --- a/.pylintrc +++ b/.pylintrc @@ -80,7 +80,7 @@ class-rgx=[A-Z_][a-zA-Z0-9_]+$ const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ docstring-min-length=-1 function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ -good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_,cs +good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_,cs,TVOC include-naming-hint=no inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 6686702..94e63f2 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -12,4 +12,3 @@ build: python: install: - requirements: docs/requirements.txt - - requirements: requirements.txt diff --git a/README.rst b/README.rst index 5711704..8d30984 100644 --- a/README.rst +++ b/README.rst @@ -88,4 +88,3 @@ Take a look at the examples directory Documentation ============= API documentation for this library can be found on `Read the Docs `_. - diff --git a/docs/api.rst b/docs/api.rst index ff9731f..b5b9022 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -7,6 +7,3 @@ AGS02MA .. automodule:: micropython_ags02ma.ags02ma :members: - -.. automodule:: micropython_ags02ma.i2c_helpers - :members: diff --git a/docs/conf.py b/docs/conf.py index 70d505c..cfcd6aa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,6 +10,23 @@ sys.path.insert(0, os.path.abspath("..")) +try: + # Inject mock modules so that we can build the + # documentation without having the real stuff available + from mock import Mock + + to_be_mocked = [ + "micropython", + "machine", + ] + for module in to_be_mocked: + sys.modules[module] = Mock() + print("Mocked '{}' module".format(module)) + + import micropython_ags02ma +except ImportError: + raise SystemExit("micropython_ags02ma has to be importable") + # -- General configuration ------------------------------------------------ extensions = [ diff --git a/docs/requirements.txt b/docs/requirements.txt index 8a9508b..378eb11 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -3,3 +3,14 @@ # SPDX-License-Identifier: Unlicense sphinx-immaterial + +docutils >=0.14,<0.18 + +# sphinx 5.3.0 requires Jinja2 >=3.0 and docutils >=0.14,<0.20 +sphinx >=5.0.0,<6 + +# replaces outdated and no longer maintained m2rr +myst-parser >= 0.18.1,<1 + +# mock imports of "micropython" +mock >=4.0.3,<5 diff --git a/micropython_ags02ma/ags02ma.py b/micropython_ags02ma/ags02ma.py index a4fdaaf..9d0f5a5 100644 --- a/micropython_ags02ma/ags02ma.py +++ b/micropython_ags02ma/ags02ma.py @@ -15,21 +15,14 @@ """ import time +import struct from micropython import const -try: - import struct -except ImportError: - import ustruct as struct - -try: - from typing import Tuple -except ImportError: - pass __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/jposada202020/MicroPython_AGS02MA.git" + _DATA = const(0x00) _AGS02MA_CRC8_POLYNOMIAL = const(0x31) _AGS02MA_CRC8_INIT = const(0xFF) @@ -92,14 +85,14 @@ def _read_reg(self, addr: int, delayms: int) -> int: """ data = bytearray(5) - self._i2c.writeto(self._addr, bytes([0x00])) + self._i2c.writeto(self._addr, bytes([addr])) time.sleep(delayms / 1000) self._i2c.readfrom_into(self._addr, data) if self._generate_crc(data) != 0: raise RuntimeError("CRC check failed") - val, crc = struct.unpack(">IB", data) + val, _ = struct.unpack(">IB", data) return val @property diff --git a/requirements.txt b/requirements.txt index 11fd7c4..83461cf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,3 @@ # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya # # SPDX-License-Identifier: MIT - -Adafruit-Blinka