From f19543cb88f2e3e24a942ef1bdbfbe0200cf25c3 Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 20 Mar 2020 21:06:45 -0400 Subject: [PATCH] Ran black, updated to pylint 2.x --- .github/workflows/build.yml | 2 +- adafruit_l3gd20.py | 42 ++++++------ docs/conf.py | 116 ++++++++++++++++++++-------------- examples/l3gd20_simpletest.py | 2 +- setup.py | 52 +++++++-------- 5 files changed, 117 insertions(+), 97 deletions(-) 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/adafruit_l3gd20.py b/adafruit_l3gd20.py index 27d52ab..1208d63 100644 --- a/adafruit_l3gd20.py +++ b/adafruit_l3gd20.py @@ -54,6 +54,7 @@ from micropython import const from adafruit_register.i2c_struct import Struct + try: from struct import unpack except ImportError: @@ -78,9 +79,9 @@ _L3GD20_CHIP_ID = const(0xD4) _L3GD20H_CHIP_ID = const(0xD7) -_L3GD20_SENSITIVITY_250DPS = 0.00875 ## Roughly 22/256 for fixed point match -_L3GD20_SENSITIVITY_500DPS = 0.0175 ## Roughly 45/256 -_L3GD20_SENSITIVITY_2000DPS = 0.070 ## Roughly 18/256 +_L3GD20_SENSITIVITY_250DPS = 0.00875 ## Roughly 22/256 for fixed point match +_L3GD20_SENSITIVITY_500DPS = 0.0175 ## Roughly 45/256 +_L3GD20_SENSITIVITY_2000DPS = 0.070 ## Roughly 18/256 # pylint: disable=no-member @@ -94,15 +95,17 @@ class L3GD20: def __init__(self, rng=L3DS20_RANGE_250DPS): chip_id = self.read_register(_ID_REGISTER) - if chip_id != _L3GD20_CHIP_ID and chip_id != _L3GD20H_CHIP_ID: - raise RuntimeError("bad chip id (%x != %x or %x)" % - (chip_id, _L3GD20_CHIP_ID, _L3GD20H_CHIP_ID)) - - if rng != L3DS20_RANGE_250DPS and \ - rng != L3DS20_RANGE_500DPS and \ - rng != L3DS20_RANGE_2000DPS: - raise ValueError("Range value must be one of L3DS20_RANGE_250DPS, " - "L3DS20_RANGE_500DPS, or L3DS20_RANGE_2000DPS") + if chip_id not in (_L3GD20_CHIP_ID, _L3GD20H_CHIP_ID): + raise RuntimeError( + "bad chip id (%x != %x or %x)" + % (chip_id, _L3GD20_CHIP_ID, _L3GD20H_CHIP_ID) + ) + + if rng not in (L3DS20_RANGE_250DPS, L3DS20_RANGE_500DPS, L3DS20_RANGE_2000DPS): + raise ValueError( + "Range value must be one of L3DS20_RANGE_250DPS, " + "L3DS20_RANGE_500DPS, or L3DS20_RANGE_2000DPS" + ) # Set CTRL_REG1 (0x20) # ==================================================================== @@ -186,7 +189,6 @@ def __init__(self, rng=L3DS20_RANGE_250DPS): # Nothing to do ... keep default values # ------------------------------------------------------------------ - @property def gyro(self): """ @@ -194,7 +196,7 @@ def gyro(self): range selected """ raw = self.gyro_raw - return tuple(self.scale*v for v in raw) + return tuple(self.scale * v for v in raw) class L3GD20_I2C(L3GD20): @@ -207,11 +209,12 @@ class L3GD20_I2C(L3GD20): :param address: the optional device address, 0x68 is the default address """ - gyro_raw = Struct(_L3GD20_REGISTER_OUT_X_L_X80, '