From 78ac7f108d3c2d8f3d8199e83855726cdcf4fc93 Mon Sep 17 00:00:00 2001 From: Florian Rohrer Date: Sat, 14 Dec 2024 17:41:35 +0100 Subject: [PATCH] added example --- CONTRIBUTING.md | 10 +++++----- src/sts1_sensors/edu/ADXL345.py | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 43217cb..e55cbb4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,8 +4,8 @@ ## Making a new release * (On Raspberry Pi) Run `pytest`. -* Go to pyproject.toml and increase the version number -* Go to docs/source/conf.py and increase the version number -* Merge into main -* Merge into release. This will automaticall update the docs. -* On Github: Make a release. This will automatically publish it to PyPI +* Go to pyproject.toml and increase the version number. +* Go to docs/source/conf.py and increase the version number. +* Merge into main. +* Merge into release. This will automatically update the docs. +* On Github: Make a release. This will automatically publish it to PyPI. diff --git a/src/sts1_sensors/edu/ADXL345.py b/src/sts1_sensors/edu/ADXL345.py index 4606c2e..9ac3052 100644 --- a/src/sts1_sensors/edu/ADXL345.py +++ b/src/sts1_sensors/edu/ADXL345.py @@ -18,6 +18,14 @@ def __init__(self, range=2, datarate=50, x_offset=0, y_offset=0, z_offset=0, add :param int z_offset: z-axis offset, defaults to 0. :param hexadecimal address: Physical address of the sensor on the board (see `i2cdetect` command). Allowed values: `[0x1D, 0x3A, 0x3B, 0x53]`. If None, the environment variable `STS1_SENSOR_ADDRESS_AVXL345` will be used. If environment variable is not found, 0x53 will be used. :param SMBus bus: A SMBus object. If None, this class will generate its own, defaults to None. + + Example: + + .. code-block:: python + + accel = ADXL345(range=2, datarate=50) + x, y, z = accel.get_g() + print(f"{x=:.2f} g, {y=:.2f} g, {z=:.2f} g") """ super().__init__(possible_addresses=[0x1D, 0x3A, 0x3B, 0x53], bus=bus)