Files
receipt_maker/README.md
T
adamfandClaude Fable 5 71686e8ad4
CI / test (push) Failing after 6m11s
Add tests, TUI, packaging, and CI
- receipt_tui.py: Textual terminal UI (tui subcommand), optional [tui] extra
- tests/: pytest suite for CLI and TUI using fakes; no hardware needed
- pyproject.toml: packaging with dev/tui extras, ruff config
- GitHub Actions CI running ruff and pytest
- Rename connect_recipt.sh -> connect_receipt.sh
- CLAUDE.md project instructions; README updates

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-11 19:53:18 +01:00

84 lines
2.7 KiB
Markdown

# Receipt Maker
Prints images, text notes, and QR codes to an Epson TM-T20II thermal receipt printer, including random images from 4chan's /bant/ board.
## How it works
1. `connect_receipt.sh` — brings up the USB Ethernet interface, assigns `192.168.192.10/24`, and waits until the printer at `192.168.192.168:9100` is reachable
2. `receipt.py` — CLI with subcommands; images are resized in memory to the printer's full 576px width before printing
The CLI runs the connect script automatically before printing (unless `--usb` is used).
## Requirements
- Python 3.10+
- `python-escpos`, `Pillow`, `requests` (see `pyproject.toml`)
- `textual` (optional, only for the `tui` subcommand; `pip install '.[tui]'`)
- Epson TM-T20II connected via a USB-to-Ethernet adapter (or directly over USB with `--usb`)
Install the dependencies (or `pip install .` to also get a `receipt` command on your PATH):
```bash
pip install python-escpos Pillow requests
```
## Usage
```bash
# Print a random image from /bant/ (optionally more than one)
./receipt.py image
./receipt.py image 3
# Print a text note (from an argument or stdin), word-wrapped to 48 columns
./receipt.py note "your message here"
fortune | ./receipt.py note
./receipt.py note -t "with a date/time header"
# Print a local image (with optional caption)
./receipt.py print path/to/image.jpg
./receipt.py print path/to/image.jpg "optional caption"
# Print a QR code (with optional caption)
./receipt.py qr "https://example.com" "scan me"
# Reprint a cached image (most recent, or by name from `list`)
./receipt.py reprint
./receipt.py reprint 1783716801701399
# Check the printer is reachable
./receipt.py status
# List or delete the downloaded image cache
./receipt.py list
./receipt.py clean
# Open the interactive terminal UI (needs `pip install textual`)
./receipt.py tui
# Use a direct USB connection instead of Ethernet
./receipt.py --usb note "hello"
# Point at a different printer (or set RECEIPT_PRINTER_IP / RECEIPT_PRINTER_PORT)
./receipt.py --ip 10.0.0.5 --port 9100 status
```
Images are prepared for thermal output automatically: transparency is composited onto white, then the image is resized to full width, autocontrast-stretched, and Floyd-Steinberg dithered.
## Development
```bash
pip install -e '.[dev]'
pytest # run the tests
ruff check . # lint
```
Both checks also run in CI on every push and pull request (`.github/workflows/ci.yml`).
## Files
- `receipt.py` — main script
- `receipt_tui.py` — Textual terminal UI (`./receipt.py tui`)
- `connect_receipt.sh` — network setup for the USB Ethernet adapter
- `tests/` — pytest suite for the CLI and TUI (no printer or network needed)
- `img/` — downloaded images cache (gitignored; clear with `./receipt.py clean`)