Ran black, updated to pylint 2.x
This commit is contained in:
parent
30f497690e
commit
ff47136955
6 changed files with 196 additions and 158 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
|
@ -40,7 +40,7 @@ jobs:
|
||||||
source actions-ci/install.sh
|
source actions-ci/install.sh
|
||||||
- name: Pip install pylint, black, & Sphinx
|
- name: Pip install pylint, black, & Sphinx
|
||||||
run: |
|
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
|
- name: Library version
|
||||||
run: git describe --dirty --always --tags
|
run: git describe --dirty --always --tags
|
||||||
- name: PyLint
|
- name: PyLint
|
||||||
|
|
|
||||||
|
|
@ -45,56 +45,58 @@ https://www.adafruit.com/product/1231
|
||||||
|
|
||||||
from micropython import const
|
from micropython import const
|
||||||
from adafruit_bus_device import i2c_device
|
from adafruit_bus_device import i2c_device
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from struct import unpack
|
from struct import unpack
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from ustruct import unpack
|
from ustruct import unpack
|
||||||
__version__ = "0.0.0-auto.0"
|
__version__ = "0.0.0-auto.0"
|
||||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x.git"
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x.git"
|
||||||
#pylint: disable=bad-whitespace
|
# pylint: disable=bad-whitespace
|
||||||
_ADXL345_DEFAULT_ADDRESS = const(0x53) # Assumes ALT address pin low
|
_ADXL345_DEFAULT_ADDRESS = const(0x53) # Assumes ALT address pin low
|
||||||
|
|
||||||
# Conversion factors
|
# Conversion factors
|
||||||
_ADXL345_MG2G_MULTIPLIER = 0.004 # 4mg per lsb
|
_ADXL345_MG2G_MULTIPLIER = 0.004 # 4mg per lsb
|
||||||
_STANDARD_GRAVITY = 9.80665 # earth standard gravity
|
_STANDARD_GRAVITY = 9.80665 # earth standard gravity
|
||||||
|
|
||||||
_REG_DEVID = const(0x00) # Device ID
|
_REG_DEVID = const(0x00) # Device ID
|
||||||
_REG_THRESH_TAP = const(0x1D) # Tap threshold
|
_REG_THRESH_TAP = const(0x1D) # Tap threshold
|
||||||
_REG_OFSX = const(0x1E) # X-axis offset
|
_REG_OFSX = const(0x1E) # X-axis offset
|
||||||
_REG_OFSY = const(0x1F) # Y-axis offset
|
_REG_OFSY = const(0x1F) # Y-axis offset
|
||||||
_REG_OFSZ = const(0x20) # Z-axis offset
|
_REG_OFSZ = const(0x20) # Z-axis offset
|
||||||
_REG_DUR = const(0x21) # Tap duration
|
_REG_DUR = const(0x21) # Tap duration
|
||||||
_REG_LATENT = const(0x22) # Tap latency
|
_REG_LATENT = const(0x22) # Tap latency
|
||||||
_REG_WINDOW = const(0x23) # Tap window
|
_REG_WINDOW = const(0x23) # Tap window
|
||||||
_REG_THRESH_ACT = const(0x24) # Activity threshold
|
_REG_THRESH_ACT = const(0x24) # Activity threshold
|
||||||
_REG_THRESH_INACT = const(0x25) # Inactivity threshold
|
_REG_THRESH_INACT = const(0x25) # Inactivity threshold
|
||||||
_REG_TIME_INACT = const(0x26) # Inactivity time
|
_REG_TIME_INACT = const(0x26) # Inactivity time
|
||||||
_REG_ACT_INACT_CTL = const(0x27) # Axis enable control for [in]activity detection
|
_REG_ACT_INACT_CTL = const(0x27) # Axis enable control for [in]activity detection
|
||||||
_REG_THRESH_FF = const(0x28) # Free-fall threshold
|
_REG_THRESH_FF = const(0x28) # Free-fall threshold
|
||||||
_REG_TIME_FF = const(0x29) # Free-fall time
|
_REG_TIME_FF = const(0x29) # Free-fall time
|
||||||
_REG_TAP_AXES = const(0x2A) # Axis control for single/double tap
|
_REG_TAP_AXES = const(0x2A) # Axis control for single/double tap
|
||||||
_REG_ACT_TAP_STATUS = const(0x2B) # Source for single/double tap
|
_REG_ACT_TAP_STATUS = const(0x2B) # Source for single/double tap
|
||||||
_REG_BW_RATE = const(0x2C) # Data rate and power mode control
|
_REG_BW_RATE = const(0x2C) # Data rate and power mode control
|
||||||
_REG_POWER_CTL = const(0x2D) # Power-saving features control
|
_REG_POWER_CTL = const(0x2D) # Power-saving features control
|
||||||
_REG_INT_ENABLE = const(0x2E) # Interrupt enable control
|
_REG_INT_ENABLE = const(0x2E) # Interrupt enable control
|
||||||
_REG_INT_MAP = const(0x2F) # Interrupt mapping control
|
_REG_INT_MAP = const(0x2F) # Interrupt mapping control
|
||||||
_REG_INT_SOURCE = const(0x30) # Source of interrupts
|
_REG_INT_SOURCE = const(0x30) # Source of interrupts
|
||||||
_REG_DATA_FORMAT = const(0x31) # Data format control
|
_REG_DATA_FORMAT = const(0x31) # Data format control
|
||||||
_REG_DATAX0 = const(0x32) # X-axis data 0
|
_REG_DATAX0 = const(0x32) # X-axis data 0
|
||||||
_REG_DATAX1 = const(0x33) # X-axis data 1
|
_REG_DATAX1 = const(0x33) # X-axis data 1
|
||||||
_REG_DATAY0 = const(0x34) # Y-axis data 0
|
_REG_DATAY0 = const(0x34) # Y-axis data 0
|
||||||
_REG_DATAY1 = const(0x35) # Y-axis data 1
|
_REG_DATAY1 = const(0x35) # Y-axis data 1
|
||||||
_REG_DATAZ0 = const(0x36) # Z-axis data 0
|
_REG_DATAZ0 = const(0x36) # Z-axis data 0
|
||||||
_REG_DATAZ1 = const(0x37) # Z-axis data 1
|
_REG_DATAZ1 = const(0x37) # Z-axis data 1
|
||||||
_REG_FIFO_CTL = const(0x38) # FIFO control
|
_REG_FIFO_CTL = const(0x38) # FIFO control
|
||||||
_REG_FIFO_STATUS = const(0x39) # FIFO status
|
_REG_FIFO_STATUS = const(0x39) # FIFO status
|
||||||
_INT_SINGLE_TAP = const(0b01000000) # SINGLE_TAP bit
|
_INT_SINGLE_TAP = const(0b01000000) # SINGLE_TAP bit
|
||||||
_INT_DOUBLE_TAP = const(0b00100000) # DOUBLE_TAP bit
|
_INT_DOUBLE_TAP = const(0b00100000) # DOUBLE_TAP bit
|
||||||
_INT_ACT = const(0b00010000) # ACT bit
|
_INT_ACT = const(0b00010000) # ACT bit
|
||||||
_INT_INACT = const(0b00001000) # INACT bit
|
_INT_INACT = const(0b00001000) # INACT bit
|
||||||
_INT_FREE_FALL = const(0b00000100) # FREE_FALL bit
|
_INT_FREE_FALL = const(0b00000100) # FREE_FALL bit
|
||||||
|
|
||||||
class DataRate: #pylint: disable=too-few-public-methods
|
|
||||||
|
class DataRate: # pylint: disable=too-few-public-methods
|
||||||
"""An enum-like class representing the possible data rates.
|
"""An enum-like class representing the possible data rates.
|
||||||
Possible values are
|
Possible values are
|
||||||
|
|
||||||
|
|
@ -116,25 +118,26 @@ class DataRate: #pylint: disable=too-few-public-methods
|
||||||
- ``DataRate.RATE_0_10_HZ``
|
- ``DataRate.RATE_0_10_HZ``
|
||||||
|
|
||||||
"""
|
"""
|
||||||
RATE_3200_HZ = const(0b1111) # 1600Hz Bandwidth 140mA IDD
|
|
||||||
RATE_1600_HZ = const(0b1110) # 800Hz Bandwidth 90mA IDD
|
RATE_3200_HZ = const(0b1111) # 1600Hz Bandwidth 140mA IDD
|
||||||
RATE_800_HZ = const(0b1101) # 400Hz Bandwidth 140mA IDD
|
RATE_1600_HZ = const(0b1110) # 800Hz Bandwidth 90mA IDD
|
||||||
RATE_400_HZ = const(0b1100) # 200Hz Bandwidth 140mA IDD
|
RATE_800_HZ = const(0b1101) # 400Hz Bandwidth 140mA IDD
|
||||||
RATE_200_HZ = const(0b1011) # 100Hz Bandwidth 140mA IDD
|
RATE_400_HZ = const(0b1100) # 200Hz Bandwidth 140mA IDD
|
||||||
RATE_100_HZ = const(0b1010) # 50Hz Bandwidth 140mA IDD
|
RATE_200_HZ = const(0b1011) # 100Hz Bandwidth 140mA IDD
|
||||||
RATE_50_HZ = const(0b1001) # 25Hz Bandwidth 90mA IDD
|
RATE_100_HZ = const(0b1010) # 50Hz Bandwidth 140mA IDD
|
||||||
RATE_25_HZ = const(0b1000) # 12.5Hz Bandwidth 60mA IDD
|
RATE_50_HZ = const(0b1001) # 25Hz Bandwidth 90mA IDD
|
||||||
RATE_12_5_HZ = const(0b0111) # 6.25Hz Bandwidth 50mA IDD
|
RATE_25_HZ = const(0b1000) # 12.5Hz Bandwidth 60mA IDD
|
||||||
RATE_6_25HZ = const(0b0110) # 3.13Hz Bandwidth 45mA IDD
|
RATE_12_5_HZ = const(0b0111) # 6.25Hz Bandwidth 50mA IDD
|
||||||
RATE_3_13_HZ = const(0b0101) # 1.56Hz Bandwidth 40mA IDD
|
RATE_6_25HZ = const(0b0110) # 3.13Hz Bandwidth 45mA IDD
|
||||||
RATE_1_56_HZ = const(0b0100) # 0.78Hz Bandwidth 34mA IDD
|
RATE_3_13_HZ = const(0b0101) # 1.56Hz Bandwidth 40mA IDD
|
||||||
RATE_0_78_HZ = const(0b0011) # 0.39Hz Bandwidth 23mA IDD
|
RATE_1_56_HZ = const(0b0100) # 0.78Hz Bandwidth 34mA IDD
|
||||||
RATE_0_39_HZ = const(0b0010) # 0.20Hz Bandwidth 23mA IDD
|
RATE_0_78_HZ = const(0b0011) # 0.39Hz Bandwidth 23mA IDD
|
||||||
RATE_0_20_HZ = const(0b0001) # 0.10Hz Bandwidth 23mA IDD
|
RATE_0_39_HZ = const(0b0010) # 0.20Hz Bandwidth 23mA IDD
|
||||||
RATE_0_10_HZ = const(0b0000) # 0.05Hz Bandwidth 23mA IDD (default value)
|
RATE_0_20_HZ = const(0b0001) # 0.10Hz Bandwidth 23mA IDD
|
||||||
|
RATE_0_10_HZ = const(0b0000) # 0.05Hz Bandwidth 23mA IDD (default value)
|
||||||
|
|
||||||
|
|
||||||
class Range: #pylint: disable=too-few-public-methods
|
class Range: # pylint: disable=too-few-public-methods
|
||||||
"""An enum-like class representing the possible measurement ranges in +/- G.
|
"""An enum-like class representing the possible measurement ranges in +/- G.
|
||||||
|
|
||||||
Possible values are
|
Possible values are
|
||||||
|
|
@ -145,10 +148,12 @@ class Range: #pylint: disable=too-few-public-methods
|
||||||
- ``Range.RANGE_2_G``
|
- ``Range.RANGE_2_G``
|
||||||
|
|
||||||
"""
|
"""
|
||||||
RANGE_16_G = const(0b11) # +/- 16g
|
|
||||||
RANGE_8_G = const(0b10) # +/- 8g
|
RANGE_16_G = const(0b11) # +/- 16g
|
||||||
RANGE_4_G = const(0b01) # +/- 4g
|
RANGE_8_G = const(0b10) # +/- 8g
|
||||||
RANGE_2_G = const(0b00) # +/- 2g (default value)
|
RANGE_4_G = const(0b01) # +/- 4g
|
||||||
|
RANGE_2_G = const(0b00) # +/- 2g (default value)
|
||||||
|
|
||||||
|
|
||||||
# pylint: enable=bad-whitespace
|
# pylint: enable=bad-whitespace
|
||||||
class ADXL345:
|
class ADXL345:
|
||||||
|
|
@ -158,8 +163,8 @@ class ADXL345:
|
||||||
:param address: The I2C device address for the sensor. Default is ``0x53``.
|
:param address: The I2C device address for the sensor. Default is ``0x53``.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, i2c, address=_ADXL345_DEFAULT_ADDRESS):
|
|
||||||
|
|
||||||
|
def __init__(self, i2c, address=_ADXL345_DEFAULT_ADDRESS):
|
||||||
|
|
||||||
self._i2c = i2c_device.I2CDevice(i2c, address)
|
self._i2c = i2c_device.I2CDevice(i2c, address)
|
||||||
self._buffer = bytearray(6)
|
self._buffer = bytearray(6)
|
||||||
|
|
@ -173,7 +178,7 @@ class ADXL345:
|
||||||
@property
|
@property
|
||||||
def acceleration(self):
|
def acceleration(self):
|
||||||
"""The x, y, z acceleration values returned in a 3-tuple in m / s ^ 2."""
|
"""The x, y, z acceleration values returned in a 3-tuple in m / s ^ 2."""
|
||||||
x, y, z = unpack('<hhh', self._read_register(_REG_DATAX0, 6))
|
x, y, z = unpack("<hhh", self._read_register(_REG_DATAX0, 6))
|
||||||
x = x * _ADXL345_MG2G_MULTIPLIER * _STANDARD_GRAVITY
|
x = x * _ADXL345_MG2G_MULTIPLIER * _STANDARD_GRAVITY
|
||||||
y = y * _ADXL345_MG2G_MULTIPLIER * _STANDARD_GRAVITY
|
y = y * _ADXL345_MG2G_MULTIPLIER * _STANDARD_GRAVITY
|
||||||
z = z * _ADXL345_MG2G_MULTIPLIER * _STANDARD_GRAVITY
|
z = z * _ADXL345_MG2G_MULTIPLIER * _STANDARD_GRAVITY
|
||||||
|
|
@ -207,14 +212,22 @@ class ADXL345:
|
||||||
|
|
||||||
for event_type, value in self._enabled_interrupts.items():
|
for event_type, value in self._enabled_interrupts.items():
|
||||||
if event_type == "motion":
|
if event_type == "motion":
|
||||||
self._event_status[event_type] = interrupt_source_register & _INT_ACT > 0
|
self._event_status[event_type] = (
|
||||||
|
interrupt_source_register & _INT_ACT > 0
|
||||||
|
)
|
||||||
if event_type == "tap":
|
if event_type == "tap":
|
||||||
if value == 1:
|
if value == 1:
|
||||||
self._event_status[event_type] = interrupt_source_register & _INT_SINGLE_TAP > 0
|
self._event_status[event_type] = (
|
||||||
|
interrupt_source_register & _INT_SINGLE_TAP > 0
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self._event_status[event_type] = interrupt_source_register & _INT_DOUBLE_TAP > 0
|
self._event_status[event_type] = (
|
||||||
|
interrupt_source_register & _INT_DOUBLE_TAP > 0
|
||||||
|
)
|
||||||
if event_type == "freefall":
|
if event_type == "freefall":
|
||||||
self._event_status[event_type] = interrupt_source_register & _INT_FREE_FALL > 0
|
self._event_status[event_type] = (
|
||||||
|
interrupt_source_register & _INT_FREE_FALL > 0
|
||||||
|
)
|
||||||
|
|
||||||
return self._event_status
|
return self._event_status
|
||||||
|
|
||||||
|
|
@ -233,11 +246,12 @@ class ADXL345:
|
||||||
"""
|
"""
|
||||||
active_interrupts = self._read_register_unpacked(_REG_INT_ENABLE)
|
active_interrupts = self._read_register_unpacked(_REG_INT_ENABLE)
|
||||||
|
|
||||||
|
self._write_register_byte(_REG_INT_ENABLE, 0x0) # disable interrupts for setup
|
||||||
self._write_register_byte(_REG_INT_ENABLE, 0x0) # disable interrupts for setup
|
self._write_register_byte(
|
||||||
self._write_register_byte(_REG_ACT_INACT_CTL, 0b01110000) # enable activity on X,Y,Z
|
_REG_ACT_INACT_CTL, 0b01110000
|
||||||
|
) # enable activity on X,Y,Z
|
||||||
self._write_register_byte(_REG_THRESH_ACT, threshold)
|
self._write_register_byte(_REG_THRESH_ACT, threshold)
|
||||||
self._write_register_byte(_REG_INT_ENABLE, _INT_ACT) # Inactive interrupt only
|
self._write_register_byte(_REG_INT_ENABLE, _INT_ACT) # Inactive interrupt only
|
||||||
|
|
||||||
active_interrupts |= _INT_ACT
|
active_interrupts |= _INT_ACT
|
||||||
self._write_register_byte(_REG_INT_ENABLE, active_interrupts)
|
self._write_register_byte(_REG_INT_ENABLE, active_interrupts)
|
||||||
|
|
@ -252,7 +266,6 @@ class ADXL345:
|
||||||
self._write_register_byte(_REG_INT_ENABLE, active_interrupts)
|
self._write_register_byte(_REG_INT_ENABLE, active_interrupts)
|
||||||
self._enabled_interrupts.pop("motion")
|
self._enabled_interrupts.pop("motion")
|
||||||
|
|
||||||
|
|
||||||
def enable_freefall_detection(self, *, threshold=10, time=25):
|
def enable_freefall_detection(self, *, threshold=10, time=25):
|
||||||
"""
|
"""
|
||||||
Freefall detection parameters:
|
Freefall detection parameters:
|
||||||
|
|
@ -273,7 +286,7 @@ class ADXL345:
|
||||||
|
|
||||||
active_interrupts = self._read_register_unpacked(_REG_INT_ENABLE)
|
active_interrupts = self._read_register_unpacked(_REG_INT_ENABLE)
|
||||||
|
|
||||||
self._write_register_byte(_REG_INT_ENABLE, 0x0) # disable interrupts for setup
|
self._write_register_byte(_REG_INT_ENABLE, 0x0) # disable interrupts for setup
|
||||||
self._write_register_byte(_REG_THRESH_FF, threshold)
|
self._write_register_byte(_REG_THRESH_FF, threshold)
|
||||||
self._write_register_byte(_REG_TIME_FF, time)
|
self._write_register_byte(_REG_TIME_FF, time)
|
||||||
|
|
||||||
|
|
@ -289,7 +302,9 @@ class ADXL345:
|
||||||
self._write_register_byte(_REG_INT_ENABLE, active_interrupts)
|
self._write_register_byte(_REG_INT_ENABLE, active_interrupts)
|
||||||
self._enabled_interrupts.pop("freefall")
|
self._enabled_interrupts.pop("freefall")
|
||||||
|
|
||||||
def enable_tap_detection(self, *, tap_count=1, threshold=20, duration=50, latency=20, window=255):#pylint: disable=line-too-long
|
def enable_tap_detection(
|
||||||
|
self, *, tap_count=1, threshold=20, duration=50, latency=20, window=255
|
||||||
|
): # pylint: disable=line-too-long
|
||||||
"""
|
"""
|
||||||
The tap detection parameters.
|
The tap detection parameters.
|
||||||
|
|
||||||
|
|
@ -317,8 +332,10 @@ class ADXL345:
|
||||||
"""
|
"""
|
||||||
active_interrupts = self._read_register_unpacked(_REG_INT_ENABLE)
|
active_interrupts = self._read_register_unpacked(_REG_INT_ENABLE)
|
||||||
|
|
||||||
self._write_register_byte(_REG_INT_ENABLE, 0x0) # disable interrupts for setup
|
self._write_register_byte(_REG_INT_ENABLE, 0x0) # disable interrupts for setup
|
||||||
self._write_register_byte(_REG_TAP_AXES, 0b00000111) # enable X, Y, Z axes for tap
|
self._write_register_byte(
|
||||||
|
_REG_TAP_AXES, 0b00000111
|
||||||
|
) # enable X, Y, Z axes for tap
|
||||||
self._write_register_byte(_REG_THRESH_TAP, threshold)
|
self._write_register_byte(_REG_THRESH_TAP, threshold)
|
||||||
self._write_register_byte(_REG_DUR, duration)
|
self._write_register_byte(_REG_DUR, duration)
|
||||||
|
|
||||||
|
|
@ -334,7 +351,9 @@ class ADXL345:
|
||||||
self._write_register_byte(_REG_INT_ENABLE, active_interrupts)
|
self._write_register_byte(_REG_INT_ENABLE, active_interrupts)
|
||||||
self._enabled_interrupts["tap"] = 2
|
self._enabled_interrupts["tap"] = 2
|
||||||
else:
|
else:
|
||||||
raise ValueError("tap must be 0 to disable, 1 for single tap, or 2 for double tap")
|
raise ValueError(
|
||||||
|
"tap must be 0 to disable, 1 for single tap, or 2 for double tap"
|
||||||
|
)
|
||||||
|
|
||||||
def disable_tap_detection(self):
|
def disable_tap_detection(self):
|
||||||
"Disable tap detection"
|
"Disable tap detection"
|
||||||
|
|
@ -394,6 +413,7 @@ class ADXL345:
|
||||||
with self._i2c as i2c:
|
with self._i2c as i2c:
|
||||||
i2c.write(self._buffer, start=0, end=2)
|
i2c.write(self._buffer, start=0, end=2)
|
||||||
|
|
||||||
|
|
||||||
class ADXL343(ADXL345):
|
class ADXL343(ADXL345):
|
||||||
"""
|
"""
|
||||||
Stub class for the ADXL343 3-axis accelerometer
|
Stub class for the ADXL343 3-axis accelerometer
|
||||||
|
|
|
||||||
120
docs/conf.py
120
docs/conf.py
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
sys.path.insert(0, os.path.abspath('..'))
|
|
||||||
|
sys.path.insert(0, os.path.abspath(".."))
|
||||||
|
|
||||||
# -- General configuration ------------------------------------------------
|
# -- General configuration ------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -10,10 +11,10 @@ sys.path.insert(0, os.path.abspath('..'))
|
||||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||||
# ones.
|
# ones.
|
||||||
extensions = [
|
extensions = [
|
||||||
'sphinx.ext.autodoc',
|
"sphinx.ext.autodoc",
|
||||||
'sphinx.ext.intersphinx',
|
"sphinx.ext.intersphinx",
|
||||||
'sphinx.ext.napoleon',
|
"sphinx.ext.napoleon",
|
||||||
'sphinx.ext.todo',
|
"sphinx.ext.todo",
|
||||||
]
|
]
|
||||||
|
|
||||||
# TODO: Please Read!
|
# TODO: Please Read!
|
||||||
|
|
@ -23,29 +24,40 @@ extensions = [
|
||||||
# autodoc_mock_imports = ["adafruit_bus_device", "digitalio", "busio", "micropython"]
|
# autodoc_mock_imports = ["adafruit_bus_device", "digitalio", "busio", "micropython"]
|
||||||
|
|
||||||
|
|
||||||
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/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,
|
||||||
|
),
|
||||||
|
"Register": (
|
||||||
|
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
|
||||||
|
}
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# 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.
|
# The master toctree document.
|
||||||
master_doc = 'index'
|
master_doc = "index"
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'Adafruit ADXL34x Library'
|
project = u"Adafruit ADXL34x Library"
|
||||||
copyright = u'2018 Bryan Siepert'
|
copyright = u"2018 Bryan Siepert"
|
||||||
author = u'Bryan Siepert'
|
author = u"Bryan Siepert"
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = u'1.0'
|
version = u"1.0"
|
||||||
# The full version, including alpha/beta/rc tags.
|
# 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
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|
@ -57,7 +69,7 @@ language = None
|
||||||
# List of patterns, relative to source directory, that match files and
|
# List of patterns, relative to source directory, that match files and
|
||||||
# directories to ignore when looking for source files.
|
# directories to ignore when looking for source files.
|
||||||
# This patterns also effect to html_static_path and html_extra_path
|
# 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
|
# The reST default role (used for this markup: `text`) to use for all
|
||||||
# documents.
|
# documents.
|
||||||
|
|
@ -69,7 +81,7 @@ default_role = "any"
|
||||||
add_function_parentheses = True
|
add_function_parentheses = True
|
||||||
|
|
||||||
# The name of the Pygments (syntax highlighting) style to use.
|
# 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.
|
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||||
todo_include_todos = False
|
todo_include_todos = False
|
||||||
|
|
@ -84,59 +96,62 @@ napoleon_numpy_docstring = False
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
# a list of builtin themes.
|
# 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
|
if not on_rtd: # only import and set the theme if we're building docs locally
|
||||||
try:
|
try:
|
||||||
import sphinx_rtd_theme
|
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:
|
except:
|
||||||
html_theme = 'default'
|
html_theme = "default"
|
||||||
html_theme_path = ['.']
|
html_theme_path = ["."]
|
||||||
else:
|
else:
|
||||||
html_theme_path = ['.']
|
html_theme_path = ["."]
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# 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,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# 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 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
|
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||||
# pixels large.
|
# pixels large.
|
||||||
#
|
#
|
||||||
html_favicon = '_static/favicon.ico'
|
html_favicon = "_static/favicon.ico"
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
# Output file base name for HTML help builder.
|
||||||
htmlhelp_basename = 'AdafruitAdxl34xLibrarydoc'
|
htmlhelp_basename = "AdafruitAdxl34xLibrarydoc"
|
||||||
|
|
||||||
# -- Options for LaTeX output ---------------------------------------------
|
# -- Options for LaTeX output ---------------------------------------------
|
||||||
|
|
||||||
latex_elements = {
|
latex_elements = {
|
||||||
# The paper size ('letterpaper' or 'a4paper').
|
# The paper size ('letterpaper' or 'a4paper').
|
||||||
#
|
#
|
||||||
# 'papersize': 'letterpaper',
|
# 'papersize': 'letterpaper',
|
||||||
|
# The font size ('10pt', '11pt' or '12pt').
|
||||||
# The font size ('10pt', '11pt' or '12pt').
|
#
|
||||||
#
|
# 'pointsize': '10pt',
|
||||||
# 'pointsize': '10pt',
|
# Additional stuff for the LaTeX preamble.
|
||||||
|
#
|
||||||
# Additional stuff for the LaTeX preamble.
|
# 'preamble': '',
|
||||||
#
|
# Latex figure (float) alignment
|
||||||
# 'preamble': '',
|
#
|
||||||
|
# 'figure_align': 'htbp',
|
||||||
# Latex figure (float) alignment
|
|
||||||
#
|
|
||||||
# 'figure_align': 'htbp',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Grouping the document tree into LaTeX files. List of tuples
|
# Grouping the document tree into LaTeX files. List of tuples
|
||||||
# (source start file, target name, title,
|
# (source start file, target name, title,
|
||||||
# author, documentclass [howto, manual, or own class]).
|
# author, documentclass [howto, manual, or own class]).
|
||||||
latex_documents = [
|
latex_documents = [
|
||||||
(master_doc, 'AdafruitADXL34xLibrary.tex', u'AdafruitADXL34x Library Documentation',
|
(
|
||||||
author, 'manual'),
|
master_doc,
|
||||||
|
"AdafruitADXL34xLibrary.tex",
|
||||||
|
u"AdafruitADXL34x Library Documentation",
|
||||||
|
author,
|
||||||
|
"manual",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
# -- Options for manual page output ---------------------------------------
|
# -- Options for manual page output ---------------------------------------
|
||||||
|
|
@ -144,8 +159,13 @@ latex_documents = [
|
||||||
# One entry per manual page. List of tuples
|
# One entry per manual page. List of tuples
|
||||||
# (source start file, name, description, authors, manual section).
|
# (source start file, name, description, authors, manual section).
|
||||||
man_pages = [
|
man_pages = [
|
||||||
(master_doc, 'AdafruitADXL34xlibrary', u'Adafruit ADXL34x Library Documentation',
|
(
|
||||||
[author], 1)
|
master_doc,
|
||||||
|
"AdafruitADXL34xlibrary",
|
||||||
|
u"Adafruit ADXL34x Library Documentation",
|
||||||
|
[author],
|
||||||
|
1,
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
# -- Options for Texinfo output -------------------------------------------
|
# -- Options for Texinfo output -------------------------------------------
|
||||||
|
|
@ -154,7 +174,13 @@ man_pages = [
|
||||||
# (source start file, target name, title, author,
|
# (source start file, target name, title, author,
|
||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
(master_doc, 'AdafruitADXL34xLibrary', u'Adafruit ADXL34x Library Documentation',
|
(
|
||||||
author, 'AdafruitADXL34xLibrary', 'One line description of project.',
|
master_doc,
|
||||||
'Miscellaneous'),
|
"AdafruitADXL34xLibrary",
|
||||||
|
u"Adafruit ADXL34x Library Documentation",
|
||||||
|
author,
|
||||||
|
"AdafruitADXL34xLibrary",
|
||||||
|
"One line description of project.",
|
||||||
|
"Miscellaneous",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,5 @@ accelerometer.enable_motion_detection()
|
||||||
while True:
|
while True:
|
||||||
print("%f %f %f" % accelerometer.acceleration)
|
print("%f %f %f" % accelerometer.acceleration)
|
||||||
|
|
||||||
print("Motion detected: %s" % accelerometer.events['motion'])
|
print("Motion detected: %s" % accelerometer.events["motion"])
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,5 @@ accelerometer.enable_tap_detection()
|
||||||
while True:
|
while True:
|
||||||
print("%f %f %f" % accelerometer.acceleration)
|
print("%f %f %f" % accelerometer.acceleration)
|
||||||
|
|
||||||
print("Tapped: %s" % accelerometer.events['tap'])
|
print("Tapped: %s" % accelerometer.events["tap"])
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
|
||||||
54
setup.py
54
setup.py
|
|
@ -7,6 +7,7 @@ https://github.com/pypa/sampleproject
|
||||||
|
|
||||||
# Always prefer setuptools over distutils
|
# Always prefer setuptools over distutils
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
# To use a consistent encoding
|
# To use a consistent encoding
|
||||||
from codecs import open
|
from codecs import open
|
||||||
from os import path
|
from os import path
|
||||||
|
|
@ -14,48 +15,39 @@ from os import path
|
||||||
here = path.abspath(path.dirname(__file__))
|
here = path.abspath(path.dirname(__file__))
|
||||||
|
|
||||||
# Get the long description from the README 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()
|
long_description = f.read()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='adafruit-circuitpython-adxl34x',
|
name="adafruit-circuitpython-adxl34x",
|
||||||
|
|
||||||
use_scm_version=True,
|
use_scm_version=True,
|
||||||
setup_requires=['setuptools_scm'],
|
setup_requires=["setuptools_scm"],
|
||||||
|
description="A CircuitPython driver for the ADXL34x family of accelerometers.",
|
||||||
description='A CircuitPython driver for the ADXL34x family of accelerometers.',
|
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type='text/x-rst',
|
long_description_content_type="text/x-rst",
|
||||||
|
|
||||||
# The project's main homepage.
|
# The project's main homepage.
|
||||||
url='https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x',
|
url="https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x",
|
||||||
|
|
||||||
# Author details
|
# Author details
|
||||||
author='Adafruit Industries',
|
author="Adafruit Industries",
|
||||||
author_email='circuitpython@adafruit.com',
|
author_email="circuitpython@adafruit.com",
|
||||||
|
install_requires=["Adafruit-Blinka", "adafruit-circuitpython-busdevice"],
|
||||||
install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice'],
|
|
||||||
|
|
||||||
# Choose your license
|
# Choose your license
|
||||||
license='MIT',
|
license="MIT",
|
||||||
|
|
||||||
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 3 - Alpha',
|
"Development Status :: 3 - Alpha",
|
||||||
'Intended Audience :: Developers',
|
"Intended Audience :: Developers",
|
||||||
'Topic :: Software Development :: Libraries',
|
"Topic :: Software Development :: Libraries",
|
||||||
'Topic :: System :: Hardware',
|
"Topic :: System :: Hardware",
|
||||||
'License :: OSI Approved :: MIT License',
|
"License :: OSI Approved :: MIT License",
|
||||||
'Programming Language :: Python :: 3',
|
"Programming Language :: Python :: 3",
|
||||||
'Programming Language :: Python :: 3.4',
|
"Programming Language :: Python :: 3.4",
|
||||||
'Programming Language :: Python :: 3.5',
|
"Programming Language :: Python :: 3.5",
|
||||||
],
|
],
|
||||||
|
|
||||||
# What does your project relate to?
|
# What does your project relate to?
|
||||||
keywords='adafruit hardware accelerometer acceleration spi i2c triple axis'
|
keywords="adafruit hardware accelerometer acceleration spi i2c triple axis"
|
||||||
'micropython circuitpython',
|
"micropython circuitpython",
|
||||||
|
|
||||||
# You can just specify the packages manually here if your project is
|
# You can just specify the packages manually here if your project is
|
||||||
# simple. Or you can use find_packages().
|
# simple. Or you can use find_packages().
|
||||||
py_modules=['adafruit_adxl34x'],
|
py_modules=["adafruit_adxl34x"],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue