# Python driver for MCP2221/A
[![Build](https://github.com/pilotak/python-mcp2221/actions/workflows/validate.yaml/badge.svg)](https://github.com/pilotak/python-mcp2221/actions/workflows/validate.yaml)
[![PyPI](https://img.shields.io/pypi/v/mcp2221)](https://pypi.org/project/mcp2221/)
## Examples
Read GP0
```python
from MCP2221 import MCP2221
mcp2221 = MCP2221.MCP2221()
mcp2221.InitGP(0, MCP2221.TYPE.INPUT)
print(mcp2221.ReadGP(0))
```
Write GP0
```python
from MCP2221 import MCP2221
mcp2221 = MCP2221.MCP2221()
mcp2221.InitGP(0, MCP2221.TYPE.OUTPUT)
print(mcp2221.WriteGP(0, 1))
```
Read ADC on GP1
```python
from MCP2221 import MCP2221
mcp2221 = MCP2221.MCP2221()
mcp2221.InitGP(1, MCP2221.TYPE.ADC)
mcp2221.SetADCVoltageReference(MCP2221.VRM.VDD)
print(mcp2221.ReadADC(1))
```
Write DAC on GP2
```python
from MCP2221 import MCP2221
mcp2221 = MCP2221.MCP2221()
mcp2221.InitGP(2, MCP2221.TYPE.DAC)
mcp2221.SetDACVoltageReference(MCP2221.VRM.REF_2_048V)
mcp2221.WriteDAC(12)
```
## Tests
```sh
pip install pytest pytest-cov
pytest tests/ --doctest-modules --cov=MCP2221
```
Raw data
{
"_id": null,
"home_page": "https://github.com/pilotak/python-mcp2221",
"name": "mcp2221",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "MCP2221,MCP2221A,GPIO,ADC,DAC",
"author": "Pavel Slama",
"author_email": "info@pavelslama.cz",
"download_url": "https://files.pythonhosted.org/packages/06/61/6f652162588212fc8fd1a7aae9320b9133f1c773a0e1a6e50dc4c3310504/mcp2221-1.1.0.tar.gz",
"platform": null,
"description": "# Python driver for MCP2221/A\n[![Build](https://github.com/pilotak/python-mcp2221/actions/workflows/validate.yaml/badge.svg)](https://github.com/pilotak/python-mcp2221/actions/workflows/validate.yaml)\n[![PyPI](https://img.shields.io/pypi/v/mcp2221)](https://pypi.org/project/mcp2221/)\n\n## Examples\n\nRead GP0\n```python\nfrom MCP2221 import MCP2221\n\nmcp2221 = MCP2221.MCP2221()\nmcp2221.InitGP(0, MCP2221.TYPE.INPUT)\nprint(mcp2221.ReadGP(0))\n```\n\nWrite GP0\n```python\nfrom MCP2221 import MCP2221\n\nmcp2221 = MCP2221.MCP2221()\nmcp2221.InitGP(0, MCP2221.TYPE.OUTPUT)\nprint(mcp2221.WriteGP(0, 1))\n```\n\nRead ADC on GP1\n```python\nfrom MCP2221 import MCP2221\n\nmcp2221 = MCP2221.MCP2221()\nmcp2221.InitGP(1, MCP2221.TYPE.ADC)\nmcp2221.SetADCVoltageReference(MCP2221.VRM.VDD)\nprint(mcp2221.ReadADC(1))\n```\n\nWrite DAC on GP2\n```python\nfrom MCP2221 import MCP2221\n\nmcp2221 = MCP2221.MCP2221()\nmcp2221.InitGP(2, MCP2221.TYPE.DAC)\nmcp2221.SetDACVoltageReference(MCP2221.VRM.REF_2_048V)\nmcp2221.WriteDAC(12)\n```\n\n## Tests\n```sh\npip install pytest pytest-cov\npytest tests/ --doctest-modules --cov=MCP2221\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "Python driver for MCP2221/A",
"version": "1.1.0",
"project_urls": {
"Bug Tracker": "https://github.com/pilotak/python-mcp2221/issues",
"Homepage": "https://github.com/pilotak/python-mcp2221"
},
"split_keywords": [
"mcp2221",
"mcp2221a",
"gpio",
"adc",
"dac"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "47612cf8bbee6ebbf4575c69f611f0026d4a93a6c3af9881d808054029e08d36",
"md5": "b6bcd8d8686dd348ce51cf8fd8b6428d",
"sha256": "9bef9d946857c232ab7d30a1079c2bf9c092857a926bf31d658963c7e2ef03ab"
},
"downloads": -1,
"filename": "mcp2221-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b6bcd8d8686dd348ce51cf8fd8b6428d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 5393,
"upload_time": "2024-01-16T18:35:54",
"upload_time_iso_8601": "2024-01-16T18:35:54.364040Z",
"url": "https://files.pythonhosted.org/packages/47/61/2cf8bbee6ebbf4575c69f611f0026d4a93a6c3af9881d808054029e08d36/mcp2221-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "06616f652162588212fc8fd1a7aae9320b9133f1c773a0e1a6e50dc4c3310504",
"md5": "aa2c7b98fcbb013b88538bccfc794e63",
"sha256": "78d1be8c4396ebbfeb2bd66eb78e7fc69600af1e292e859891a42e60ab8b756d"
},
"downloads": -1,
"filename": "mcp2221-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "aa2c7b98fcbb013b88538bccfc794e63",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 5104,
"upload_time": "2024-01-16T18:35:55",
"upload_time_iso_8601": "2024-01-16T18:35:55.958006Z",
"url": "https://files.pythonhosted.org/packages/06/61/6f652162588212fc8fd1a7aae9320b9133f1c773a0e1a6e50dc4c3310504/mcp2221-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-16 18:35:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pilotak",
"github_project": "python-mcp2221",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "hidapi",
"specs": []
}
],
"lcname": "mcp2221"
}