- 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]>
This commit is contained in:
@@ -1,40 +1,83 @@
|
||||
# Receipt Maker
|
||||
|
||||
Prints random images from 4chan's /bant/ board to an Epson TM-T20II thermal receipt printer over Ethernet.
|
||||
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_recipt.sh` — configures the network interface and connects to the printer at `192.168.192.168:9100`
|
||||
2. `receipt.py` — CLI with subcommands to print random /bant/ images, text notes, or local images (resized to full printer width, 576px)
|
||||
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
|
||||
- `python-escpos`
|
||||
- `Pillow`
|
||||
- `requests`
|
||||
- `nmap` (for connection script)
|
||||
- Epson TM-T20II connected via USB-to-Ethernet adapter
|
||||
- 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/
|
||||
python receipt.py image
|
||||
# Print a random image from /bant/ (optionally more than one)
|
||||
./receipt.py image
|
||||
./receipt.py image 3
|
||||
|
||||
# Print a text note
|
||||
python receipt.py note "your message here"
|
||||
# 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)
|
||||
python receipt.py print path/to/image.jpg
|
||||
python receipt.py print path/to/image.jpg "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
|
||||
```
|
||||
|
||||
The script will run `connect_recipt.sh` automatically to bring up the network interface before printing.
|
||||
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
|
||||
- `connect_recipt.sh` — network setup for USB Ethernet adapter
|
||||
- `img/` — downloaded images cache
|
||||
- `img_fullwidth/` — resized images ready for printing
|
||||
- `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`)
|
||||
|
||||
Reference in New Issue
Block a user