bussdcc-hardware 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bussdcc_hardware-0.1.0/.github/workflows/workflow.yml +62 -0
- bussdcc_hardware-0.1.0/.gitignore +209 -0
- bussdcc_hardware-0.1.0/CHANGELOG.md +14 -0
- bussdcc_hardware-0.1.0/LICENSE +21 -0
- bussdcc_hardware-0.1.0/Makefile +44 -0
- bussdcc_hardware-0.1.0/PKG-INFO +40 -0
- bussdcc_hardware-0.1.0/README.md +9 -0
- bussdcc_hardware-0.1.0/pyproject.toml +53 -0
- bussdcc_hardware-0.1.0/setup.cfg +4 -0
- bussdcc_hardware-0.1.0/src/bussdcc_hardware/__init__.py +5 -0
- bussdcc_hardware-0.1.0/src/bussdcc_hardware/i2c_bus/__init__.py +44 -0
- bussdcc_hardware-0.1.0/src/bussdcc_hardware/message/__init__.py +0 -0
- bussdcc_hardware-0.1.0/src/bussdcc_hardware/nau7802/__init__.py +85 -0
- bussdcc_hardware-0.1.0/src/bussdcc_hardware/py.typed +0 -0
- bussdcc_hardware-0.1.0/src/bussdcc_hardware/version.py +14 -0
- bussdcc_hardware-0.1.0/src/bussdcc_hardware.egg-info/PKG-INFO +40 -0
- bussdcc_hardware-0.1.0/src/bussdcc_hardware.egg-info/SOURCES.txt +18 -0
- bussdcc_hardware-0.1.0/src/bussdcc_hardware.egg-info/dependency_links.txt +1 -0
- bussdcc_hardware-0.1.0/src/bussdcc_hardware.egg-info/requires.txt +4 -0
- bussdcc_hardware-0.1.0/src/bussdcc_hardware.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
name: Github Actions Workflow
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
jobs:
|
|
6
|
+
check:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- name: Checkout code
|
|
10
|
+
uses: actions/checkout@v4
|
|
11
|
+
- name: Set up Python
|
|
12
|
+
uses: actions/setup-python@v5
|
|
13
|
+
with:
|
|
14
|
+
python-version: "3.13"
|
|
15
|
+
- name: make setup
|
|
16
|
+
run: make setup
|
|
17
|
+
- name: make check
|
|
18
|
+
run: make check
|
|
19
|
+
release-please:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
needs: check
|
|
22
|
+
if: github.ref == 'refs/heads/master'
|
|
23
|
+
permissions:
|
|
24
|
+
contents: write
|
|
25
|
+
issues: write
|
|
26
|
+
pull-requests: write
|
|
27
|
+
steps:
|
|
28
|
+
- name: release-please
|
|
29
|
+
id: release-please
|
|
30
|
+
uses: googleapis/release-please-action@v4
|
|
31
|
+
with:
|
|
32
|
+
release-type: python
|
|
33
|
+
outputs:
|
|
34
|
+
release_created: ${{ steps.release-please.outputs.release_created }}
|
|
35
|
+
tag_name: ${{ steps.release-please.outputs.tag_name }}
|
|
36
|
+
publish:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
needs: release-please
|
|
39
|
+
if: needs.release-please.outputs.release_created
|
|
40
|
+
environment: pypi
|
|
41
|
+
permissions:
|
|
42
|
+
contents: write
|
|
43
|
+
id-token: write
|
|
44
|
+
steps:
|
|
45
|
+
- name: Checkout code
|
|
46
|
+
uses: actions/checkout@v4
|
|
47
|
+
with:
|
|
48
|
+
ref: ${{ needs.release-please.outputs.tag_name }}
|
|
49
|
+
- name: Set up Python
|
|
50
|
+
uses: actions/setup-python@v5
|
|
51
|
+
with:
|
|
52
|
+
python-version: "3.12"
|
|
53
|
+
- name: make build
|
|
54
|
+
run: make build
|
|
55
|
+
- name: make build-check
|
|
56
|
+
run: make build-check
|
|
57
|
+
- name: Publish to GitHub Releases
|
|
58
|
+
env:
|
|
59
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
60
|
+
run: gh release upload ${{ needs.release-please.outputs.tag_name }} dist/*
|
|
61
|
+
- name: Publish to PyPI
|
|
62
|
+
run: make publish
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
|
|
209
|
+
/data/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (2026-03-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **i2c:** add I2CBus and NAU7802 device support ([12c78df](https://github.com/jbussdieker/bussdcc-hardware/commit/12c78dfcf0d715f4c2cc5aee57e03df285483f5a))
|
|
9
|
+
* initial commit ([01b3136](https://github.com/jbussdieker/bussdcc-hardware/commit/01b313647497bffa5c14babe7bb0801c9d082cf0))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Documentation
|
|
13
|
+
|
|
14
|
+
* **readme:** expand README with project concepts ([ee73fc1](https://github.com/jbussdieker/bussdcc-hardware/commit/ee73fc17cbfd46a17021e3678108df9681922541))
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Joshua B. Bussdieker
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.PHONY: setup check typecheck lint format clean
|
|
2
|
+
|
|
3
|
+
setup: .venv/bin/python
|
|
4
|
+
.venv/bin/python -m pip install -e .[dev,nau7802]
|
|
5
|
+
check: typecheck lint
|
|
6
|
+
typecheck: .venv/bin/mypy
|
|
7
|
+
.venv/bin/mypy --strict src
|
|
8
|
+
lint: .venv/bin/black
|
|
9
|
+
.venv/bin/black --check .
|
|
10
|
+
format: .venv/bin/black
|
|
11
|
+
.venv/bin/black .
|
|
12
|
+
build: .venv/bin/build
|
|
13
|
+
.venv/bin/python -m build .
|
|
14
|
+
build-check: .venv/bin/twine
|
|
15
|
+
.venv/bin/twine check dist/*
|
|
16
|
+
publish-testpypi: .venv/bin/twine
|
|
17
|
+
.venv/bin/twine upload --repository testpypi dist/*
|
|
18
|
+
publish: .venv/bin/twine
|
|
19
|
+
.venv/bin/twine upload dist/*
|
|
20
|
+
clean:
|
|
21
|
+
rm -rf dist build .venv
|
|
22
|
+
.venv/bin/mypy: .venv/bin/python
|
|
23
|
+
.venv/bin/pip install mypy
|
|
24
|
+
.venv/bin/build: .venv/bin/python
|
|
25
|
+
.venv/bin/pip install build
|
|
26
|
+
.venv/bin/black: .venv/bin/python
|
|
27
|
+
.venv/bin/pip install black
|
|
28
|
+
.venv/bin/twine: .venv/bin/python
|
|
29
|
+
.venv/bin/pip install twine
|
|
30
|
+
.venv/bin/python:
|
|
31
|
+
python3 -m venv --system-site-packages .venv
|
|
32
|
+
context:
|
|
33
|
+
@echo "# README.md"
|
|
34
|
+
@cat README.md
|
|
35
|
+
@echo ""
|
|
36
|
+
@echo ""
|
|
37
|
+
@echo "# pyproject.toml"
|
|
38
|
+
@cat pyproject.toml
|
|
39
|
+
@echo ""
|
|
40
|
+
@echo ""
|
|
41
|
+
@for f in $$(find src -type f -name "*.html"); do echo "# $$f"; cat $$f; echo; echo; done
|
|
42
|
+
@echo ""
|
|
43
|
+
@echo ""
|
|
44
|
+
@for f in $$(find src -type f -name "*.py"); do echo "# $$f"; cat $$f; echo; echo; done
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bussdcc-hardware
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Hardware device integrations for the BussDCC cybernetic runtime
|
|
5
|
+
Author-email: "Joshua B. Bussdieker" <jbussdieker@gmail.com>
|
|
6
|
+
Maintainer-email: "Joshua B. Bussdieker" <jbussdieker@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/jbussdieker/bussdcc-hardware
|
|
9
|
+
Project-URL: Documentation, https://github.com/jbussdieker/bussdcc-hardware/blob/main/README.md
|
|
10
|
+
Project-URL: Repository, https://github.com/jbussdieker/bussdcc-hardware
|
|
11
|
+
Project-URL: Issues, https://github.com/jbussdieker/bussdcc-hardware/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/jbussdieker/bussdcc-hardware/blob/main/CHANGELOG.md
|
|
13
|
+
Keywords: hardware
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
15
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Environment :: Console
|
|
21
|
+
Classifier: Intended Audience :: Developers
|
|
22
|
+
Classifier: Natural Language :: English
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: bussdcc==0.26.0
|
|
28
|
+
Provides-Extra: nau7802
|
|
29
|
+
Requires-Dist: nau7802[i2c]==0.5.4; extra == "nau7802"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# BussDCC Hardware
|
|
33
|
+
|
|
34
|
+
Hardware integrations for BussDCC.
|
|
35
|
+
|
|
36
|
+
## Concepts
|
|
37
|
+
|
|
38
|
+
- Bus devices (I2C, SPI, etc.)
|
|
39
|
+
- Hardware devices (ADC, sensors)
|
|
40
|
+
- Runtime-managed lifecycle
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "bussdcc-hardware"
|
|
3
|
+
dynamic = [
|
|
4
|
+
"version",
|
|
5
|
+
]
|
|
6
|
+
dependencies = [
|
|
7
|
+
"bussdcc==0.26.0",
|
|
8
|
+
]
|
|
9
|
+
description = "Hardware device integrations for the BussDCC cybernetic runtime"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Joshua B. Bussdieker", email = "jbussdieker@gmail.com" },
|
|
14
|
+
]
|
|
15
|
+
maintainers = [
|
|
16
|
+
{ name = "Joshua B. Bussdieker", email = "jbussdieker@gmail.com" },
|
|
17
|
+
]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
20
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
"Environment :: Console",
|
|
26
|
+
"Intended Audience :: Developers",
|
|
27
|
+
"Natural Language :: English",
|
|
28
|
+
"Typing :: Typed",
|
|
29
|
+
]
|
|
30
|
+
keywords = [
|
|
31
|
+
"hardware",
|
|
32
|
+
]
|
|
33
|
+
license = "MIT"
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
nau7802 = ["nau7802[i2c]==0.5.4"]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/jbussdieker/bussdcc-hardware"
|
|
40
|
+
Documentation = "https://github.com/jbussdieker/bussdcc-hardware/blob/main/README.md"
|
|
41
|
+
Repository = "https://github.com/jbussdieker/bussdcc-hardware"
|
|
42
|
+
Issues = "https://github.com/jbussdieker/bussdcc-hardware/issues"
|
|
43
|
+
Changelog = "https://github.com/jbussdieker/bussdcc-hardware/blob/main/CHANGELOG.md"
|
|
44
|
+
|
|
45
|
+
[build-system]
|
|
46
|
+
requires = [
|
|
47
|
+
"setuptools",
|
|
48
|
+
"setuptools-scm",
|
|
49
|
+
]
|
|
50
|
+
build-backend = "setuptools.build_meta"
|
|
51
|
+
|
|
52
|
+
[tool.setuptools_scm]
|
|
53
|
+
fallback_version = "0.0.0"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from typing import Iterable, cast
|
|
2
|
+
import smbus2
|
|
3
|
+
|
|
4
|
+
from nau7802.protocol import BusProtocol
|
|
5
|
+
|
|
6
|
+
from bussdcc.device import Device
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class I2CBus(Device):
|
|
10
|
+
kind = "bus"
|
|
11
|
+
|
|
12
|
+
def __init__(self, *, id: str, bus: int = 1):
|
|
13
|
+
self.bus_num = bus
|
|
14
|
+
self._bus: smbus2.SMBus | None = None
|
|
15
|
+
super().__init__(id=id)
|
|
16
|
+
|
|
17
|
+
def connect(self) -> None:
|
|
18
|
+
self._bus = smbus2.SMBus(self.bus_num)
|
|
19
|
+
|
|
20
|
+
def disconnect(self) -> None:
|
|
21
|
+
if self._bus:
|
|
22
|
+
self._bus.close()
|
|
23
|
+
self._bus = None
|
|
24
|
+
|
|
25
|
+
def protocol(self) -> BusProtocol | None:
|
|
26
|
+
if not self._bus:
|
|
27
|
+
return None
|
|
28
|
+
|
|
29
|
+
return cast(BusProtocol, self._bus)
|
|
30
|
+
|
|
31
|
+
def discover(self) -> Iterable[int]:
|
|
32
|
+
if not self._bus:
|
|
33
|
+
return []
|
|
34
|
+
|
|
35
|
+
found = []
|
|
36
|
+
for addr in range(0x03, 0x78):
|
|
37
|
+
try:
|
|
38
|
+
# Read a single byte without specifying a register
|
|
39
|
+
msg = smbus2.i2c_msg.read(addr, 1)
|
|
40
|
+
self._bus.i2c_rdwr(msg)
|
|
41
|
+
found.append(addr)
|
|
42
|
+
except OSError:
|
|
43
|
+
pass
|
|
44
|
+
return found
|
|
File without changes
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from typing import cast, Literal
|
|
2
|
+
import threading
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
from bussdcc.device import Device
|
|
6
|
+
from bussdcc.message import DeviceFailed
|
|
7
|
+
from nau7802 import NAU7802 as _NAU7802
|
|
8
|
+
from nau7802.protocol import BusProtocol
|
|
9
|
+
|
|
10
|
+
from ..i2c_bus import I2CBus
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class NAU7802(Device):
|
|
14
|
+
kind = "adc"
|
|
15
|
+
|
|
16
|
+
def __init__(self, *, id: str, bus_id: str, addr: int = 0x2A):
|
|
17
|
+
super().__init__(id=id)
|
|
18
|
+
self.bus_id = bus_id
|
|
19
|
+
self.addr = addr
|
|
20
|
+
self._current_channel: int | None = None
|
|
21
|
+
self._lock = threading.Lock()
|
|
22
|
+
|
|
23
|
+
def connect(self) -> None:
|
|
24
|
+
if not self.ctx:
|
|
25
|
+
raise RuntimeError("Device not attached")
|
|
26
|
+
|
|
27
|
+
runtime = self.ctx.runtime
|
|
28
|
+
bus = runtime.get_device(self.bus_id)
|
|
29
|
+
|
|
30
|
+
if not isinstance(bus, I2CBus):
|
|
31
|
+
raise RuntimeError("NAU7802 requires an I2CBus")
|
|
32
|
+
|
|
33
|
+
self.bus: I2CBus = bus
|
|
34
|
+
|
|
35
|
+
protocol: BusProtocol | None = bus.protocol()
|
|
36
|
+
|
|
37
|
+
if protocol:
|
|
38
|
+
self.device = _NAU7802(protocol, self.addr)
|
|
39
|
+
|
|
40
|
+
with self._lock:
|
|
41
|
+
self.device.initialize()
|
|
42
|
+
self.device.set_crs(3)
|
|
43
|
+
self.device.set_gain(7)
|
|
44
|
+
|
|
45
|
+
def disconnect(self) -> None:
|
|
46
|
+
pass
|
|
47
|
+
|
|
48
|
+
def _wait_ready(self) -> bool:
|
|
49
|
+
if not self.ctx:
|
|
50
|
+
return False
|
|
51
|
+
|
|
52
|
+
timeout = self.ctx.clock.monotonic() + 0.15 # at a minimum we expect 10 SPS
|
|
53
|
+
while not self.device.cycle_ready:
|
|
54
|
+
self.ctx.clock.sleep(0.001)
|
|
55
|
+
if self.ctx.clock.monotonic() > timeout:
|
|
56
|
+
return False
|
|
57
|
+
return True
|
|
58
|
+
|
|
59
|
+
def _switch_channel(self, channel: Literal[1, 2]) -> None:
|
|
60
|
+
if not self.ctx:
|
|
61
|
+
return
|
|
62
|
+
if self._current_channel == channel:
|
|
63
|
+
return
|
|
64
|
+
|
|
65
|
+
self.device.set_channel(channel)
|
|
66
|
+
|
|
67
|
+
# Discard 10 samples after changing channels
|
|
68
|
+
for n in range(1, 10):
|
|
69
|
+
if not self._wait_ready():
|
|
70
|
+
self.ctx.emit(
|
|
71
|
+
DeviceFailed(
|
|
72
|
+
device=self.id,
|
|
73
|
+
kind=self.kind,
|
|
74
|
+
error="timeout changing channels",
|
|
75
|
+
)
|
|
76
|
+
)
|
|
77
|
+
self.device.adco
|
|
78
|
+
|
|
79
|
+
self._current_channel = channel
|
|
80
|
+
|
|
81
|
+
def read(self, channel: Literal[1, 2]) -> int:
|
|
82
|
+
self._switch_channel(channel)
|
|
83
|
+
|
|
84
|
+
with self._lock:
|
|
85
|
+
return self.device.adco.value
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
2
|
+
|
|
3
|
+
PACKAGE_NAME = "bussdcc-hardware"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def get_version() -> str:
|
|
7
|
+
try:
|
|
8
|
+
return version(PACKAGE_NAME)
|
|
9
|
+
except PackageNotFoundError:
|
|
10
|
+
return "0.0.0"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
__name__ = PACKAGE_NAME
|
|
14
|
+
__version__ = get_version()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bussdcc-hardware
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Hardware device integrations for the BussDCC cybernetic runtime
|
|
5
|
+
Author-email: "Joshua B. Bussdieker" <jbussdieker@gmail.com>
|
|
6
|
+
Maintainer-email: "Joshua B. Bussdieker" <jbussdieker@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/jbussdieker/bussdcc-hardware
|
|
9
|
+
Project-URL: Documentation, https://github.com/jbussdieker/bussdcc-hardware/blob/main/README.md
|
|
10
|
+
Project-URL: Repository, https://github.com/jbussdieker/bussdcc-hardware
|
|
11
|
+
Project-URL: Issues, https://github.com/jbussdieker/bussdcc-hardware/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/jbussdieker/bussdcc-hardware/blob/main/CHANGELOG.md
|
|
13
|
+
Keywords: hardware
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
15
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Environment :: Console
|
|
21
|
+
Classifier: Intended Audience :: Developers
|
|
22
|
+
Classifier: Natural Language :: English
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: bussdcc==0.26.0
|
|
28
|
+
Provides-Extra: nau7802
|
|
29
|
+
Requires-Dist: nau7802[i2c]==0.5.4; extra == "nau7802"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# BussDCC Hardware
|
|
33
|
+
|
|
34
|
+
Hardware integrations for BussDCC.
|
|
35
|
+
|
|
36
|
+
## Concepts
|
|
37
|
+
|
|
38
|
+
- Bus devices (I2C, SPI, etc.)
|
|
39
|
+
- Hardware devices (ADC, sensors)
|
|
40
|
+
- Runtime-managed lifecycle
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.gitignore
|
|
2
|
+
CHANGELOG.md
|
|
3
|
+
LICENSE
|
|
4
|
+
Makefile
|
|
5
|
+
README.md
|
|
6
|
+
pyproject.toml
|
|
7
|
+
.github/workflows/workflow.yml
|
|
8
|
+
src/bussdcc_hardware/__init__.py
|
|
9
|
+
src/bussdcc_hardware/py.typed
|
|
10
|
+
src/bussdcc_hardware/version.py
|
|
11
|
+
src/bussdcc_hardware.egg-info/PKG-INFO
|
|
12
|
+
src/bussdcc_hardware.egg-info/SOURCES.txt
|
|
13
|
+
src/bussdcc_hardware.egg-info/dependency_links.txt
|
|
14
|
+
src/bussdcc_hardware.egg-info/requires.txt
|
|
15
|
+
src/bussdcc_hardware.egg-info/top_level.txt
|
|
16
|
+
src/bussdcc_hardware/i2c_bus/__init__.py
|
|
17
|
+
src/bussdcc_hardware/message/__init__.py
|
|
18
|
+
src/bussdcc_hardware/nau7802/__init__.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bussdcc_hardware
|