Skip to content

Commit e4efcca

Browse files
committed
ready for release
1 parent 879d36c commit e4efcca

File tree

6 files changed

+56
-23
lines changed

6 files changed

+56
-23
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ bundles
99
*.DS_Store
1010
.eggs
1111
dist
12-
**/*.egg-info
12+
docs/
13+
**/*.egg-info

.travis.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
dist: xenial
2+
language: python
3+
python:
4+
- "3.6"
5+
cache:
6+
pip: true
7+
8+
env:
9+
- DEPLOY_PYPI="true"
10+
11+
deploy:
12+
- provider: releases
13+
api_key: "$GITHUB_TOKEN"
14+
file_glob: true
15+
file: "$TRAVIS_BUILD_DIR/bundles/*"
16+
skip_cleanup: true
17+
overwrite: true
18+
on:
19+
tags: true
20+
- provider: pypi
21+
user: adafruit-travis
22+
password:
23+
secure: DpEbI64T3Vp2NGlcOC3lRUHfdqenvuUQHdq3nLZTybaGboggsBRWqpnGok/qhY5Ojq0YCrTP/6+tX5LNyJGqo8M2ULPf8Ss4eyafdtKC67kS63y5AxK032P2cipYtAFDhnWmRmd6hxhIVBwcgNE2FOi3QVCz2jIiMq8xvnpeeY87NAjvoW5JcQPzaNHjh+YAleP8xIEdwoXjBRYmx0b9IELCtOTQWQzIcS4dJZ2FPQpQOLTnqh0drROhXDoG7HQQBMliiYir39zSZO9QorJFzHSoccVtT72Kn6ifE05Jh1S5ZGs2Xl4pzNa7+EofemIuR4Umgour00sZv/rFB0fn9LX0ywUD+6PvpDo7MlCBXhsv2CFJHohXCTRdZtjQJhtyn+TiBUScjXyi5xGwX/OORA+5yhiSdcDRhdg28MDluOOEpZdX4TcHoprQk7Pd3wYrTLWY6sSE7xEXezK5mnmALwsz2bnAMtJFMjvngdkZuht+nD5+msL7SW72ETCR7i2dCMGPWYh0hI0/zEFo7YTPCtJ+4EdhqNleq8+JIYXjST0JmxrQMwZgcnKpcUrgH5zh1/+uXPcskEp4q/QYwLJwsLGZ5oMrq1p6FkdQVEQdlDZF5CLlOVZT/wFGPV535yRljhyJEmoC4U3Ix+vOdEkWGGyc2A6u0KTOJaFIHVaXRAQ=
24+
on:
25+
tags: true
26+
condition: $DEPLOY_PYPI = "true"
27+
28+
install:
29+
- pip install -r requirements.txt
30+
- pip install circuitpython-build-tools Sphinx sphinx-rtd-theme
31+
- pip install --force-reinstall pylint==1.9.2
32+
33+
script:
34+
- pylint adafruit_tlv493d.py
35+
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*.py)
36+
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-tlv493d --library_location .
37+
- cd docs && sphinx-build -E -W -b html . _build/html && cd ..

README.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ This is easily achieved by downloading
3030

3131
Installing from PyPI
3232
=====================
33-
.. note:: This library is not available on PyPI yet. Install documentation is included
34-
as a standard element. Stay tuned for PyPI availability!
35-
36-
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
37-
If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section.
38-
3933
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
4034
PyPI <https://pypi.org/project/adafruit-circuitpython-tlv493d/>`_. To install for current user:
4135

@@ -65,14 +59,14 @@ Usage Example
6559
6660
import time
6761
import board
62+
import busio
6863
import adafruit_tlv493d
6964
70-
i2c = board.I2C()
71-
65+
i2c = busio.I2C(board.SCL, board.SDA)
7266
tlv = adafruit_tlv493d.TLV493D(i2c)
7367
7468
while True:
75-
print("%s, %s, %s"%tlv.magnetic)
69+
print("X: %s, Y:%s, Z:%s mT"%tlv.magnetic)
7670
time.sleep(1)
7771
7872
Contributing

adafruit_tlv493d.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@
4949
__version__ = "0.0.0-auto.0"
5050
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_TLV493D.git"
5151

52-
class TLV493D:
52+
class TLV493D:
5353
"""Driver for the TLV493D 3-axis Magnetometer.
54+
5455
:param busio.I2C i2c_bus: The I2C bus the TLV493D is connected to.
56+
5557
"""
5658

5759
read_masks = {
@@ -85,16 +87,16 @@ class TLV493D:
8587
"RES3":(3, 0x1F, 0)
8688
}
8789

88-
def __init__(self, i2c_interface):
89-
self.i2c_device = i2cdevice.I2CDevice(i2c_interface, 0x5E)
90+
def __init__(self, i2c_bus):
91+
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, 0x5E)
9092
self.read_buffer = bytearray(10)
9193
self.write_buffer = bytearray(4)
9294

9395
# read in data from sensor, including data that must be set on a write
9496
self._setup_write_buffer()
95-
97+
9698
# setup MASTERCONTROLLEDMODE which takes a measurement for every read
97-
self._set_write_key('PARITY', 1)
99+
self._set_write_key('PARITY', 1)
98100
self._set_write_key('PARITY', 1)
99101
self._set_write_key('LOWPOWER', 1)
100102
self._set_write_key('LP_PERIOD', 1)
@@ -145,7 +147,7 @@ def magnetic(self):
145147
self._unpack_and_scale(y_top, y_bot),
146148
self._unpack_and_scale(z_top, z_bot))
147149

148-
def _unpack_and_scale(self, top, bottom):
149-
binval = struct.unpack_from(">h", bytearray([top, bottom]))[0]
150+
def _unpack_and_scale(self, top, bottom): #pylint: disable=no-self-use
151+
binval = struct.unpack_from(">h", bytearray([top, bottom]))[0]
150152
binval = binval >>4
151153
return binval * 0.098

examples/tlv493d_simpletest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import time
22
import board
3+
import busio
34
import adafruit_tlv493d
45

5-
i2c = board.I2C()
6-
6+
i2c = busio.I2C(board.SCL, board.SDA)
77
tlv = adafruit_tlv493d.TLV493D(i2c)
88

99
while True:
10-
print("%s, %s, %s"%tlv.magnetic)
11-
time.sleep(1)
10+
print("X: %s, Y: %s, Z: %s mT"%tlv.magnetic)
11+
time.sleep(1)

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959

6060
# You can just specify the packages manually here if your project is
6161
# simple. Or you can use find_packages().
62-
# TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER,
63-
# CHANGE `py_modules=['...']` TO `packages=['...']`
62+
6463
py_modules=['adafruit_tlv493d'],
6564
)

0 commit comments

Comments
 (0)