Skip to content

Commit 9be73b2

Browse files
authored
Improve docs, add mkdocs & readthedocs config (#32)
* Improve docs and fix formatting * Add mkdocs documentation * Add readthedocs config
1 parent 1172d16 commit 9be73b2

File tree

12 files changed

+172
-24
lines changed

12 files changed

+172
-24
lines changed

.readthedocs.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
# Required
5+
version: 2
6+
7+
# Set the OS, Python version, and other tools you might need
8+
build:
9+
os: ubuntu-24.04
10+
tools:
11+
python: "3.13"
12+
13+
mkdocs:
14+
configuration: mkdocs.yml
15+
fail_on_warning: false
16+
17+
python:
18+
install:
19+
- method: pip
20+
path: .
21+
extra_requirements:
22+
- docs

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,25 @@ $(VENV)/.timestamp-dev: $(VENV)/bin/activate pyproject.toml
4141
$(PIP) install -e ".[dev]"
4242
touch $@
4343

44+
# Install package with docs dependencies
45+
$(VENV)/.timestamp-docs: $(VENV)/bin/activate pyproject.toml
46+
$(PIP) install -e ".[docs]"
47+
touch $@
48+
4449
.PHONY: install-dev
4550
install-dev: $(VENV)/.timestamp-dev
4651

52+
.PHONY: install-docs
53+
install-dev: $(VENV)/.timestamp-docs
54+
4755
.PHONY: test
4856
test: install-dev
4957
$(PYTEST)
5058

59+
.PHONY: docs
60+
docs: install-docs
61+
mkdocs build
62+
5163
.PHONY: lint
5264
lint: install-dev
5365
$(RUFF) check src/ tests/
@@ -66,6 +78,7 @@ clean:
6678
rm -rf $(VENV)
6779
rm -rf build/
6880
rm -rf dist/
81+
rm -rf site/
6982
rm -rf *.egg-info
7083
rm -rf .pytest_cache
7184
rm -rf .ruff_cache

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ Frontend module and a Raspberry Pi Pico (Zero).
2222
- Python library for easy integration.
2323
- Uses USB serial communication to the reader.
2424
- Cross-platform support (Linux, Windows, macOS).
25-
- Finds and selects single ISO/IEC 14443 cards.
26-
- Uses NFC FORUM commands to read/write 14443-A cards' memories.
25+
- Finds and selects ISO/IEC 14443A and ISO/IEC 15693 cards.
26+
- Can read/write the cards' memories.
2727
- Can authenticate against Mifare classic cards to read their memories.
28-
- Finds ISO/IEC 15693 cards, uses 15693-3 commands to read/write their memories.
28+
- Supports multiple cards within the field.
2929

30-
Multiple cards can be detected within the field.
30+
## API Documentation
31+
32+
See [API Reference](https://pn5180-tagomatic.readthedocs.io/en/latest/).
3133

3234
## Installation
3335

REUSE.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ SPDX-FileCopyrightText = "2026 PN5180-tagomatic contributors"
1313
SPDX-License-Identifier = "GPL-3.0-or-later"
1414

1515
[[annotations]]
16-
path = [".gitignore", ".clang-format"]
16+
path = [
17+
".gitignore",
18+
".clang-format",
19+
".readthedocs.yaml",
20+
"docs/reference.md"
21+
]
1722
precedence = "aggregate"
1823
SPDX-FileCopyrightText = "2026 PN5180-tagomatic contributors"
1924
SPDX-License-Identifier = "CC0-1.0"

docs/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2026 PN5180-tagomatic contributors
3+
SPDX-License-Identifier: GPL-3.0-or-later
4+
-->
5+
6+
# PN5180 Tagomatic
7+
A USB connected RFID Reader/Writer with a python interface.
8+
9+
---
10+
11+
A PN5180 card is connected to a Raspberry Pi Pico Zero via SPI.
12+
The Pico Zero runs an arduino firmware which exposes a SimpleRPC
13+
interface which this python module uses via USB to communicate
14+
with RFID tags.
15+
16+
## Features
17+
18+
- Python library for easy integration.
19+
- Uses USB serial communication to the reader.
20+
- Cross-platform support (Linux, Windows, macOS).
21+
- Finds and selects ISO/IEC 14443A and ISO/IEC 15693 cards.
22+
- Can read/write the cards' memories.
23+
- Can authenticate against Mifare classic cards to read their memories.
24+
- Supports multiple cards within the field.
25+
26+
## API Documentation
27+
28+
See [API Reference](reference.md).
29+
30+
## Installation
31+
32+
### Python Package
33+
34+
Install from PyPI:
35+
36+
```bash
37+
pip install pn5180-tagomatic
38+
```
39+
40+
### Building the hardware
41+
42+
See
43+
[here](https://github.com/bofh69/pn5180-tagomatic/tree/main/sketch/README.md)
44+
for instructions on the hardware and the firmware.
45+
46+
## Usage
47+
48+
```python
49+
from pn5180_tagomatic import PN5180, RxProtocol, TxProtocol
50+
51+
# Create reader instance and use it
52+
with PN5180("/dev/ttyACM0") as reader:
53+
versions = reader.ll.read_eeprom(0x10, 6)
54+
with reader.start_session(
55+
TxProtocol.ISO_14443_A_106, RxProtocol.ISO_14443_A_106
56+
) as session:
57+
card = session.connect_one_iso14443a()
58+
print(f"Reading from card {card.id}")
59+
memory = card.read_memory()
60+
```
61+
62+
## License
63+
64+
This project is licensed under the GNU General Public License v3.0 or later (GPL-3.0-or-later).
65+
66+
## Contributing
67+
68+
Contributions are welcome!
69+
70+
## Acknowledgments
71+
72+
This project uses FastLED by Daniel Garcia et al.
73+
74+
SimpleRPC by Jeroen F.J. Laros, Chris Flesher et al is also used.

docs/reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: src.pn5180_tagomatic

mkdocs.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-FileCopyrightText: 2026 PN5180-tagomatic contributors
2+
# SPDX-License-Identifier: CC0-1.0
3+
4+
site_name: PN5180 Tagomatic
5+
repo_url: https://github.com/bofh69/pn5180-tagomatic
6+
7+
theme:
8+
name: "material"
9+
palette:
10+
scheme: slate
11+
12+
plugins:
13+
- search
14+
- mkdocstrings
15+
16+
nav:
17+
- Home: 'README.md'
18+
- API Reference: 'reference.md'

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ dev = [
5151
"types-pyserial>=3.5.0",
5252
]
5353

54+
docs = [
55+
"mkdocs>=1.6.1",
56+
"mkdocs-material>=9.7.1",
57+
"mkdocs-material-extensions>=1.3.1",
58+
"mkdocstrings-python>=2.0.1",
59+
]
60+
5461
[project.urls]
5562
Homepage = "https://github.com/bofh69/PN5180-tagomatic"
5663
Repository = "https://github.com/bofh69/PN5180-tagomatic"

src/pn5180_tagomatic/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: 2026 PN5180-tagomatic contributors
22
# SPDX-License-Identifier: GPL-3.0-or-later
33

4-
"""PN5180-tagomatic: USB based RFID reader with Python interface."""
4+
"""PN5180-tagomatic: USB connected RFID reader with Python interface."""
55

66
from .cards import (
77
Card,

src/pn5180_tagomatic/pn5180.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,21 @@ class PN5180:
2727
Attributes:
2828
ll: Low-level PN5180 interface for direct hardware access.
2929
30-
Example:
31-
>>> from pn5180_tagomatic import PN5180
30+
Examples:
31+
>>> from pn5180_tagomatic import *
3232
>>> with PN5180("/dev/ttyACM0") as reader:
33-
... # High-level API (recommended)
34-
... with reader.start_session(0x00, 0x80) as comm:
35-
... card = comm.connect_one_iso14443a()
36-
... memory = card.read_memory()
33+
... # High-level API
34+
... with reader.start_session(
35+
... TxProtocol.ISO_14443_A_106, RxProtocol.ISO_14443_A_106
36+
... ) as comm:
37+
... card: Card = comm.connect_one_iso14443a()
38+
... print(f"Found card: {card.id}")
39+
... memory: bytes = card.read_memory()
3740
...
38-
... # Low-level access if needed
39-
... reader.ll.write_register(addr, value)
41+
... # Low-level access, when needed
42+
... data: bytes = reader.ll.read_eeprom(0x12, 2)
43+
... print("Read from EEPROM")
44+
... print(f"Firmware version: {data[1]}.{data[0]}")
4045
"""
4146

4247
def __init__(self, tty: str) -> None:
@@ -66,11 +71,11 @@ def start_session(
6671
Raises:
6772
PN5180Error: If the operation fails.
6873
69-
Example:
74+
Examples:
7075
>>> reader = PN5180("/dev/ttyACM0")
7176
>>> with reader.start_session(0x00, 0x80) as comm:
7277
... card = comm.connect_one_iso14443a()
73-
... uid = card.uid
78+
... uid = card.id.uid_as_bytes()
7479
... memory = card.read_memory()
7580
"""
7681
self.ll.load_rf_config(tx_config, rx_config)

0 commit comments

Comments
 (0)