diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fff3aa9..1dad804 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: source actions-ci/install.sh - name: Pip install pylint, black, & Sphinx run: | - pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme + pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme - name: Library version run: git describe --dirty --always --tags - name: PyLint diff --git a/.pylintrc b/.pylintrc index 8e9553a..d8f0ee8 100644 --- a/.pylintrc +++ b/.pylintrc @@ -119,7 +119,7 @@ spelling-store-unknown-words=no [MISCELLANEOUS] # List of note tags to take in consideration, separated by a comma. -#notes=FIXME,XXX,TODO +# notes=FIXME,XXX,TODO notes=FIXME,XXX @@ -301,7 +301,7 @@ function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ # Good variable names which should always be accepted, separated by a comma # good-names=i,j,k,ex,Run,_ -good-names=r,g,b,i,j,k,n,ex,Run,_ +good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_ # Include a hint for the correct naming format with invalid-name include-naming-hint=no @@ -423,7 +423,7 @@ max-returns=6 max-statements=50 # Minimum number of public methods for a class (see R0903). -min-public-methods=2 +min-public-methods=1 [EXCEPTIONS] diff --git a/adafruit_lsm9ds1.py b/adafruit_lsm9ds1.py index 49bb683..975e358 100644 --- a/adafruit_lsm9ds1.py +++ b/adafruit_lsm9ds1.py @@ -50,6 +50,7 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS1.git" import time + try: import struct except ImportError: @@ -61,79 +62,79 @@ # Internal constants and register values: # pylint: disable=bad-whitespace -_LSM9DS1_ADDRESS_ACCELGYRO = const(0x6B) -_LSM9DS1_ADDRESS_MAG = const(0x1E) -_LSM9DS1_XG_ID = const(0b01101000) -_LSM9DS1_MAG_ID = const(0b00111101) -_LSM9DS1_ACCEL_MG_LSB_2G = 0.061 -_LSM9DS1_ACCEL_MG_LSB_4G = 0.122 -_LSM9DS1_ACCEL_MG_LSB_8G = 0.244 -_LSM9DS1_ACCEL_MG_LSB_16G = 0.732 -_LSM9DS1_MAG_MGAUSS_4GAUSS = 0.14 -_LSM9DS1_MAG_MGAUSS_8GAUSS = 0.29 -_LSM9DS1_MAG_MGAUSS_12GAUSS = 0.43 -_LSM9DS1_MAG_MGAUSS_16GAUSS = 0.58 -_LSM9DS1_GYRO_DPS_DIGIT_245DPS = 0.00875 -_LSM9DS1_GYRO_DPS_DIGIT_500DPS = 0.01750 -_LSM9DS1_GYRO_DPS_DIGIT_2000DPS = 0.07000 -_LSM9DS1_TEMP_LSB_DEGREE_CELSIUS = 8 # 1°C = 8, 25° = 200, etc. -_LSM9DS1_REGISTER_WHO_AM_I_XG = const(0x0F) -_LSM9DS1_REGISTER_CTRL_REG1_G = const(0x10) -_LSM9DS1_REGISTER_CTRL_REG2_G = const(0x11) -_LSM9DS1_REGISTER_CTRL_REG3_G = const(0x12) -_LSM9DS1_REGISTER_TEMP_OUT_L = const(0x15) -_LSM9DS1_REGISTER_TEMP_OUT_H = const(0x16) -_LSM9DS1_REGISTER_STATUS_REG = const(0x17) -_LSM9DS1_REGISTER_OUT_X_L_G = const(0x18) -_LSM9DS1_REGISTER_OUT_X_H_G = const(0x19) -_LSM9DS1_REGISTER_OUT_Y_L_G = const(0x1A) -_LSM9DS1_REGISTER_OUT_Y_H_G = const(0x1B) -_LSM9DS1_REGISTER_OUT_Z_L_G = const(0x1C) -_LSM9DS1_REGISTER_OUT_Z_H_G = const(0x1D) -_LSM9DS1_REGISTER_CTRL_REG4 = const(0x1E) -_LSM9DS1_REGISTER_CTRL_REG5_XL = const(0x1F) -_LSM9DS1_REGISTER_CTRL_REG6_XL = const(0x20) -_LSM9DS1_REGISTER_CTRL_REG7_XL = const(0x21) -_LSM9DS1_REGISTER_CTRL_REG8 = const(0x22) -_LSM9DS1_REGISTER_CTRL_REG9 = const(0x23) -_LSM9DS1_REGISTER_CTRL_REG10 = const(0x24) -_LSM9DS1_REGISTER_OUT_X_L_XL = const(0x28) -_LSM9DS1_REGISTER_OUT_X_H_XL = const(0x29) -_LSM9DS1_REGISTER_OUT_Y_L_XL = const(0x2A) -_LSM9DS1_REGISTER_OUT_Y_H_XL = const(0x2B) -_LSM9DS1_REGISTER_OUT_Z_L_XL = const(0x2C) -_LSM9DS1_REGISTER_OUT_Z_H_XL = const(0x2D) -_LSM9DS1_REGISTER_WHO_AM_I_M = const(0x0F) -_LSM9DS1_REGISTER_CTRL_REG1_M = const(0x20) -_LSM9DS1_REGISTER_CTRL_REG2_M = const(0x21) -_LSM9DS1_REGISTER_CTRL_REG3_M = const(0x22) -_LSM9DS1_REGISTER_CTRL_REG4_M = const(0x23) -_LSM9DS1_REGISTER_CTRL_REG5_M = const(0x24) -_LSM9DS1_REGISTER_STATUS_REG_M = const(0x27) -_LSM9DS1_REGISTER_OUT_X_L_M = const(0x28) -_LSM9DS1_REGISTER_OUT_X_H_M = const(0x29) -_LSM9DS1_REGISTER_OUT_Y_L_M = const(0x2A) -_LSM9DS1_REGISTER_OUT_Y_H_M = const(0x2B) -_LSM9DS1_REGISTER_OUT_Z_L_M = const(0x2C) -_LSM9DS1_REGISTER_OUT_Z_H_M = const(0x2D) -_LSM9DS1_REGISTER_CFG_M = const(0x30) -_LSM9DS1_REGISTER_INT_SRC_M = const(0x31) -_MAGTYPE = True -_XGTYPE = False -_SENSORS_GRAVITY_STANDARD = 9.80665 +_LSM9DS1_ADDRESS_ACCELGYRO = const(0x6B) +_LSM9DS1_ADDRESS_MAG = const(0x1E) +_LSM9DS1_XG_ID = const(0b01101000) +_LSM9DS1_MAG_ID = const(0b00111101) +_LSM9DS1_ACCEL_MG_LSB_2G = 0.061 +_LSM9DS1_ACCEL_MG_LSB_4G = 0.122 +_LSM9DS1_ACCEL_MG_LSB_8G = 0.244 +_LSM9DS1_ACCEL_MG_LSB_16G = 0.732 +_LSM9DS1_MAG_MGAUSS_4GAUSS = 0.14 +_LSM9DS1_MAG_MGAUSS_8GAUSS = 0.29 +_LSM9DS1_MAG_MGAUSS_12GAUSS = 0.43 +_LSM9DS1_MAG_MGAUSS_16GAUSS = 0.58 +_LSM9DS1_GYRO_DPS_DIGIT_245DPS = 0.00875 +_LSM9DS1_GYRO_DPS_DIGIT_500DPS = 0.01750 +_LSM9DS1_GYRO_DPS_DIGIT_2000DPS = 0.07000 +_LSM9DS1_TEMP_LSB_DEGREE_CELSIUS = 8 # 1°C = 8, 25° = 200, etc. +_LSM9DS1_REGISTER_WHO_AM_I_XG = const(0x0F) +_LSM9DS1_REGISTER_CTRL_REG1_G = const(0x10) +_LSM9DS1_REGISTER_CTRL_REG2_G = const(0x11) +_LSM9DS1_REGISTER_CTRL_REG3_G = const(0x12) +_LSM9DS1_REGISTER_TEMP_OUT_L = const(0x15) +_LSM9DS1_REGISTER_TEMP_OUT_H = const(0x16) +_LSM9DS1_REGISTER_STATUS_REG = const(0x17) +_LSM9DS1_REGISTER_OUT_X_L_G = const(0x18) +_LSM9DS1_REGISTER_OUT_X_H_G = const(0x19) +_LSM9DS1_REGISTER_OUT_Y_L_G = const(0x1A) +_LSM9DS1_REGISTER_OUT_Y_H_G = const(0x1B) +_LSM9DS1_REGISTER_OUT_Z_L_G = const(0x1C) +_LSM9DS1_REGISTER_OUT_Z_H_G = const(0x1D) +_LSM9DS1_REGISTER_CTRL_REG4 = const(0x1E) +_LSM9DS1_REGISTER_CTRL_REG5_XL = const(0x1F) +_LSM9DS1_REGISTER_CTRL_REG6_XL = const(0x20) +_LSM9DS1_REGISTER_CTRL_REG7_XL = const(0x21) +_LSM9DS1_REGISTER_CTRL_REG8 = const(0x22) +_LSM9DS1_REGISTER_CTRL_REG9 = const(0x23) +_LSM9DS1_REGISTER_CTRL_REG10 = const(0x24) +_LSM9DS1_REGISTER_OUT_X_L_XL = const(0x28) +_LSM9DS1_REGISTER_OUT_X_H_XL = const(0x29) +_LSM9DS1_REGISTER_OUT_Y_L_XL = const(0x2A) +_LSM9DS1_REGISTER_OUT_Y_H_XL = const(0x2B) +_LSM9DS1_REGISTER_OUT_Z_L_XL = const(0x2C) +_LSM9DS1_REGISTER_OUT_Z_H_XL = const(0x2D) +_LSM9DS1_REGISTER_WHO_AM_I_M = const(0x0F) +_LSM9DS1_REGISTER_CTRL_REG1_M = const(0x20) +_LSM9DS1_REGISTER_CTRL_REG2_M = const(0x21) +_LSM9DS1_REGISTER_CTRL_REG3_M = const(0x22) +_LSM9DS1_REGISTER_CTRL_REG4_M = const(0x23) +_LSM9DS1_REGISTER_CTRL_REG5_M = const(0x24) +_LSM9DS1_REGISTER_STATUS_REG_M = const(0x27) +_LSM9DS1_REGISTER_OUT_X_L_M = const(0x28) +_LSM9DS1_REGISTER_OUT_X_H_M = const(0x29) +_LSM9DS1_REGISTER_OUT_Y_L_M = const(0x2A) +_LSM9DS1_REGISTER_OUT_Y_H_M = const(0x2B) +_LSM9DS1_REGISTER_OUT_Z_L_M = const(0x2C) +_LSM9DS1_REGISTER_OUT_Z_H_M = const(0x2D) +_LSM9DS1_REGISTER_CFG_M = const(0x30) +_LSM9DS1_REGISTER_INT_SRC_M = const(0x31) +_MAGTYPE = True +_XGTYPE = False +_SENSORS_GRAVITY_STANDARD = 9.80665 # User facing constants/module globals. -ACCELRANGE_2G = (0b00 << 3) -ACCELRANGE_16G = (0b01 << 3) -ACCELRANGE_4G = (0b10 << 3) -ACCELRANGE_8G = (0b11 << 3) -MAGGAIN_4GAUSS = (0b00 << 5) # +/- 4 gauss -MAGGAIN_8GAUSS = (0b01 << 5) # +/- 8 gauss -MAGGAIN_12GAUSS = (0b10 << 5) # +/- 12 gauss -MAGGAIN_16GAUSS = (0b11 << 5) # +/- 16 gauss -GYROSCALE_245DPS = (0b00 << 3) # +/- 245 degrees/s rotation -GYROSCALE_500DPS = (0b01 << 3) # +/- 500 degrees/s rotation -GYROSCALE_2000DPS = (0b11 << 3) # +/- 2000 degrees/s rotation +ACCELRANGE_2G = 0b00 << 3 +ACCELRANGE_16G = 0b01 << 3 +ACCELRANGE_4G = 0b10 << 3 +ACCELRANGE_8G = 0b11 << 3 +MAGGAIN_4GAUSS = 0b00 << 5 # +/- 4 gauss +MAGGAIN_8GAUSS = 0b01 << 5 # +/- 8 gauss +MAGGAIN_12GAUSS = 0b10 << 5 # +/- 12 gauss +MAGGAIN_16GAUSS = 0b11 << 5 # +/- 16 gauss +GYROSCALE_245DPS = 0b00 << 3 # +/- 245 degrees/s rotation +GYROSCALE_500DPS = 0b01 << 3 # +/- 500 degrees/s rotation +GYROSCALE_2000DPS = 0b11 << 3 # +/- 2000 degrees/s rotation # pylint: enable=bad-whitespace @@ -160,11 +161,13 @@ def __init__(self): self._write_u8(_MAGTYPE, _LSM9DS1_REGISTER_CTRL_REG2_M, 0x0C) time.sleep(0.01) # Check ID registers. - if self._read_u8(_XGTYPE, _LSM9DS1_REGISTER_WHO_AM_I_XG) != _LSM9DS1_XG_ID or \ - self._read_u8(_MAGTYPE, _LSM9DS1_REGISTER_WHO_AM_I_M) != _LSM9DS1_MAG_ID: - raise RuntimeError('Could not find LSM9DS1, check wiring!') + if ( + self._read_u8(_XGTYPE, _LSM9DS1_REGISTER_WHO_AM_I_XG) != _LSM9DS1_XG_ID + or self._read_u8(_MAGTYPE, _LSM9DS1_REGISTER_WHO_AM_I_M) != _LSM9DS1_MAG_ID + ): + raise RuntimeError("Could not find LSM9DS1, check wiring!") # enable gyro continuous - self._write_u8(_XGTYPE, _LSM9DS1_REGISTER_CTRL_REG1_G, 0xC0) # on XYZ + self._write_u8(_XGTYPE, _LSM9DS1_REGISTER_CTRL_REG1_G, 0xC0) # on XYZ # Enable the accelerometer continous self._write_u8(_XGTYPE, _LSM9DS1_REGISTER_CTRL_REG5_XL, 0x38) self._write_u8(_XGTYPE, _LSM9DS1_REGISTER_CTRL_REG6_XL, 0xC0) @@ -191,8 +194,7 @@ def accel_range(self): @accel_range.setter def accel_range(self, val): - assert val in (ACCELRANGE_2G, ACCELRANGE_4G, ACCELRANGE_8G, - ACCELRANGE_16G) + assert val in (ACCELRANGE_2G, ACCELRANGE_4G, ACCELRANGE_8G, ACCELRANGE_16G) reg = self._read_u8(_XGTYPE, _LSM9DS1_REGISTER_CTRL_REG6_XL) reg = (reg & ~(0b00011000)) & 0xFF reg |= val @@ -219,8 +221,7 @@ def mag_gain(self): @mag_gain.setter def mag_gain(self, val): - assert val in (MAGGAIN_4GAUSS, MAGGAIN_8GAUSS, MAGGAIN_12GAUSS, - MAGGAIN_16GAUSS) + assert val in (MAGGAIN_4GAUSS, MAGGAIN_8GAUSS, MAGGAIN_12GAUSS, MAGGAIN_16GAUSS) reg = self._read_u8(_MAGTYPE, _LSM9DS1_REGISTER_CTRL_REG2_M) reg = (reg & ~(0b01100000)) & 0xFF reg |= val @@ -265,9 +266,8 @@ def read_accel_raw(self): accelerometer property! """ # Read the accelerometer - self._read_bytes(_XGTYPE, 0x80 | _LSM9DS1_REGISTER_OUT_X_L_XL, 6, - self._BUFFER) - raw_x, raw_y, raw_z = struct.unpack_from('> 4 return _twos_comp(temp, 12) @@ -337,7 +335,7 @@ def temperature(self): # See discussion from: # https://github.com/kriswiner/LSM9DS1/issues/3 temp = self.read_temp_raw() - temp = 27.5 + temp/16 + temp = 27.5 + temp / 16 return temp def _read_u8(self, sensor_type, address): @@ -379,16 +377,23 @@ class LSM9DS1_I2C(LSM9DS1): Defaults to ``0x6B``. """ - def __init__(self, i2c, mag_address=_LSM9DS1_ADDRESS_MAG, - xg_address=_LSM9DS1_ADDRESS_ACCELGYRO): - if mag_address in (0x1c, 0x1e) and xg_address in (0x6a, 0x6b): + + def __init__( + self, + i2c, + mag_address=_LSM9DS1_ADDRESS_MAG, + xg_address=_LSM9DS1_ADDRESS_ACCELGYRO, + ): + if mag_address in (0x1C, 0x1E) and xg_address in (0x6A, 0x6B): self._mag_device = i2c_device.I2CDevice(i2c, mag_address) self._xg_device = i2c_device.I2CDevice(i2c, xg_address) super().__init__() else: - raise ValueError('address parmeters are incorrect. Read the docs at ' - 'circuitpython.rtfd.io/projects/lsm9ds1/en/latest' - '/api.html#adafruit_lsm9ds1.LSM9DS1_I2C') + raise ValueError( + "address parmeters are incorrect. Read the docs at " + "circuitpython.rtfd.io/projects/lsm9ds1/en/latest" + "/api.html#adafruit_lsm9ds1.LSM9DS1_I2C" + ) def _read_u8(self, sensor_type, address): if sensor_type == _MAGTYPE: @@ -397,7 +402,9 @@ def _read_u8(self, sensor_type, address): device = self._xg_device with device as i2c: self._BUFFER[0] = address & 0xFF - i2c.write_then_readinto(self._BUFFER, self._BUFFER, out_end=1, in_start=1, in_end=2) + i2c.write_then_readinto( + self._BUFFER, self._BUFFER, out_end=1, in_start=1, in_end=2 + ) return self._BUFFER[1] def _read_bytes(self, sensor_type, address, count, buf): @@ -435,10 +442,15 @@ class LSM9DS1_SPI(LSM9DS1): LSM9DS1's CSAG (Chip Select Accelerometer/Gyroscope) pin. """ + # pylint: disable=no-member def __init__(self, spi, xgcs, mcs): - self._mag_device = spi_device.SPIDevice(spi, mcs, baudrate=200000, phase=1, polarity=1) - self._xg_device = spi_device.SPIDevice(spi, xgcs, baudrate=200000, phase=1, polarity=1) + self._mag_device = spi_device.SPIDevice( + spi, mcs, baudrate=200000, phase=1, polarity=1 + ) + self._xg_device = spi_device.SPIDevice( + spi, xgcs, baudrate=200000, phase=1, polarity=1 + ) super().__init__() def _read_u8(self, sensor_type, address): diff --git a/docs/conf.py b/docs/conf.py index 41620f7..f2d96ae 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,8 @@ import os import sys -sys.path.insert(0, os.path.abspath('..')) + +sys.path.insert(0, os.path.abspath("..")) # -- General configuration ------------------------------------------------ @@ -10,9 +11,9 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.viewcode', + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.viewcode", ] # Uncomment the below if you use native CircuitPython modules such as @@ -20,29 +21,36 @@ # autodoc module docs will fail to generate with a warning. # autodoc_mock_imports = ["adafruit_bus_device", "micropython"] -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)} +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), +} # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'Adafruit LSM9DS1 Library' -copyright = u'2017 Tony DiCola' -author = u'Tony DiCola' +project = u"Adafruit LSM9DS1 Library" +copyright = u"2017 Tony DiCola" +author = u"Tony DiCola" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'1.0' +version = u"1.0" # The full version, including alpha/beta/rc tags. -release = u'1.0' +release = u"1.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -54,7 +62,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"] # The reST default role (used for this markup: `text`) to use for all # documents. @@ -66,7 +74,7 @@ add_function_parentheses = True # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False @@ -80,59 +88,62 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -on_rtd = os.environ.get('READTHEDOCS', None) == 'True' +on_rtd = os.environ.get("READTHEDOCS", None) == "True" if not on_rtd: # only import and set the theme if we're building docs locally try: import sphinx_rtd_theme - html_theme = 'sphinx_rtd_theme' - html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.'] + + html_theme = "sphinx_rtd_theme" + html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] except: - html_theme = 'default' - html_theme_path = ['.'] + html_theme = "default" + html_theme_path = ["."] else: - html_theme_path = ['.'] + html_theme_path = ["."] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # The name of an image file (relative to this directory) to use as a favicon of # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # -html_favicon = '_static/favicon.ico' +html_favicon = "_static/favicon.ico" # Output file base name for HTML help builder. -htmlhelp_basename = 'AdafruitLSM9DS1Librarydoc' +htmlhelp_basename = "AdafruitLSM9DS1Librarydoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'AdafruitLSM9DS1Library.tex', u'Adafruit LSM9DS1 Library Documentation', - author, 'manual'), + ( + master_doc, + "AdafruitLSM9DS1Library.tex", + u"Adafruit LSM9DS1 Library Documentation", + author, + "manual", + ), ] # -- Options for manual page output --------------------------------------- @@ -140,8 +151,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'adafruitLSM9DS1library', u'Adafruit LSM9DS1 Library Documentation', - [author], 1) + ( + master_doc, + "adafruitLSM9DS1library", + u"Adafruit LSM9DS1 Library Documentation", + [author], + 1, + ) ] # -- Options for Texinfo output ------------------------------------------- @@ -150,7 +166,13 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'AdafruitLSM9DS1Library', u'Adafruit LSM9DS1 Library Documentation', - author, 'AdafruitLSM9DS1Library', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "AdafruitLSM9DS1Library", + u"Adafruit LSM9DS1 Library Documentation", + author, + "AdafruitLSM9DS1Library", + "One line description of project.", + "Miscellaneous", + ), ] diff --git a/examples/lsm9ds1_simpletest.py b/examples/lsm9ds1_simpletest.py index 9e42169..9f8ad0d 100644 --- a/examples/lsm9ds1_simpletest.py +++ b/examples/lsm9ds1_simpletest.py @@ -9,7 +9,7 @@ i2c = busio.I2C(board.SCL, board.SDA) sensor = adafruit_lsm9ds1.LSM9DS1_I2C(i2c) -#SPI connection: +# SPI connection: # from digitalio import DigitalInOut, Direction # spi = busio.SPI(board.SCK, board.MOSI, board.MISO) # csag = DigitalInOut(board.D5) @@ -29,9 +29,19 @@ gyro_x, gyro_y, gyro_z = sensor.gyro temp = sensor.temperature # Print values. - print('Acceleration (m/s^2): ({0:0.3f},{1:0.3f},{2:0.3f})'.format(accel_x, accel_y, accel_z)) - print('Magnetometer (gauss): ({0:0.3f},{1:0.3f},{2:0.3f})'.format(mag_x, mag_y, mag_z)) - print('Gyroscope (degrees/sec): ({0:0.3f},{1:0.3f},{2:0.3f})'.format(gyro_x, gyro_y, gyro_z)) - print('Temperature: {0:0.3f}C'.format(temp)) + print( + "Acceleration (m/s^2): ({0:0.3f},{1:0.3f},{2:0.3f})".format( + accel_x, accel_y, accel_z + ) + ) + print( + "Magnetometer (gauss): ({0:0.3f},{1:0.3f},{2:0.3f})".format(mag_x, mag_y, mag_z) + ) + print( + "Gyroscope (degrees/sec): ({0:0.3f},{1:0.3f},{2:0.3f})".format( + gyro_x, gyro_y, gyro_z + ) + ) + print("Temperature: {0:0.3f}C".format(temp)) # Delay for a second. time.sleep(1.0) diff --git a/setup.py b/setup.py index d387b20..75f2616 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ # Always prefer setuptools over distutils from setuptools import setup, find_packages + # To use a consistent encoding from codecs import open from os import path @@ -14,48 +15,39 @@ 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: +with open(path.join(here, "README.rst"), encoding="utf-8") as f: long_description = f.read() setup( - name='adafruit-circuitpython-lsm9ds1', - + name="adafruit-circuitpython-lsm9ds1", use_scm_version=True, - setup_requires=['setuptools_scm'], - - description='CircuitPython library for LSM9DS1 accelerometer, magnetometer, gyroscope.', + setup_requires=["setuptools_scm"], + description="CircuitPython library for LSM9DS1 accelerometer, magnetometer, gyroscope.", long_description=long_description, - long_description_content_type='text/x-rst', - + long_description_content_type="text/x-rst", # The project's main homepage. - url='https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS1', - + url="https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS1", # Author details - author='Adafruit Industries', - author_email='circuitpython@adafruit.com', - - install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice'], - + author="Adafruit Industries", + author_email="circuitpython@adafruit.com", + install_requires=["Adafruit-Blinka", "adafruit-circuitpython-busdevice"], # Choose your license - license='MIT', - + 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', + "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 accelerometer magnetometer gyroscope lsm9ds1' - 'breakout hardware micropython circuitpython', - + keywords="adafruit accelerometer magnetometer gyroscope lsm9ds1" + "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_lsm9ds1'], + py_modules=["adafruit_lsm9ds1"], )