Skip to content

Commit 990f34b

Browse files
committed
prepare release
1 parent f677143 commit 990f34b

File tree

7 files changed

+91
-18
lines changed

7 files changed

+91
-18
lines changed

.github/workflows/release.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,20 @@ jobs:
2525
2626
echo ::set-output name=version::${VERSION}
2727
28-
- name: Publish a Python distribution to PyPI
28+
- name: Setup Python
29+
uses: actions/setup-python@v2
30+
with:
31+
python-version: 3.7
32+
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install build --user
36+
37+
- name: Build
38+
run: |
39+
python -m build --sdist --wheel --outdir dist/
40+
41+
- name: Publish to PyPI
2942
uses: pypa/gh-action-pypi-publish@release/v1
3043
with:
3144
user: __token__

.github/workflows/validate.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,3 @@ jobs:
4040

4141
- name: Perform CodeQL Analysis
4242
uses: github/codeql-action/analyze@v1
43-
44-
- name: Test
45-
run: |
46-
pip install pytest pytest-cov
47-
pytest tests/ --doctest-modules --cov=MCP2221 --cov-report term-missing

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
.pytest_cache
22
__pycache__
33
junit
4-
.coverage
4+
.coverage
5+
build/
6+
dist/
7+
*.egg-info

MCP2221/MCP2221.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,41 +68,33 @@ def _getConfig(self):
6868
buf = [0] * 65
6969
buf[1] = 0x61 # get SRAM settings
7070
rbuf = self._send(buf)
71-
print(rbuf)
71+
# print(rbuf)
7272

7373
buf[0 + 1] = 0x60 # set SRAM settings
7474

7575
# Clock Output Divider Value
7676
buf[2 + 1] |= (rbuf[5] & 0b11111)
77-
print("Clock divider:", rbuf[5] & 0b111,
78-
"duty:", (rbuf[5] >> 3) & 0b11)
7977

8078
# DAC Voltage Reference
8179
buf[3 + 1] |= rbuf[6] >> 5
82-
print("DAC ref:", (rbuf[6] >> 6) & 0b11, "VRM:", (rbuf[6] >> 5) & 0b1)
8380

8481
# ADC Voltage Reference
8582
buf[5 + 1] |= (rbuf[7] >> 2) & 0b111
86-
print("ADC ref:", (rbuf[7] >> 3) & 0b11, "VRM:", (rbuf[7] >> 2) & 0b1)
8783

8884
# Interrupt detection
8985
# TODO
9086

9187
# GP0 Settings
9288
buf[8 + 1] = rbuf[22]
93-
print("GP0 type:", rbuf[22] & 0b111, "input:", (rbuf[22] >> 3) & 0b1)
9489

9590
# GP1 Settings
9691
buf[9 + 1] = rbuf[23]
97-
print("GP1 type:", rbuf[23] & 0b111, "input:", (rbuf[23] >> 3) & 0b1)
9892

9993
# GP2 Settings
10094
buf[10 + 1] = rbuf[24]
101-
print("GP2 type:", rbuf[24] & 0b111, "input:", (rbuf[24] >> 3) & 0b1)
10295

10396
# GP3 Settings
10497
buf[11 + 1] = rbuf[25]
105-
print("GP3 type:", rbuf[25] & 0b111, "input:", (rbuf[25] >> 3) & 0b1)
10698

10799
return buf
108100

MCP2221/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Python driver for MCP2221A
3+
"""

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,48 @@
11
# Python module for MCP2221
2-
[![Build](https://github.com/pilotak/python-mcp2221/actions/workflows/build.yaml/badge.svg)](https://github.com/pilotak/python-mcp2221/actions/workflows/build.yaml)
2+
[![Build](https://github.com/pilotak/python-mcp2221/actions/workflows/validate.yaml/badge.svg)](https://github.com/pilotak/python-mcp2221/actions/workflows/validate.yaml)
3+
4+
## Examples
5+
6+
Read GP0
7+
```python
8+
from MCP2221 import MCP2221
9+
10+
mcp2221 = MCP2221.MCP2221()
11+
mcp2221.InitGP(0, MCP2221.TYPE.INPUT)
12+
print(mcp2221.ReadGP(0))
13+
```
14+
15+
Write GP0
16+
```python
17+
from MCP2221 import MCP2221
18+
19+
mcp2221 = MCP2221.MCP2221()
20+
mcp2221.InitGP(0, MCP2221.TYPE.OUTPUT)
21+
print(mcp2221.WriteGP(0, 1))
22+
```
23+
24+
Read ADC on GP1
25+
```python
26+
from MCP2221 import MCP2221
27+
28+
mcp2221 = MCP2221.MCP2221()
29+
mcp2221.InitGP(1, MCP2221.TYPE.ADC)
30+
mcp2221.SetADCVoltageReference(MCP2221.VRM.VDD)
31+
print(mcp2221.ReadADC(1))
32+
```
33+
34+
Write DAC on GP2
35+
```python
36+
from MCP2221 import MCP2221
37+
38+
mcp2221 = MCP2221.MCP2221()
39+
mcp2221.InitGP(2, MCP2221.TYPE.DAC)
40+
mcp2221.SetDACVoltageReference(MCP2221.VRM.REF_2_048V)
41+
mcp2221.WriteDAC(12)
42+
```
343

444
## Tests
545
```sh
646
pip install pytest pytest-cov
7-
pytest tests/ --doctest-modules --cov=MCP2221 --cov-report term-missing
47+
pytest tests/ --doctest-modules --cov=MCP2221
848
```

setup.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import setuptools
2+
3+
with open("README.md", "r", encoding="utf-8") as fh:
4+
long_description = fh.read()
5+
6+
setuptools.setup(
7+
name="mcp2221",
8+
version="1.0.0",
9+
author="Pavel Slama",
10+
author_email="info@pavelslama.cz",
11+
description="Python driver for MCP2221A",
12+
long_description=long_description,
13+
long_description_content_type="text/markdown",
14+
keywords=['MCP2221', 'MCP2221A', 'GPIO', 'ADC', 'DAC', 'I2C'],
15+
url="https://github.com/pilotak/python-mcp2221",
16+
project_urls={
17+
"Bug Tracker": "https://github.com/pilotak/python-mcp2221/issues",
18+
},
19+
packages=setuptools.find_packages(),
20+
install_requires=['hidapi'],
21+
classifiers=[
22+
"Programming Language :: Python :: 3",
23+
"License :: OSI Approved :: MIT License",
24+
"Operating System :: OS Independent",
25+
],
26+
python_requires='>=3.7',
27+
)

0 commit comments

Comments
 (0)