From aaa717edb8b1bc9b3ecd6eb7451b9fb4116a394d Mon Sep 17 00:00:00 2001 From: Kattni Date: Thu, 1 Mar 2018 18:33:58 -0500 Subject: [PATCH 01/22] Update to method names and linting --- README.rst | 10 ++-- adafruit_lsm303.py | 57 ++++++++++------------- examples/fast_accel/fast_accel.py | 2 +- examples/fast_mag/fast_mag.py | 2 +- examples/raw_and_cooked/raw_and_cooked.py | 15 +++--- examples/slow_both/slow_both.py | 4 +- 6 files changed, 41 insertions(+), 49 deletions(-) diff --git a/README.rst b/README.rst index fee906d..37be849 100644 --- a/README.rst +++ b/README.rst @@ -27,7 +27,7 @@ Usage Example ============= .. code-block:: python - + import time import board import busio @@ -38,10 +38,10 @@ Usage Example sensor = adafruit_lsm303.LSM303(i2c) while True: - raw_accel_x, raw_accel_y, raw_accel_z = sensor.raw_accelerometer - accel_x, accel_y, accel_z = sensor.accelerometer - raw_mag_x, raw_mag_y, raw_mag_z = sensor.raw_magnetometer - mag_x, mag_y, mag_z = sensor.magnetometer + raw_accel_x, raw_accel_y, raw_accel_z = sensor.raw_acceleration + accel_x, accel_y, accel_z = sensor.acceleration + raw_mag_x, raw_mag_y, raw_mag_z = sensor.raw_magnetic + mag_x, mag_y, mag_z = sensor.magnetic print('Acceleration raw: ({0:6d}, {1:6d}, {2:6d}), (m/s^2): ({3:10.3f}, {4:10.3f}, {5:10.3f})'.format(raw_accel_x, raw_accel_y, raw_accel_z, accel_x, accel_y, accel_z)) print('Magnetometer raw: ({0:6d}, {1:6d}, {2:6d}), (gauss): ({3:10.3f}, {4:10.3f}, {5:10.3f})'.format(raw_mag_x, raw_mag_y, raw_mag_z, mag_x, mag_y, mag_z)) diff --git a/adafruit_lsm303.py b/adafruit_lsm303.py index 553c839..fa8723f 100644 --- a/adafruit_lsm303.py +++ b/adafruit_lsm303.py @@ -116,6 +116,8 @@ _LSM303ACCEL_MG_LSB = 16704.0 _GRAVITY_STANDARD = 9.80665 # Earth's gravity in m/s^2 _GAUSS_TO_MICROTESLA = 100.0 # Gauss to micro-Tesla multiplier +# pylint: enable=bad-whitespace + class LSM303(object): """Driver for the LSM303 accelerometer/magnetometer.""" @@ -128,33 +130,31 @@ class LSM303(object): def __init__(self, i2c): self._accel_device = I2CDevice(i2c, _ADDRESS_ACCEL) self._mag_device = I2CDevice(i2c, _ADDRESS_MAG) - self._write_u8(self._accel_device, _REG_ACCEL_CTRL_REG1_A, 0x27) # Enable the accelerometer - self._write_u8(self._mag_device, _REG_MAG_MR_REG_M, 0x00) # Enable the magnetometer + self._write_u8(self._accel_device, _REG_ACCEL_CTRL_REG1_A, 0x27) # Enable the accelerometer + self._write_u8(self._mag_device, _REG_MAG_MR_REG_M, 0x00) # Enable the magnetometer self._lsm303mag_gauss_lsb_xy = 1100.0 self._lsm303mag_gauss_lsb_z = 980.0 self._mag_gain = MAGGAIN_1_3 self._mag_rate = MAGRATE_0_7 @property - def raw_accelerometer(self): + def raw_acceleration(self): """The raw accelerometer sensor values. A 3-tuple of X, Y, Z axis values that are 16-bit signed integers. """ self._read_bytes(self._accel_device, _REG_ACCEL_OUT_X_L_A | 0x80, 6, self._BUFFER) return struct.unpack_from('hhh', self._BUFFER[0:6]) return [n >> 4 for n in raw_values] - @property - def magnetometer(self): + def magnetic(self): """The processed magnetometer sensor values. A 3-tuple of X, Y, Z axis values in microteslas that are signed floats. """ - mag_x, mag_y, mag_z = self.raw_magnetometer + mag_x, mag_y, mag_z = self.raw_magnetic return (mag_x / self._lsm303mag_gauss_lsb_xy * _GAUSS_TO_MICROTESLA, mag_y / self._lsm303mag_gauss_lsb_xy * _GAUSS_TO_MICROTESLA, mag_z / self._lsm303mag_gauss_lsb_z * _GAUSS_TO_MICROTESLA) - @property def mag_gain(self): """The magnetometer's gain.""" return self._mag_gain - @mag_gain.setter def mag_gain(self, value): - # pylint: disable=line-too-long - assert value in (MAGGAIN_1_3, MAGGAIN_1_9, MAGGAIN_2_5, MAGGAIN_4_0, MAGGAIN_4_7, MAGGAIN_5_6, MAGGAIN_8_1) - # pylint: enable=line-too-long + assert value in (MAGGAIN_1_3, MAGGAIN_1_9, MAGGAIN_2_5, MAGGAIN_4_0, MAGGAIN_4_7, + MAGGAIN_5_6, MAGGAIN_8_1) self._mag_gain = value self._write_u8(self._mag_device, _REG_MAG_CRB_REG_M, self._mag_gain) if self._mag_gain == MAGGAIN_1_3: self._lsm303mag_gauss_lsb_xy = 1100.0 - self._lsm303mag_gauss_lsb_z = 980.0 + self._lsm303mag_gauss_lsb_z = 980.0 elif self._mag_gain == MAGGAIN_1_9: self._lsm303mag_gauss_lsb_xy = 855.0 - self._lsm303mag_gauss_lsb_z = 760.0 + self._lsm303mag_gauss_lsb_z = 760.0 elif self._mag_gain == MAGGAIN_2_5: self._lsm303mag_gauss_lsb_xy = 670.0 - self._lsm303mag_gauss_lsb_z = 600.0 + self._lsm303mag_gauss_lsb_z = 600.0 elif self._mag_gain == MAGGAIN_4_0: self._lsm303mag_gauss_lsb_xy = 450.0 - self._lsm303mag_gauss_lsb_z = 400.0 + self._lsm303mag_gauss_lsb_z = 400.0 elif self._mag_gain == MAGGAIN_4_7: self._lsm303mag_gauss_lsb_xy = 400.0 - self._lsm303mag_gauss_lsb_z = 355.0 + self._lsm303mag_gauss_lsb_z = 355.0 elif self._mag_gain == MAGGAIN_5_6: self._lsm303mag_gauss_lsb_xy = 330.0 - self._lsm303mag_gauss_lsb_z = 295.0 + self._lsm303mag_gauss_lsb_z = 295.0 elif self._mag_gain == MAGGAIN_8_1: self._lsm303mag_gauss_lsb_xy = 230.0 - self._lsm303mag_gauss_lsb_z = 205.0 - + self._lsm303mag_gauss_lsb_z = 205.0 @property def mag_rate(self): """The magnetometer update rate.""" return self._mag_rate - @mag_rate.setter def mag_rate(self, value): - # pylint: disable=line-too-long - assert value in (MAGRATE_0_7, MAGRATE_1_5, MAGRATE_3_0, MAGRATE_7_5, MAGRATE_15, MAGRATE_30, MAGRATE_75, MAGRATE_220) - # pylint: enable=line-too-long + assert value in (MAGRATE_0_7, MAGRATE_1_5, MAGRATE_3_0, MAGRATE_7_5, MAGRATE_15, MAGRATE_30, + MAGRATE_75, MAGRATE_220) self._mag_rate = value reg_m = ((value & 0x07) << 2) & 0xFF self._write_u8(self._mag_device, _REG_MAG_CRA_REG_M, reg_m) - def _read_u8(self, device, address): with device as i2c: self._BUFFER[0] = address & 0xFF @@ -235,15 +227,14 @@ def _read_u8(self, device, address): i2c.readinto(self._BUFFER, end=1) return self._BUFFER[0] - def _write_u8(self, device, address, val): with device as i2c: self._BUFFER[0] = address & 0xFF self._BUFFER[1] = val & 0xFF i2c.write(self._BUFFER, end=2) - # pylint: disable=no-self-use - def _read_bytes(self, device, address, count, buf): + @staticmethod + def _read_bytes(device, address, count, buf): with device as i2c: buf[0] = address & 0xFF i2c.write(buf, end=1, stop=False) diff --git a/examples/fast_accel/fast_accel.py b/examples/fast_accel/fast_accel.py index 9160879..4e603d8 100644 --- a/examples/fast_accel/fast_accel.py +++ b/examples/fast_accel/fast_accel.py @@ -9,5 +9,5 @@ sensor = adafruit_lsm303.LSM303(i2c) while True: - accel_x, accel_y, accel_z = sensor.accelerometer + accel_x, accel_y, accel_z = sensor.acceleration print('{0:10.3f} {1:10.3f} {2:10.3f}'.format(accel_x, accel_y, accel_z)) diff --git a/examples/fast_mag/fast_mag.py b/examples/fast_mag/fast_mag.py index 02713dc..fd6ccad 100644 --- a/examples/fast_mag/fast_mag.py +++ b/examples/fast_mag/fast_mag.py @@ -8,5 +8,5 @@ sensor = adafruit_lsm303.LSM303(i2c) while True: - mag_x, mag_y, mag_z = sensor.magnetometer + mag_x, mag_y, mag_z = sensor.magnetic print('{0:10.3f} {1:10.3f} {2:10.3f}'.format(mag_x, mag_y, mag_z)) diff --git a/examples/raw_and_cooked/raw_and_cooked.py b/examples/raw_and_cooked/raw_and_cooked.py index 8d710ca..ed3ec12 100644 --- a/examples/raw_and_cooked/raw_and_cooked.py +++ b/examples/raw_and_cooked/raw_and_cooked.py @@ -1,5 +1,4 @@ """ Display both accelerometer and magnetometer data once per second """ -# pylint: disable=line-too-long import time import board @@ -11,12 +10,14 @@ sensor = adafruit_lsm303.LSM303(i2c) while True: - raw_accel_x, raw_accel_y, raw_accel_z = sensor.raw_accelerometer - accel_x, accel_y, accel_z = sensor.accelerometer - raw_mag_x, raw_mag_y, raw_mag_z = sensor.raw_magnetometer - mag_x, mag_y, mag_z = sensor.magnetometer + raw_accel_x, raw_accel_y, raw_accel_z = sensor.raw_acceleration + accel_x, accel_y, accel_z = sensor.acceleration + raw_mag_x, raw_mag_y, raw_mag_z = sensor.raw_magnetic + mag_x, mag_y, mag_z = sensor.magnetic - print('Acceleration raw: ({0:6d}, {1:6d}, {2:6d}), (m/s^2): ({3:10.3f}, {4:10.3f}, {5:10.3f})'.format(raw_accel_x, raw_accel_y, raw_accel_z, accel_x, accel_y, accel_z)) - print('Magnetometer raw: ({0:6d}, {1:6d}, {2:6d}), (gauss): ({3:10.3f}, {4:10.3f}, {5:10.3f})'.format(raw_mag_x, raw_mag_y, raw_mag_z, mag_x, mag_y, mag_z)) + print('Acceleration raw: ({0:6d}, {1:6d}, {2:6d}), (m/s^2): ({3:10.3f}, {4:10.3f}, {5:10.3f})' + .format(raw_accel_x, raw_accel_y, raw_accel_z, accel_x, accel_y, accel_z)) + print('Magnetometer raw: ({0:6d}, {1:6d}, {2:6d}), (gauss): ({3:10.3f}, {4:10.3f}, {5:10.3f})' + .format(raw_mag_x, raw_mag_y, raw_mag_z, mag_x, mag_y, mag_z)) print('') time.sleep(1.0) diff --git a/examples/slow_both/slow_both.py b/examples/slow_both/slow_both.py index fe41c02..e3de69c 100644 --- a/examples/slow_both/slow_both.py +++ b/examples/slow_both/slow_both.py @@ -9,8 +9,8 @@ sensor = adafruit_lsm303.LSM303(i2c) while True: - acc_x, acc_y, acc_z = sensor.accelerometer - mag_x, mag_y, mag_z = sensor.magnetometer + acc_x, acc_y, acc_z = sensor.acceleration + mag_x, mag_y, mag_z = sensor.magnetic print('Acceleration (m/s^2): ({0:10.3f}, {1:10.3f}, {2:10.3f})'.format(acc_x, acc_y, acc_z)) print('Magnetometer (gauss): ({0:10.3f}, {1:10.3f}, {2:10.3f})'.format(mag_x, mag_y, mag_z)) From a7135b248ce0099a346147e9d506d88b3ff0965c Mon Sep 17 00:00:00 2001 From: Kattni Date: Thu, 1 Mar 2018 18:58:24 -0500 Subject: [PATCH 02/22] update magnetic to tuple --- adafruit_lsm303.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_lsm303.py b/adafruit_lsm303.py index fa8723f..effe567 100644 --- a/adafruit_lsm303.py +++ b/adafruit_lsm303.py @@ -160,7 +160,7 @@ def raw_magnetic(self): """ self._read_bytes(self._mag_device, _REG_MAG_OUT_X_H_M, 6, self._BUFFER) raw_values = struct.unpack_from('>hhh', self._BUFFER[0:6]) - return [n >> 4 for n in raw_values] + return tuple([n >> 4 for n in raw_values]) @property def magnetic(self): From f44b26edd5d9c598cc9fef658fd05a35b4d1bd86 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Wed, 14 Mar 2018 23:53:48 -0500 Subject: [PATCH 03/22] setup docs folder --- docs/_static/favicon.ico | Bin 0 -> 4414 bytes api.rst => docs/api.rst | 0 conf.py => docs/conf.py | 17 ++++++++++---- docs/examples.rst | 20 ++++++++++++++++ docs/index.rst | 48 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 docs/_static/favicon.ico rename api.rst => docs/api.rst (100%) rename conf.py => docs/conf.py (88%) create mode 100644 docs/examples.rst create mode 100644 docs/index.rst diff --git a/docs/_static/favicon.ico b/docs/_static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..5aca98376a1f7e593ebd9cf41a808512c2135635 GIT binary patch literal 4414 zcmd^BX;4#F6n=SG-XmlONeGrD5E6J{RVh+e928U#MG!$jWvO+UsvWh`x&VqGNx*en zx=qox7Dqv{kPwo%fZC$dDwVpRtz{HzTkSs8QhG0)%Y=-3@Kt!4ag|JcIo?$-F|?bXVS9UDUyev>MVZQ(H8K4#;BQW-t2CPorj8^KJrMX}QK zp+e<;4ldpXz~=)2GxNy811&)gt-}Q*yVQpsxr@VMoA##{)$1~=bZ1MmjeFw?uT(`8 z^g=09<=zW%r%buwN%iHtuKSg|+r7HkT0PYN*_u9k1;^Ss-Z!RBfJ?Un4w(awqp2b3 z%+myoFis_lTlCrGx2z$0BQdh+7?!JK#9K9@Z!VrG zNj6gK5r(b4?YDOLw|DPRoN7bdP{(>GEG41YcN~4r_SUHU2hgVtUwZG@s%edC;k7Sn zC)RvEnlq~raE2mY2ko64^m1KQL}3riixh?#J{o)IT+K-RdHae2eRX91-+g!y`8^># z-zI0ir>P%Xon)!@xp-BK2bDYUB9k613NRrY6%lVjbFcQc*pRqiK~8xtkNPLxt}e?&QsTB}^!39t_%Qb)~Ukn0O%iC;zt z<&A-y;3h++)>c1br`5VFM~5(83!HKx$L+my8sW_c#@x*|*vB1yU)_dt3vH;2hqPWx zAl^6@?ipx&U7pf`a*>Yq6C85nb+B=Fnn+(id$W#WB^uHAcZVG`qg;rWB}ubvi(Y>D z$ei>REw$#xp0SHAd^|1hq&9HJ=jKK8^zTH~nk)G?yUcmTh9vUM6Y0LMw4(gYVY$D$ zGl&WY&H<)BbJ&3sYbKjx1j^=3-0Q#f^}(aP1?8^`&FUWMp|rmtpK)bLQ1Zo?^s4jqK=Lfg*9&geMGVQ z#^-*!V`fG@;H&{M9S8%+;|h&Qrxym0Ar>WT4BCVLR8cGXF=JmEYN(sNT(9vl+S|%g z8r7nXQ(95i^`=+XHo|){$vf2$?=`F$^&wFlYXyXg$B{a>$-Fp+V}+D;9k=~Xl~?C4 zAB-;RKXdUzBJE{V&d&%R>aEfFe;vxqI$0@hwVM}gFeQR@j}a>DDxR+n+-*6|_)k%% z*mSpDV|=5I9!&VC&9tD%fcVygWZV!iIo2qFtm#!*(s|@ZT33*Ad;+<|3^+yrp*;oH zBSYLV(H1zTU?2WjrCQoQW)Z>J2a=dTriuvezBmu16`tM2fm7Q@d4^iqII-xFpwHGI zn9CL}QE*1vdj2PX{PIuqOe5dracsciH6OlAZATvE8rj6ykqdIjal2 z0S0S~PwHb-5?OQ-tU-^KTG@XNrEVSvo|HIP?H;7ZhYeZkhSqh-{reE!5di;1zk$#Y zCe7rOnlzFYJ6Z#Hm$GoidKB=2HBCwm`BbZVeZY4ukmG%1uz7p2URs6c9j-Gjj^oQV zsdDb3@k2e`C$1I5ML5U0Qs0C1GAp^?!*`=|Nm(vWz3j*j*8ucum2;r0^-6Aca=Gv) zc%}&;!+_*S2tlnnJnz0EKeRmw-Y!@9ob!XQBwiv}^u9MkaXHvM=!<3YX;+2#5Cj5pp?FEK750S3BgeSDtaE^ zXUM@xoV6yBFKfzvY20V&Lr0yC + FLORA Accelerometer/Compass Sensor - LSM303 - v1.0 + +.. toctree:: + :caption: Other Links + + Download + CircuitPython Reference Documentation + CircuitPython Support Forum + Discord Chat + Adafruit Learning System + Adafruit Blog + Adafruit Store + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` From 18d2d684dfbebf23b406d2111dbc39f38a0e7a36 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Wed, 14 Mar 2018 23:55:00 -0500 Subject: [PATCH 04/22] updated .travis & .readthedocs.yml --- readthedocs.yml => .readthedocs.yml | 0 .travis.yml | 5 +++-- 2 files changed, 3 insertions(+), 2 deletions(-) rename readthedocs.yml => .readthedocs.yml (100%) diff --git a/readthedocs.yml b/.readthedocs.yml similarity index 100% rename from readthedocs.yml rename to .readthedocs.yml diff --git a/.travis.yml b/.travis.yml index d7d6402..fdf1191 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,16 +16,17 @@ deploy: provider: releases api_key: $GH_REPO_TOKEN file_glob: true - file: bundles/* + file: $TRAVIS_BUILD_DIR/bundles/* skip_cleanup: true overwrite: true on: tags: true install: - - pip install pylint circuitpython-build-tools + - pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme script: - pylint adafruit_lsm303.py - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*/*.py) - circuitpython-build-bundles --filename_prefix adafruit-circuitpython-lsm303 --library_location . + - cd docs && sphinx-build -E -W -b html . _build/html From 3506761567cb3ed0eb14db2f14f6ee64419e4581 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Wed, 14 Mar 2018 23:56:33 -0500 Subject: [PATCH 05/22] updated README --- README.rst | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 37be849..2541920 100644 --- a/README.rst +++ b/README.rst @@ -10,6 +10,10 @@ Introduction :target: https://discord.gg/nBQh6qu :alt: Discord +.. image:: https://travis-ci.org/adafruit/Adafruit_CircuitPython_LSM303.svg?branch=master + :target: https://travis-ci.org/adafruit/Adafruit_CircuitPython_LSM303 + :alt: Build Status + Adafruit CircuitPython module for the LSM303 6-DoF with 3-axis accelerometer and magnetometer Dependencies @@ -49,14 +53,6 @@ Usage Example time.sleep(1.0) -API Reference -============= - -.. toctree:: - :maxdepth: 2 - - api - Contributing ============ @@ -87,3 +83,27 @@ Then run the build: .. code-block:: shell circuitpython-build-bundles --filename_prefix adafruit-circuitpython-lsm303 --library_location . + + +Sphinx documentation +----------------------- + +Sphinx is used to build the documentation based on rST files and comments in the code. First, +install dependencies (feel free to reuse the virtual environment from above): + +.. code-block:: shell + + python3 -m venv .env + source .env/bin/activate + pip install Sphinx sphinx-rtd-theme + +Now, once you have the virtual environment activated: + +.. code-block:: shell + + cd docs + sphinx-build -E -W -b html . _build/html + +This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to +view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to +locally verify it will pass. \ No newline at end of file From 21dfdf8fa706e0896c30b5ad838162c43f2001ea Mon Sep 17 00:00:00 2001 From: sommersoft Date: Wed, 14 Mar 2018 23:59:37 -0500 Subject: [PATCH 06/22] updated info docstring --- adafruit_lsm303.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/adafruit_lsm303.py b/adafruit_lsm303.py index effe567..c7ac53b 100644 --- a/adafruit_lsm303.py +++ b/adafruit_lsm303.py @@ -20,13 +20,30 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. """ -`adafruit_LSM303` +`adafruit_lsm303` ==================================================== CircuitPython driver for the LSM303 accelerometer + magnetometer. * Author(s): Dave Astels + +Implementation Notes +-------------------- + +**Hardware:** + +* Adafruit `Triple-axis Accelerometer+Magnetometer (Compass) Board - LSM303 + `_ (Product ID: 1120) +* Adafruit `FLORA Accelerometer/Compass Sensor - LSM303 - v1.0 + `_ (Product ID: 1247) + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards: + https://github.com/adafruit/circuitpython/releases +* Adafruit's Bus Device library: + https://github.com/adafruit/Adafruit_CircuitPython_BusDevice """ try: From bfd7b020771571f2c08b3b380224538c65230562 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Wed, 11 Jul 2018 09:44:39 -0500 Subject: [PATCH 07/22] updated CoC Signed-off-by: sommersoft --- CODE_OF_CONDUCT.md | 123 ++++++++++++++++++++++++++++++++------------- 1 file changed, 88 insertions(+), 35 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 1617586..a9b258d 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,74 +1,127 @@ -# Contributor Covenant Code of Conduct +# Adafruit Community Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and +contributors and leaders pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, gender identity and expression, level of experience, -nationality, personal appearance, race, religion, or sexual identity and -orientation. +size, disability, ethnicity, gender identity and expression, level or type of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. ## Our Standards +We are committed to providing a friendly, safe and welcoming environment for +all. + Examples of behavior that contributes to creating a positive environment include: +* Be kind and courteous to others * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences +* Collaborating with other community members * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or -advances +* The use of sexualized language or imagery and sexual attention or advances +* The use of inappropriate images, including in a community member's avatar +* The use of inappropriate language, including in a community member's nickname +* Any spamming, flaming, baiting or other attention-stealing behavior +* Excessive or unwelcome helping; answering outside the scope of the question + asked * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +* Other conduct which could reasonably be considered inappropriate + +The goal of the standards and moderation guidelines outlined here is to build +and maintain a respectful community. We ask that you don’t just aim to be +"technically unimpeachable", but rather try to be your best self. + +We value many things beyond technical expertise, including collaboration and +supporting others within our community. Providing a positive experience for +other community members can have a much more significant impact than simply +providing the correct answer. ## Our Responsibilities -Project maintainers are responsible for clarifying the standards of acceptable +Project leaders are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions +Project leaders have the right and responsibility to remove, edit, or +reject messages, comments, commits, code, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. +permanently any community member for other behaviors that they deem +inappropriate, threatening, offensive, or harmful. -## Scope +## Moderation -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. +Instances of behaviors that violate the Adafruit Community Code of Conduct +may be reported by any member of the community. Community members are +encouraged to report these situations, including situations they witness +involving other community members. + +You may report in the following ways: + +In any situation, you may send an email to . -## Enforcement +On the Adafruit Discord, you may send an open message from any channel +to all Community Helpers by tagging @community helpers. You may also send an +open message from any channel, or a direct message to @kattni#1507, +@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or +@Andon#8175. -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at support@adafruit.com. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. +Email and direct message reports will be kept confidential. -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. +In situations on Discord where the issue is particularly egregious, possibly +illegal, requires immediate action, or violates the Discord terms of service, +you should also report the message directly to Discord. + +These are the steps for upholding our community’s standards of conduct. + +1. Any member of the community may report any situation that violates the +Adafruit Community Code of Conduct. All reports will be reviewed and +investigated. +2. If the behavior is an egregious violation, the community member who +committed the violation may be banned immediately, without warning. +3. Otherwise, moderators will first respond to such behavior with a warning. +4. Moderators follow a soft "three strikes" policy - the community member may +be given another chance, if they are receptive to the warning and change their +behavior. +5. If the community member is unreceptive or unreasonable when warned by a +moderator, or the warning goes unheeded, they may be banned for a first or +second offense. Repeated offenses will result in the community member being +banned. + +## Scope + +This Code of Conduct and the enforcement policies listed above apply to all +Adafruit Community venues. This includes but is not limited to any community +spaces (both public and private), the entire Adafruit Discord server, and +Adafruit GitHub repositories. Examples of Adafruit Community spaces include +but are not limited to meet-ups, audio chats on the Adafruit Discord, or +interaction at a conference. + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. As a community +member, you are representing our community, and are expected to behave +accordingly. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [http://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 1.4, available at +, +and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html). -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ +For other projects adopting the Adafruit Community Code of +Conduct, please contact the maintainers of those projects for enforcement. +If you wish to use this code of conduct for your own project, consider +explicitly mentioning your moderation policy or making a copy with your +own moderation policy so as to avoid confusion. \ No newline at end of file From 0d8f825677a7a82568c0714b71fc9026235ad6db Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Sun, 5 Aug 2018 15:10:41 -0400 Subject: [PATCH 08/22] PyPi setup. --- .gitignore | 6 +++++ .travis.yml | 39 ++++++++++++++--------------- adafruit_lsm303.py | 2 ++ docs/conf.py | 2 +- requirements.txt | 3 ++- setup.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 92 insertions(+), 21 deletions(-) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 0dd8629..55f127b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,12 @@ +*.mpy +.idea __pycache__ _build *.pyc .env build* bundles +*.DS_Store +.eggs +dist +**/*.egg-info \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index fdf1191..e6c13d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,33 @@ -# This is a common .travis.yml for generating library release zip files for -# CircuitPython library releases using circuitpython-build-tools. -# See https://github.com/adafruit/circuitpython-build-tools for detailed setup -# instructions. - dist: trusty sudo: false language: python python: - - "3.6" - +- '3.6' cache: - pip: true - + pip: true deploy: - provider: releases - api_key: $GH_REPO_TOKEN +- provider: releases + api_key: "$GITHUB_TOKEN" file_glob: true - file: $TRAVIS_BUILD_DIR/bundles/* + file: "$TRAVIS_BUILD_DIR/bundles/*" skip_cleanup: true overwrite: true on: tags: true - +- provider: pypi + user: adafruit-travis + on: + tags: true + password: + secure: VC/kB85L/5azjHGbgEVypF9z0tkPicR+KK+JMNbBu1aK8oemcLnoNb49aAlFLlHPf6f3ZoSosW6a+cylyZTODhbtrJJ82vfnBx6l7LJC8fubjnvDM4JYXbihWVVXM9o5e2Dow1R8gwPe+b/4LCKSBU1v5x9mIho5Qabp7lW3O+p5XVXFlpNW3PfMZ6zRGCIERbbkC6XuwCnwiwUAvCudQBTN9NbDzBvFvLiE1W7s3Ettwl8xQ5y2tgSmcfE2tFXVUkbTkg7yvRASgsTVFciu/DK8KdkO1InisTdRhjknHuMnIBS41reSxeNkKfeffVVbUAiUv0z7VWnKtikO2CenSjpRAdM+3bMV2V64keaLUJYE8ZYrnmqJsg0Vv/vpjRgak+LPWre1GatD+FzHPHavHA5ypdAAvYAI58fW06w62T8inYS7mOgP0uN72gkikxUCB/3r0lH7X+ov40Ryv6qJpXaKWzII1OJz974qQyTdqnzlcz5j2qwkD4D06zpkIQq7mVqYcUJ6IjJhk1/xySC4zWWdysgFA6Weq7wSC/QH2jLmU9OdhoMfIM2LwHZw3elqdIdzi2AIyM4on4jqd2WP6Gn3hAdk488MbLnLxLDhMz6OGHuzLSjwNooIivRnYa76rU8SlJ5LgrkXiypM2YAckIPRan57Cz4N+IVCIW/OAAM= install: - - pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme - +- pip install -r requirements.txt +- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme +- pip install --force-reinstall pylint==1.9.2 script: - - pylint adafruit_lsm303.py - - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*/*.py) - - circuitpython-build-bundles --filename_prefix adafruit-circuitpython-lsm303 --library_location . - - cd docs && sphinx-build -E -W -b html . _build/html +- pylint adafruit_lsm303.py +- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace + examples/*/*.py) +- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-lsm303 --library_location + . +- cd docs && sphinx-build -E -W -b html . _build/html && cd .. diff --git a/adafruit_lsm303.py b/adafruit_lsm303.py index c7ac53b..a666f1c 100644 --- a/adafruit_lsm303.py +++ b/adafruit_lsm303.py @@ -136,6 +136,8 @@ # pylint: enable=bad-whitespace +# pylint: disable=useless-object-inheritance +# Pylint issue needs to be fixed. class LSM303(object): """Driver for the LSM303 accelerometer/magnetometer.""" diff --git a/docs/conf.py b/docs/conf.py index 7fee6b6..9ac8fc1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,7 +18,7 @@ # Uncomment the below if you use native CircuitPython modules such as # digitalio, micropython and busio. List the modules you use. Without it, the # autodoc module docs will fail to generate with a warning. -autodoc_mock_imports = ["micropython", "adafruit_bus_device"] +# autodoc_mock_imports = ["micropython", "adafruit_bus_device"] intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} diff --git a/requirements.txt b/requirements.txt index c47d35a..3031961 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -adafruit-circuitpython-bus-device +Adafruit-Blinka +adafruit-circuitpython-busdevice diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..2bc9f24 --- /dev/null +++ b/setup.py @@ -0,0 +1,61 @@ +"""A setuptools based setup module. + +See: +https://packaging.python.org/en/latest/distributing.html +https://github.com/pypa/sampleproject +""" + +# Always prefer setuptools over distutils +from setuptools import setup, find_packages +# To use a consistent encoding +from codecs import open +from os import path + +here = path.abspath(path.dirname(__file__)) + +# Get the long description from the README file +with open(path.join(here, 'README.rst'), encoding='utf-8') as f: + long_description = f.read() + +setup( + name='adafruit-circuitpython-lsm303', + + use_scm_version=True, + setup_requires=['setuptools_scm'], + + description='CircuitPython library for LSM303 6-DoF with 3-axis accelerometer and magnetometer.', + long_description=long_description, + long_description_content_type='text/x-rst', + + # The project's main homepage. + url='https://github.com/adafruit/Adafruit_CircuitPython_LSM303', + + # Author details + author='Adafruit Industries', + author_email='circuitpython@adafruit.com', + + install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice'], + + # Choose your license + license='MIT', + + # See https://pypi.python.org/pypi?%3Aaction=list_classifiers + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Topic :: Software Development :: Libraries', + 'Topic :: System :: Hardware', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + ], + + # What does your project relate to? + keywords='adafruit lsm303 6dof 6-dof accelerometer magnetometer axis' + 'breakout hardware micropython circuitpython', + + # You can just specify the packages manually here if your project is + # simple. Or you can use find_packages(). + py_modules=['adafruit_lsm303'], +) From 95da80d5875e55bc0130119fc47d90526df12141 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Sun, 5 Aug 2018 15:13:23 -0400 Subject: [PATCH 09/22] linting --- adafruit_lsm303.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/adafruit_lsm303.py b/adafruit_lsm303.py index a666f1c..c7ac53b 100644 --- a/adafruit_lsm303.py +++ b/adafruit_lsm303.py @@ -136,8 +136,6 @@ # pylint: enable=bad-whitespace -# pylint: disable=useless-object-inheritance -# Pylint issue needs to be fixed. class LSM303(object): """Driver for the LSM303 accelerometer/magnetometer.""" From 28149d143aaeeeea9a5c3f829b8d6c502dfa13d4 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Mon, 20 Aug 2018 20:22:15 -0400 Subject: [PATCH 10/22] Renamed example to simpletest --- docs/examples.rst | 10 +++++----- .../{slow_both/slow_both.py => lsm303_simpletest.py} | 0 2 files changed, 5 insertions(+), 5 deletions(-) rename examples/{slow_both/slow_both.py => lsm303_simpletest.py} (100%) diff --git a/docs/examples.rst b/docs/examples.rst index 9153a57..110e053 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -3,6 +3,10 @@ Simple tests Ensure your device works with these simple tests. +.. literalinclude:: ../examples/lsm303_simpletest.py + :caption: examples/lsm303_simpletest.py + :linenos: + .. literalinclude:: ../examples/fast_accel/fast_accel.py :caption: examples/fast_accel/fast_accel.py :linenos: @@ -11,10 +15,6 @@ Ensure your device works with these simple tests. :caption: examples/fast_mag/fast_mag.py :linenos: -.. literalinclude:: ../examples/slow_both/slow_both.py - :caption: examples/slow_both/slow_both.py - :linenos: - .. literalinclude:: ../examples/raw_and_cooked/raw_and_cooked.py :caption: examples/raw_and_cooked/raw_and_cooked.py - :linenos: \ No newline at end of file + :linenos: diff --git a/examples/slow_both/slow_both.py b/examples/lsm303_simpletest.py similarity index 100% rename from examples/slow_both/slow_both.py rename to examples/lsm303_simpletest.py From de104b30a5b6353d19b544374e01ae52bfc500f0 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Tue, 14 Aug 2018 20:01:03 -0500 Subject: [PATCH 11/22] ignore the board module imports in .pylintrc Signed-off-by: sommersoft --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 81d8170..039eaec 100644 --- a/.pylintrc +++ b/.pylintrc @@ -156,7 +156,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis. It # supports qualified module names, as well as Unix pattern matching. -ignored-modules= +ignored-modules=board # Show a hint with possible names when a member name was not found. The aspect # of finding the hint is based on edit distance. From 6f4dbf70d0198daf465b82f424d8ae9b720f4193 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Thu, 11 Oct 2018 15:35:01 -0400 Subject: [PATCH 12/22] Reorder mag return values from XZY order to XYZ. --- adafruit_lsm303.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_lsm303.py b/adafruit_lsm303.py index c7ac53b..9cfffec 100644 --- a/adafruit_lsm303.py +++ b/adafruit_lsm303.py @@ -177,7 +177,8 @@ def raw_magnetic(self): """ self._read_bytes(self._mag_device, _REG_MAG_OUT_X_H_M, 6, self._BUFFER) raw_values = struct.unpack_from('>hhh', self._BUFFER[0:6]) - return tuple([n >> 4 for n in raw_values]) + values = tuple([n >> 4 for n in raw_values]) + return (values[0], values[2], values[1]) @property def magnetic(self): From 38ab491c4e8387a7b3d98bfd5380e7f8ad001452 Mon Sep 17 00:00:00 2001 From: Kevin Townsend Date: Fri, 12 Oct 2018 23:24:49 +0200 Subject: [PATCH 13/22] Removed erroneous 4-bit shift Values are already 16-bits signed, with 12-bit data, so it can be returned as is. The datasheet isn't terribly clear here, but testing leads me to the conclusion that the code in this PR is the correct solution. The math makes sense for 12-bit values in a 16-bit signed wrapper, though not full 16-bit data. The DS states at +/-2g on the accel 1 lsb = 1mg, so at 12-bits we get 4096mg or +/-2g. The values seem the be returned already formed as 16-bit signed integers, though, so the right-shift is incorrect. --- adafruit_lsm303.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/adafruit_lsm303.py b/adafruit_lsm303.py index 9cfffec..15acad1 100644 --- a/adafruit_lsm303.py +++ b/adafruit_lsm303.py @@ -177,8 +177,7 @@ def raw_magnetic(self): """ self._read_bytes(self._mag_device, _REG_MAG_OUT_X_H_M, 6, self._BUFFER) raw_values = struct.unpack_from('>hhh', self._BUFFER[0:6]) - values = tuple([n >> 4 for n in raw_values]) - return (values[0], values[2], values[1]) + return (raw_values[0], raw_values[2], raw_values[1]) @property def magnetic(self): From cb4b787490a6e6225b7b4530cfc77280eb3ada02 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Fri, 21 Dec 2018 13:12:35 -0600 Subject: [PATCH 14/22] change 'travis-ci.org' to 'travis-ci.com' --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 2541920..47b5f63 100644 --- a/README.rst +++ b/README.rst @@ -10,8 +10,8 @@ Introduction :target: https://discord.gg/nBQh6qu :alt: Discord -.. image:: https://travis-ci.org/adafruit/Adafruit_CircuitPython_LSM303.svg?branch=master - :target: https://travis-ci.org/adafruit/Adafruit_CircuitPython_LSM303 +.. image:: https://travis-ci.com/adafruit/Adafruit_CircuitPython_LSM303.svg?branch=master + :target: https://travis-ci.com/adafruit/Adafruit_CircuitPython_LSM303 :alt: Build Status Adafruit CircuitPython module for the LSM303 6-DoF with 3-axis accelerometer and magnetometer From e0ad9aa3255304ff57852eead770228789e7149c Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 10 May 2019 11:04:05 -0400 Subject: [PATCH 15/22] Added sensor name to example filenames, moved some out of folders --- examples/{fast_accel/fast_accel.py => lsm303_fast_accel.py} | 0 examples/{fast_mag/fast_mag.py => lsm303_fast_mag.py} | 0 .../raw_and_cooked.py => lsm303_raw_and_cooked.py} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename examples/{fast_accel/fast_accel.py => lsm303_fast_accel.py} (100%) rename examples/{fast_mag/fast_mag.py => lsm303_fast_mag.py} (100%) rename examples/{raw_and_cooked/raw_and_cooked.py => lsm303_raw_and_cooked.py} (100%) diff --git a/examples/fast_accel/fast_accel.py b/examples/lsm303_fast_accel.py similarity index 100% rename from examples/fast_accel/fast_accel.py rename to examples/lsm303_fast_accel.py diff --git a/examples/fast_mag/fast_mag.py b/examples/lsm303_fast_mag.py similarity index 100% rename from examples/fast_mag/fast_mag.py rename to examples/lsm303_fast_mag.py diff --git a/examples/raw_and_cooked/raw_and_cooked.py b/examples/lsm303_raw_and_cooked.py similarity index 100% rename from examples/raw_and_cooked/raw_and_cooked.py rename to examples/lsm303_raw_and_cooked.py From 57370e7bf391597016b2ee78f75b8b08cf58610e Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 10 May 2019 11:05:16 -0400 Subject: [PATCH 16/22] Updated docs to reflect this --- docs/examples.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/examples.rst b/docs/examples.rst index 110e053..3702c72 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -7,14 +7,14 @@ Ensure your device works with these simple tests. :caption: examples/lsm303_simpletest.py :linenos: -.. literalinclude:: ../examples/fast_accel/fast_accel.py - :caption: examples/fast_accel/fast_accel.py +.. literalinclude:: ../examples/lsm303_fast_accel.py + :caption: examples/lsm303_fast_accel.py :linenos: -.. literalinclude:: ../examples/fast_mag/fast_mag.py - :caption: examples/fast_mag/fast_mag.py +.. literalinclude:: ../examples/lsm303_fast_mag.py + :caption: examples/lsm303_fast_mag.py :linenos: -.. literalinclude:: ../examples/raw_and_cooked/raw_and_cooked.py - :caption: examples/raw_and_cooked/raw_and_cooked.py +.. literalinclude:: ../examples/lsm303_raw_and_cooked.py + :caption: examples/lsm303_raw_and_cooked.py :linenos: From ae28a46393923a404fb6640a304c9afe2439cc40 Mon Sep 17 00:00:00 2001 From: dherrada <33632497+dherrada@users.noreply.github.com> Date: Sat, 11 May 2019 13:29:39 -0400 Subject: [PATCH 17/22] Made travis stop searching for folders in the examples folder --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e6c13d2..710e476 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ install: script: - pylint adafruit_lsm303.py - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace - examples/*/*.py) + examples/*.py) - circuitpython-build-bundles --filename_prefix adafruit-circuitpython-lsm303 --library_location . - cd docs && sphinx-build -E -W -b html . _build/html && cd .. From 976c75fb89946e8605c9c81cd98e06db6a7135d9 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 21 Aug 2019 15:48:37 -0700 Subject: [PATCH 18/22] Remove stop kwarg and use write_then_readinto. See https://github.com/adafruit/circuitpython/issues/2082 for details. --- adafruit_lsm303.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/adafruit_lsm303.py b/adafruit_lsm303.py index 15acad1..ac2bfae 100644 --- a/adafruit_lsm303.py +++ b/adafruit_lsm303.py @@ -240,8 +240,8 @@ def mag_rate(self, value): def _read_u8(self, device, address): with device as i2c: self._BUFFER[0] = address & 0xFF - i2c.write(self._BUFFER, end=1, stop=False) - i2c.readinto(self._BUFFER, end=1) + i2c.write_then_readinto(self._BUFFER, self._BUFFER, + out_end=1, in_end=1) return self._BUFFER[0] def _write_u8(self, device, address, val): @@ -254,5 +254,4 @@ def _write_u8(self, device, address, val): def _read_bytes(device, address, count, buf): with device as i2c: buf[0] = address & 0xFF - i2c.write(buf, end=1, stop=False) - i2c.readinto(buf, end=count) + i2c.write_then_readinto(buf, buf, out_end=1, in_end=count) From a0899c84b50effa8de00989c74294738d62b3fe7 Mon Sep 17 00:00:00 2001 From: dherrada <33632497+dherrada@users.noreply.github.com> Date: Thu, 17 Oct 2019 18:48:01 -0400 Subject: [PATCH 19/22] Removed building locally section from README, replaced with documentation section --- README.rst | 49 +++---------------------------------------------- 1 file changed, 3 insertions(+), 46 deletions(-) diff --git a/README.rst b/README.rst index 47b5f63..f0a723b 100644 --- a/README.rst +++ b/README.rst @@ -60,50 +60,7 @@ Contributions are welcome! Please read our `Code of Conduct `_ before contributing to help this project stay welcoming. -Building locally -================ - -To build this library locally you'll need to install the -`circuitpython-build-tools `_ package. - -.. code-block:: shell - - python3 -m venv .env - source .env/bin/activate - pip install circuitpython-build-tools - -Once installed, make sure you are in the virtual environment: - -.. code-block:: shell - - source .env/bin/activate - -Then run the build: - -.. code-block:: shell - - circuitpython-build-bundles --filename_prefix adafruit-circuitpython-lsm303 --library_location . - - -Sphinx documentation ------------------------ - -Sphinx is used to build the documentation based on rST files and comments in the code. First, -install dependencies (feel free to reuse the virtual environment from above): - -.. code-block:: shell - - python3 -m venv .env - source .env/bin/activate - pip install Sphinx sphinx-rtd-theme - -Now, once you have the virtual environment activated: - -.. code-block:: shell - - cd docs - sphinx-build -E -W -b html . _build/html +Documentation +============= -This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to -view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to -locally verify it will pass. \ No newline at end of file +For information on building library documentation, please check out `this guide `_. From aeaf54078f8a6983e81998626c68740a298f32c8 Mon Sep 17 00:00:00 2001 From: dherrada <33632497+dherrada@users.noreply.github.com> Date: Fri, 18 Oct 2019 10:32:30 -0400 Subject: [PATCH 20/22] Added PyPi installation instructions --- README.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.rst b/README.rst index f0a723b..519c398 100644 --- a/README.rst +++ b/README.rst @@ -27,6 +27,31 @@ Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading `the Adafruit library and driver bundle `_. +Installing from PyPI +==================== + +On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from +PyPI `_. To install for current user: + +.. code-block:: shell + + pip3 install adafruit-circuitpython-lsm303 + +To install system-wide (this may be required in some cases): + +.. code-block:: shell + + sudo pip3 install adafruit-circuitpython-lsm303 + +To install in a virtual environment in your current project: + +.. code-block:: shell + + mkdir project-name && cd project-name + python3 -m venv .env + source .env/bin/activate + pip3 install adafruit-circuitpython-lsm303 + Usage Example ============= From 059a6d7bf1d9e8da6da7c65294cf5f35aa4303bd Mon Sep 17 00:00:00 2001 From: siddacious Date: Mon, 28 Oct 2019 14:12:58 -0700 Subject: [PATCH 21/22] Update README.rst --- README.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.rst b/README.rst index 519c398..9ab97d8 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,20 @@ +This library archived and no longer supported +============================================= +This library has been split into separate libararies for the magnetometer and accelerometer. The accelerometer code will be shared with another version of the LSM303 that uses the same accelerometer but not the magnetometer and this repo will be archived. + +The new, split libraries + +https://github.com/adafruit/Adafruit_CircuitPython_LSM303_Accel + +https://github.com/adafruit/Adafruit_CircuitPython_LSM303DLH_Mag + +The library for the new magnetometer + +https://github.com/adafruit/Adafruit_CircuitPython_LSM303AGR_Mag + +You can find usage information for the new libraries in the sensor's guide: + +https://learn.adafruit.com/lsm303-accelerometer-slash-compass-breakout/python-circuitpython Introduction ============ From 466dedfcdc107260a888af42babdb6868a0557d5 Mon Sep 17 00:00:00 2001 From: siddacious Date: Mon, 28 Oct 2019 14:14:32 -0700 Subject: [PATCH 22/22] Update README.rst --- README.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 9ab97d8..9a0349a 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,9 @@ -This library archived and no longer supported +This library is archived and no longer supported ============================================= This library has been split into separate libararies for the magnetometer and accelerometer. The accelerometer code will be shared with another version of the LSM303 that uses the same accelerometer but not the magnetometer and this repo will be archived. +This library will no longer be supported. Please us the new libraries + The new, split libraries https://github.com/adafruit/Adafruit_CircuitPython_LSM303_Accel