Add static editor, host_ports filtering, Flask /editor and REST APIs for ports and led-cli read/write; document standalone and embedded use. Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
3.2 KiB
Markdown
61 lines
3.2 KiB
Markdown
# led-tool
|
||
|
||
CLI helpers for MicroPython LED devices: **`settings.json`** download/upload via **mpremote**, resets, follow/tail, recursive uploads, optional firmware flash, and **led-driver**-oriented flags (presets, transport, Wi-Fi fields).
|
||
|
||
Connection is always via **`-p` / `--port`** (default `/dev/ttyACM0`). There is **no** separate “server IP” flag; the Pi or PC address is configured on the device in **`settings.json`** when using Wi-Fi mode.
|
||
|
||
## Common flags
|
||
|
||
| Flag | Purpose |
|
||
|------|--------|
|
||
| `-p`, `--port` | Serial device (default `/dev/ttyACM0`) |
|
||
| `-s`, `--show` | Print current settings from the device |
|
||
| `-n`, `--name` | Device **name** |
|
||
| `--reset-device-name` | Set **name** to firmware default (`led-` + STA MAC hex, same as `Settings.set_defaults` on led-driver) |
|
||
| `--id` | Numeric device id (ESP-NOW, 0–255) |
|
||
| `--pin` | LED GPIO (`led_pin`) |
|
||
| `-b`, `--brightness` | Brightness 0–255 |
|
||
| `-l`, `--leds` | LED count (`num_leds`) |
|
||
| `-d`, `--debug` | Debug 0 or 1 |
|
||
| `-o`, `--order` | LED colour order (`rgb`, `grb`, …) |
|
||
| `--preset` / `--pattern` | Create or replace a named preset in **led-driver** `presets.json` |
|
||
| `--default` | Startup preset name |
|
||
| `--transport` | `espnow` or `wifi` (`transport_type` on device) |
|
||
| `--ssid`, `--wifi-password`, `--wifi-channel` | Wi-Fi / channel fields for the driver |
|
||
| `-r`, `--reset` | Reset the device |
|
||
| `-f`, `--follow` | Follow serial output (optional timeout seconds) |
|
||
| `--pause` | Sleep N seconds (for chained actions) |
|
||
| `-u`, `--upload` | Recursive upload: `-u SRC [DEST]` (skips unchanged files via `file_hashes.json` on device) |
|
||
| `--src`, `--lib`, `--all` | Deploy led-driver trees to flash root, `patterns/`, and `lib/` |
|
||
| `--force-upload` | Upload every file; ignore `file_hashes.json` |
|
||
| `-e`, `--erase` | Erase everything at device root (including `settings.json` and `presets.json`) |
|
||
| `--rm` | Remove a path on the device |
|
||
| `--flash` | Flash a firmware binary (uses **esptool** on the host) |
|
||
|
||
**Settings I/O:** With no arguments, **`led-cli`** prints help (no device access). **`--show`** downloads `settings.json` and prints it (read-only). Setting fields (`--name`, `-b`, …) download once, merge, print, and **upload only when a value actually changed**. **`--preset`** alone only touches **`presets.json`** (no `settings.json` download). Ordered actions (`--reset`, `--upload`, `-e`, …) run without touching settings unless you also pass **`--show`** or setting / preset edits as above.
|
||
|
||
Run **`python cli.py -h`** for the full epilog and argument list.
|
||
|
||
## Web UI (`static/` + `web.py`)
|
||
|
||
Edit **`settings.json`** in the browser:
|
||
|
||
- **Web Serial** — USB on the machine running the browser (Chrome/Edge). Use **Connect USB**, then **Download** / **Upload**.
|
||
- **Host serial** — USB on the Pi/PC running **`led-cli`** (port list + **`led-cli`** merge/upload).
|
||
|
||
**Standalone (Flask):**
|
||
|
||
```bash
|
||
cd led-tool
|
||
python web.py
|
||
# open http://<host>:5000/editor
|
||
```
|
||
|
||
**Embedded in led-controller:** open **LED Tool** in the main UI, or visit **`/led-tool/editor`**.
|
||
|
||
Legacy Flask form UI remains at **`/`** on port 5000; prefer **`/editor`** for Web Serial support.
|
||
|
||
## License
|
||
|
||
See **LICENSE** in this directory.
|