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_lsm9ds0.py b/adafruit_lsm9ds0.py index ad27229..6deaf99 100644 --- a/adafruit_lsm9ds0.py +++ b/adafruit_lsm9ds0.py @@ -64,73 +64,73 @@ # Internal constants and register values: # pylint: disable=bad-whitespace -_LSM9DS0_ADDRESS_ACCELMAG = const(0x1D) # 3B >> 1 = 7bit default -_LSM9DS0_ADDRESS_GYRO = const(0x6B) # D6 >> 1 = 7bit default -_LSM9DS0_XM_ID = const(0b01001001) -_LSM9DS0_G_ID = const(0b11010100) -_LSM9DS0_ACCEL_MG_LSB_2G = 0.061 -_LSM9DS0_ACCEL_MG_LSB_4G = 0.122 -_LSM9DS0_ACCEL_MG_LSB_6G = 0.183 -_LSM9DS0_ACCEL_MG_LSB_8G = 0.244 -_LSM9DS0_ACCEL_MG_LSB_16G = 0.732 # Is this right? Was expecting 0.488 -_LSM9DS0_MAG_MGAUSS_2GAUSS = 0.08 -_LSM9DS0_MAG_MGAUSS_4GAUSS = 0.16 -_LSM9DS0_MAG_MGAUSS_8GAUSS = 0.32 -_LSM9DS0_MAG_MGAUSS_12GAUSS = 0.48 -_LSM9DS0_GYRO_DPS_DIGIT_245DPS = 0.00875 -_LSM9DS0_GYRO_DPS_DIGIT_500DPS = 0.01750 -_LSM9DS0_GYRO_DPS_DIGIT_2000DPS = 0.07000 -_LSM9DS0_TEMP_LSB_DEGREE_CELSIUS = 8 # 1°C = 8, 25° = 200, etc. -_LSM9DS0_REGISTER_WHO_AM_I_G = const(0x0F) -_LSM9DS0_REGISTER_CTRL_REG1_G = const(0x20) -_LSM9DS0_REGISTER_CTRL_REG3_G = const(0x22) -_LSM9DS0_REGISTER_CTRL_REG4_G = const(0x23) -_LSM9DS0_REGISTER_OUT_X_L_G = const(0x28) -_LSM9DS0_REGISTER_OUT_X_H_G = const(0x29) -_LSM9DS0_REGISTER_OUT_Y_L_G = const(0x2A) -_LSM9DS0_REGISTER_OUT_Y_H_G = const(0x2B) -_LSM9DS0_REGISTER_OUT_Z_L_G = const(0x2C) -_LSM9DS0_REGISTER_OUT_Z_H_G = const(0x2D) -_LSM9DS0_REGISTER_TEMP_OUT_L_XM = const(0x05) -_LSM9DS0_REGISTER_TEMP_OUT_H_XM = const(0x06) -_LSM9DS0_REGISTER_STATUS_REG_M = const(0x07) -_LSM9DS0_REGISTER_OUT_X_L_M = const(0x08) -_LSM9DS0_REGISTER_OUT_X_H_M = const(0x09) -_LSM9DS0_REGISTER_OUT_Y_L_M = const(0x0A) -_LSM9DS0_REGISTER_OUT_Y_H_M = const(0x0B) -_LSM9DS0_REGISTER_OUT_Z_L_M = const(0x0C) -_LSM9DS0_REGISTER_OUT_Z_H_M = const(0x0D) -_LSM9DS0_REGISTER_WHO_AM_I_XM = const(0x0F) -_LSM9DS0_REGISTER_INT_CTRL_REG_M = const(0x12) -_LSM9DS0_REGISTER_INT_SRC_REG_M = const(0x13) -_LSM9DS0_REGISTER_CTRL_REG1_XM = const(0x20) -_LSM9DS0_REGISTER_CTRL_REG2_XM = const(0x21) -_LSM9DS0_REGISTER_CTRL_REG5_XM = const(0x24) -_LSM9DS0_REGISTER_CTRL_REG6_XM = const(0x25) -_LSM9DS0_REGISTER_CTRL_REG7_XM = const(0x26) -_LSM9DS0_REGISTER_OUT_X_L_A = const(0x28) -_LSM9DS0_REGISTER_OUT_X_H_A = const(0x29) -_LSM9DS0_REGISTER_OUT_Y_L_A = const(0x2A) -_LSM9DS0_REGISTER_OUT_Y_H_A = const(0x2B) -_LSM9DS0_REGISTER_OUT_Z_L_A = const(0x2C) -_LSM9DS0_REGISTER_OUT_Z_H_A = const(0x2D) -_GYROTYPE = True -_XMTYPE = False -_SENSORS_GRAVITY_STANDARD = 9.80665 +_LSM9DS0_ADDRESS_ACCELMAG = const(0x1D) # 3B >> 1 = 7bit default +_LSM9DS0_ADDRESS_GYRO = const(0x6B) # D6 >> 1 = 7bit default +_LSM9DS0_XM_ID = const(0b01001001) +_LSM9DS0_G_ID = const(0b11010100) +_LSM9DS0_ACCEL_MG_LSB_2G = 0.061 +_LSM9DS0_ACCEL_MG_LSB_4G = 0.122 +_LSM9DS0_ACCEL_MG_LSB_6G = 0.183 +_LSM9DS0_ACCEL_MG_LSB_8G = 0.244 +_LSM9DS0_ACCEL_MG_LSB_16G = 0.732 # Is this right? Was expecting 0.488 +_LSM9DS0_MAG_MGAUSS_2GAUSS = 0.08 +_LSM9DS0_MAG_MGAUSS_4GAUSS = 0.16 +_LSM9DS0_MAG_MGAUSS_8GAUSS = 0.32 +_LSM9DS0_MAG_MGAUSS_12GAUSS = 0.48 +_LSM9DS0_GYRO_DPS_DIGIT_245DPS = 0.00875 +_LSM9DS0_GYRO_DPS_DIGIT_500DPS = 0.01750 +_LSM9DS0_GYRO_DPS_DIGIT_2000DPS = 0.07000 +_LSM9DS0_TEMP_LSB_DEGREE_CELSIUS = 8 # 1°C = 8, 25° = 200, etc. +_LSM9DS0_REGISTER_WHO_AM_I_G = const(0x0F) +_LSM9DS0_REGISTER_CTRL_REG1_G = const(0x20) +_LSM9DS0_REGISTER_CTRL_REG3_G = const(0x22) +_LSM9DS0_REGISTER_CTRL_REG4_G = const(0x23) +_LSM9DS0_REGISTER_OUT_X_L_G = const(0x28) +_LSM9DS0_REGISTER_OUT_X_H_G = const(0x29) +_LSM9DS0_REGISTER_OUT_Y_L_G = const(0x2A) +_LSM9DS0_REGISTER_OUT_Y_H_G = const(0x2B) +_LSM9DS0_REGISTER_OUT_Z_L_G = const(0x2C) +_LSM9DS0_REGISTER_OUT_Z_H_G = const(0x2D) +_LSM9DS0_REGISTER_TEMP_OUT_L_XM = const(0x05) +_LSM9DS0_REGISTER_TEMP_OUT_H_XM = const(0x06) +_LSM9DS0_REGISTER_STATUS_REG_M = const(0x07) +_LSM9DS0_REGISTER_OUT_X_L_M = const(0x08) +_LSM9DS0_REGISTER_OUT_X_H_M = const(0x09) +_LSM9DS0_REGISTER_OUT_Y_L_M = const(0x0A) +_LSM9DS0_REGISTER_OUT_Y_H_M = const(0x0B) +_LSM9DS0_REGISTER_OUT_Z_L_M = const(0x0C) +_LSM9DS0_REGISTER_OUT_Z_H_M = const(0x0D) +_LSM9DS0_REGISTER_WHO_AM_I_XM = const(0x0F) +_LSM9DS0_REGISTER_INT_CTRL_REG_M = const(0x12) +_LSM9DS0_REGISTER_INT_SRC_REG_M = const(0x13) +_LSM9DS0_REGISTER_CTRL_REG1_XM = const(0x20) +_LSM9DS0_REGISTER_CTRL_REG2_XM = const(0x21) +_LSM9DS0_REGISTER_CTRL_REG5_XM = const(0x24) +_LSM9DS0_REGISTER_CTRL_REG6_XM = const(0x25) +_LSM9DS0_REGISTER_CTRL_REG7_XM = const(0x26) +_LSM9DS0_REGISTER_OUT_X_L_A = const(0x28) +_LSM9DS0_REGISTER_OUT_X_H_A = const(0x29) +_LSM9DS0_REGISTER_OUT_Y_L_A = const(0x2A) +_LSM9DS0_REGISTER_OUT_Y_H_A = const(0x2B) +_LSM9DS0_REGISTER_OUT_Z_L_A = const(0x2C) +_LSM9DS0_REGISTER_OUT_Z_H_A = const(0x2D) +_GYROTYPE = True +_XMTYPE = False +_SENSORS_GRAVITY_STANDARD = 9.80665 # User facing constants/module globals. -ACCELRANGE_2G = (0b000 << 3) -ACCELRANGE_4G = (0b001 << 3) -ACCELRANGE_6G = (0b010 << 3) -ACCELRANGE_8G = (0b011 << 3) -ACCELRANGE_16G = (0b100 << 3) -MAGGAIN_2GAUSS = (0b00 << 5) # +/- 2 gauss -MAGGAIN_4GAUSS = (0b01 << 5) # +/- 4 gauss -MAGGAIN_8GAUSS = (0b10 << 5) # +/- 8 gauss -MAGGAIN_12GAUSS = (0b11 << 5) # +/- 12 gauss -GYROSCALE_245DPS = (0b00 << 4) # +/- 245 degrees per second rotation -GYROSCALE_500DPS = (0b01 << 4) # +/- 500 degrees per second rotation -GYROSCALE_2000DPS = (0b10 << 4) # +/- 2000 degrees per second rotation +ACCELRANGE_2G = 0b000 << 3 +ACCELRANGE_4G = 0b001 << 3 +ACCELRANGE_6G = 0b010 << 3 +ACCELRANGE_8G = 0b011 << 3 +ACCELRANGE_16G = 0b100 << 3 +MAGGAIN_2GAUSS = 0b00 << 5 # +/- 2 gauss +MAGGAIN_4GAUSS = 0b01 << 5 # +/- 4 gauss +MAGGAIN_8GAUSS = 0b10 << 5 # +/- 8 gauss +MAGGAIN_12GAUSS = 0b11 << 5 # +/- 12 gauss +GYROSCALE_245DPS = 0b00 << 4 # +/- 245 degrees per second rotation +GYROSCALE_500DPS = 0b01 << 4 # +/- 500 degrees per second rotation +GYROSCALE_2000DPS = 0b10 << 4 # +/- 2000 degrees per second rotation # pylint: enable=bad-whitespace @@ -144,6 +144,7 @@ def _twos_comp(val, bits): class LSM9DS0: """Driver for the LSM9DS0 accelerometer, magnetometer, gyroscope.""" + # Class-level buffer for reading and writing data with the sensor. # This reduces memory allocations but means the code is not re-entrant or # thread safe! @@ -151,9 +152,11 @@ class LSM9DS0: def __init__(self): # Check ID registers. - if self._read_u8(_XMTYPE, _LSM9DS0_REGISTER_WHO_AM_I_XM) != _LSM9DS0_XM_ID or \ - self._read_u8(_GYROTYPE, _LSM9DS0_REGISTER_WHO_AM_I_G) != _LSM9DS0_G_ID: - raise RuntimeError('Could not find LSM9DS0, check wiring!') + if ( + self._read_u8(_XMTYPE, _LSM9DS0_REGISTER_WHO_AM_I_XM) != _LSM9DS0_XM_ID + or self._read_u8(_GYROTYPE, _LSM9DS0_REGISTER_WHO_AM_I_G) != _LSM9DS0_G_ID + ): + raise RuntimeError("Could not find LSM9DS0, check wiring!") # Enable the accelerometer continous self._write_u8(_XMTYPE, _LSM9DS0_REGISTER_CTRL_REG1_XM, 0x67) self._write_u8(_XMTYPE, _LSM9DS0_REGISTER_CTRL_REG5_XM, 0b11110000) @@ -163,7 +166,7 @@ def __init__(self): self._write_u8(_GYROTYPE, _LSM9DS0_REGISTER_CTRL_REG1_G, 0x0F) # enable the temperature sensor (output rate same as the mag sensor) temp_reg = self._read_u8(_XMTYPE, _LSM9DS0_REGISTER_CTRL_REG5_XM) - self._write_u8(_XMTYPE, _LSM9DS0_REGISTER_CTRL_REG5_XM, temp_reg | (1<<7)) + self._write_u8(_XMTYPE, _LSM9DS0_REGISTER_CTRL_REG5_XM, temp_reg | (1 << 7)) # Set default ranges for the various sensors self._accel_mg_lsb = None self._mag_mgauss_lsb = None @@ -186,8 +189,13 @@ def accel_range(self): @accel_range.setter def accel_range(self, val): - assert val in (ACCELRANGE_2G, ACCELRANGE_4G, ACCELRANGE_6G, - ACCELRANGE_8G, ACCELRANGE_16G) + assert val in ( + ACCELRANGE_2G, + ACCELRANGE_4G, + ACCELRANGE_6G, + ACCELRANGE_8G, + ACCELRANGE_16G, + ) reg = self._read_u8(_XMTYPE, _LSM9DS0_REGISTER_CTRL_REG2_XM) reg = (reg & ~(0b00111000)) & 0xFF reg |= val @@ -216,8 +224,7 @@ def mag_gain(self): @mag_gain.setter def mag_gain(self, val): - assert val in (MAGGAIN_2GAUSS, MAGGAIN_4GAUSS, MAGGAIN_8GAUSS, - MAGGAIN_12GAUSS) + assert val in (MAGGAIN_2GAUSS, MAGGAIN_4GAUSS, MAGGAIN_8GAUSS, MAGGAIN_12GAUSS) reg = self._read_u8(_XMTYPE, _LSM9DS0_REGISTER_CTRL_REG6_XM) reg = (reg & ~(0b01100000)) & 0xFF reg |= val @@ -262,9 +269,8 @@ def read_accel_raw(self): accelerometer property! """ # Read the accelerometer - self._read_bytes(_XMTYPE, 0x80 | _LSM9DS0_REGISTER_OUT_X_L_A, 6, - self._BUFFER) - raw_x, raw_y, raw_z = struct.unpack_from('> 4 return _twos_comp(temp, 12) @@ -331,7 +338,7 @@ def temperature(self): """The temperature of the sensor in degrees Celsius.""" # This is just a guess since the starting point (21C here) isn't documented :( temp = self.read_temp_raw() - temp = 21.0 + temp/8 + temp = 21.0 + temp / 8 return temp def _read_u8(self, sensor_type, address): @@ -393,6 +400,7 @@ def _write_u8(self, sensor_type, address, val): class LSM9DS0_SPI(LSM9DS0): """Driver for the LSM9DS0 connected over SPI.""" + # pylint: disable=no-member def __init__(self, spi, xmcs, gcs): gcs.direction = Direction.OUTPUT diff --git a/docs/conf.py b/docs/conf.py index 358976c..398d672 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 LSM9DS0 Library' -copyright = u'2017 Tony DiCola' -author = u'Tony DiCola' +project = u"Adafruit LSM9DS0 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 = 'AdafruitLSM9DS0Librarydoc' +htmlhelp_basename = "AdafruitLSM9DS0Librarydoc" # -- 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, 'AdafruitLSM9DS0Library.tex', u'Adafruit LSM9DS0 Library Documentation', - author, 'manual'), + ( + master_doc, + "AdafruitLSM9DS0Library.tex", + u"Adafruit LSM9DS0 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, 'adafruitLSM9DS0library', u'Adafruit LSM9DS0 Library Documentation', - [author], 1) + ( + master_doc, + "adafruitLSM9DS0library", + u"Adafruit LSM9DS0 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, 'AdafruitLSM9DS0Library', u'Adafruit LSM9DS0 Library Documentation', - author, 'AdafruitLSM9DS0Library', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "AdafruitLSM9DS0Library", + u"Adafruit LSM9DS0 Library Documentation", + author, + "AdafruitLSM9DS0Library", + "One line description of project.", + "Miscellaneous", + ), ] diff --git a/examples/lsm9ds0_simpletest.py b/examples/lsm9ds0_simpletest.py index 9485345..0dcb331 100644 --- a/examples/lsm9ds0_simpletest.py +++ b/examples/lsm9ds0_simpletest.py @@ -4,6 +4,7 @@ import board import busio + # import digitalio # Used with SPI import adafruit_lsm9ds0 @@ -12,7 +13,7 @@ i2c = busio.I2C(board.SCL, board.SDA) sensor = adafruit_lsm9ds0.LSM9DS0_I2C(i2c) -#SPI connection: +# SPI connection: # from digitalio import DigitalInOut, Direction # spi = busio.SPI(board.SCK, board.MOSI, board.MISO) # gcs = DigitalInOut(board.D5) @@ -28,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 6970a80..8d8f523 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-lsm9ds0', - + name="adafruit-circuitpython-lsm9ds0", use_scm_version=True, - setup_requires=['setuptools_scm'], - - description='CircuitPython library for LSM9DS0 accelerometer, magnetometer, gyroscope.', + setup_requires=["setuptools_scm"], + description="CircuitPython library for LSM9DS0 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_LSM9DS0', - + url="https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS0", # 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 lsm9ds0 accelerometer magnetometer gyroscope breakout hardware' - 'micropython circuitpython', - + keywords="adafruit lsm9ds0 accelerometer magnetometer gyroscope 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_lsm9ds0'], + py_modules=["adafruit_lsm9ds0"], )