Skip to content
This repository has been archived by the owner on Dec 15, 2024. It is now read-only.

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jposada202020 committed Jun 22, 2023
1 parent 2fcac8d commit d9601e4
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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_]*))$
Expand Down
1 change: 0 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ build:
python:
install:
- requirements: docs/requirements.txt
- requirements: requirements.txt
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,3 @@ Take a look at the examples directory
Documentation
=============
API documentation for this library can be found on `Read the Docs <https://micropython-ags02ma.readthedocs.io/en/latest/>`_.

3 changes: 0 additions & 3 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ AGS02MA

.. automodule:: micropython_ags02ma.ags02ma
:members:

.. automodule:: micropython_ags02ma.i2c_helpers
:members:
17 changes: 17 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
11 changes: 11 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 4 additions & 11 deletions micropython_ags02ma/ags02ma.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT

Adafruit-Blinka

0 comments on commit d9601e4

Please sign in to comment.