From dec0073edd2b8516dbd5602b07107227bfe07211 Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Fri, 21 Aug 2020 12:07:57 +0200 Subject: [PATCH] docs(max86150): Document pycardium API Signed-off-by: Rahix <rahix@rahix.de> --- Documentation/conf.py | 2 ++ Documentation/index.rst | 1 + Documentation/pycardium/max86150.rst | 5 +++++ pycardium/modules/py/max86150.py | 22 +++++++++++++++------- 4 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 Documentation/pycardium/max86150.rst diff --git a/Documentation/conf.py b/Documentation/conf.py index b80d8dad..2186b6da 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -114,8 +114,10 @@ autodoc_mock_imports = [ "sys_display", "sys_leds", "sys_max30001", + "sys_max86150", "sys_config", "ucollections", + "uerrno", "urandom", "utime", ] diff --git a/Documentation/index.rst b/Documentation/index.rst index f6ce6fcd..f83d9ee7 100644 --- a/Documentation/index.rst +++ b/Documentation/index.rst @@ -25,6 +25,7 @@ Last but not least, if you want to start hacking the lower-level firmware, the pycardium/bhi160 pycardium/bme680 pycardium/max30001 + pycardium/max86150 pycardium/buttons pycardium/color pycardium/config diff --git a/Documentation/pycardium/max86150.rst b/Documentation/pycardium/max86150.rst new file mode 100644 index 00000000..3e8a8690 --- /dev/null +++ b/Documentation/pycardium/max86150.rst @@ -0,0 +1,5 @@ +``max86150`` - MAX86150 +======================= + +.. automodule:: max86150 + :members: diff --git a/pycardium/modules/py/max86150.py b/pycardium/modules/py/max86150.py index 7a799c1c..c52665c9 100644 --- a/pycardium/modules/py/max86150.py +++ b/pycardium/modules/py/max86150.py @@ -8,13 +8,19 @@ Max86150Data = ucollections.namedtuple("Max86150Data", ["red", "infrared", "ecg" class MAX86150: """ - The MAX86150 class provides a stram interface to the MAX86150 PPG and ECG. + The MAX86150 class provides a stream interface to the MAX86150 PPG and ECG. + + **Example**: .. code-block:: python - import MAX86150 + import max86150 m = max86150.MAX86150() - m.read() + + data = m.read() + for sample in data: + print("Red: {} Infrared: {} ECG: {}", sample.red, sample.infrared, sample.ecg) + m.close() """ @@ -22,8 +28,8 @@ class MAX86150: """ Initializes the MAX86150 (if it is not already running). - :param callback: If not None: A callback which is called with the data when ever new data is available - + :param callback: If not None: A callback which is called with the data + when ever new data is available """ self.active = False self.stream_id = -uerrno.ENODEV @@ -35,7 +41,9 @@ class MAX86150: def enable_sensor(self): """ - Enables the sensor. Automatically called by __init__. + Enables the sensor. + + Automatically called when instanciating the sensor object. """ interrupt.disable_callback(self.interrupt_id) interrupt.set_callback(self.interrupt_id, self._interrupt) @@ -68,7 +76,7 @@ class MAX86150: def read(self): """ - Read as many samples (signed integer) as currently available. + Read as many samples as currently available. """ assert self.active, "Sensor is inactive" result = [] -- GitLab