add text to hpgl tab

This commit is contained in:
Lukas Cremer
2026-02-03 23:26:44 +01:00
parent cd846577a4
commit 82e5ef4b73
7 changed files with 399 additions and 36 deletions

View File

@@ -2,26 +2,15 @@
Flask web interface for uploading HPGL files, previewing and transforming them (flip, rotate, scale, center), and sending to the plotter. Intended to run on a Raspberry Pi connected to the plotter via USB.
## Setup (Raspberry Pi)
## Setup (Raspberry Pi / Linux Mint / Debian)
1. From the **project root** (mimaki/), install dependencies:
From the **project root** (mimaki/), install dependencies. On Debian-based systems Python is externally managed (PEP 668), so use:
If you get **externally-managed-environment** (Python 3.11+ / PEP 668) and dont want a venv, use:
```bash
pip install --break-system-packages -r webui/requirements.txt
```
Otherwise:
```bash
pip install -r webui/requirements.txt
```
Optional use a venv to avoid touching system Python:
```bash
python3 -m venv venv
source venv/bin/activate
pip install -r webui/requirements.txt
```
```bash
pip install --break-system-packages -r webui/requirements.txt
```
2. **Config:** Copy `config.example.ini` to `config.ini` and adjust (port, baudrate, web UI host/port, etc.). `config.ini` is gitignored.
Then copy `config.example.ini` to `config.ini` and set the plotter port etc. (optional).
```bash
cp config.example.ini config.ini
```
@@ -35,25 +24,24 @@ From the **project root** (mimaki/):
python webui/app.py
```
Then open http://<raspi-ip>:5000 in a browser (e.g. http://192.168.1.10:5000).
Then open http://localhost:5000 (or http://<raspi-ip>:5000 from another device). Host is `0.0.0.0`, port 5000 (see `config.ini`).
- **Host:** `0.0.0.0` so other devices on the network can connect.
- **Port:** 5000 (override with `PORT=8080 python webui/app.py` if needed).
For production, run behind gunicorn and optionally a reverse proxy:
```bash
pip install --break-system-packages gunicorn # or omit if not using system Python
gunicorn -w 1 -b 0.0.0.0:5000 "webui.app:app"
```
For production with gunicorn: `pip install --break-system-packages gunicorn` then `gunicorn -w 1 -b 0.0.0.0:5000 "webui.app:app"`.
## Usage
**File tab**
1. **Upload** Choose an `.hpgl` or `.plt` file. It is validated and stored in `webui/uploads/`.
2. **Preview** The drawing is converted to SVG and shown in the browser.
3. **Transform** Flip, Rotate 90° / 180°, Scale + / , Center. Each action updates the stored program and the preview.
3. **Transform** Flip, Rotate 90° / 180°, Scale + / , Center, Scale to bounds. Each action updates the stored program and the preview.
4. **Print** Sends the current (transformed) program to the plotter: scale to fit, center, then write HPGL to serial.
**Text tab**
1. Type text, select a font (from `font/` or `.git/font/`, e.g. `Melange-Bold.otf`), set size (pt), then **Generate HPGL**.
2. The generated HPGL becomes the current program; use the same **Preview**, **Transform**, and **Print** as in the File tab.
Fonts: put `.otf` or `.ttf` files in the project `font/` folder (or they are read from `.git/font/` if present). The Text tab requires **matplotlib** (`pip install matplotlib`).
## API
- `POST /api/upload` Upload HPGL file (form field `file`).