diff --git a/README.md b/README.md index b609971..121258a 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Bridge zwischen der Canvas eines oder mehrerer **Elegoo Centauri Carbon 2** (Com | System | Zugriff | |---|---| | Drucker | **nur lesen**: `cat /opt/usr/canvas_record_info.json` per SSH. Kein MQTT, keine Druckerbefehle, keine Registrierung als MQTT-Client. | -| CC2 Control | Spulenverwaltung: `GET /api/spools`, `POST /api/spools/save`, `/assign`, `/enable` (nur nach Bestätigung) | +| CC2 Control | Spulenverwaltung: `GET /api/spools`, `POST /api/spools/save`, `/assign`, `/enable` (nur nach Bestätigung); während eines Drucks zusätzlich `GET /api/printer` (nur für Fortschritt und Restzeit in der Oberfläche) | | Spoolman | `GET /spool`, `PATCH /spool/{id}` (`location`), `PUT /spool/{id}/use` | **Dry-Run ist Standard.** Solange er aktiv ist, werden alle Schreibaktionen nur als „würde …“ protokolliert. @@ -70,6 +70,13 @@ Ein Update von v1 übernimmt Einstellungen, Zuordnungen, Buchungsstände und den Drucker heißt danach „CC2“ (Ort bleibt „CC2 Slot N“) und kann in den Einstellungen umbenannt werden – Ort und Felder in Spoolman ziehen dann mit. +### Am iPhone als Web-App + +`http://10.10.6.10:5066` in Safari öffnen → *Teilen* → **Zum Home-Bildschirm**. Die Bridge startet dann ohne +Safari-Leiste mit eigenem Icon. Unten liegen die Tabs Status, Protokoll, Tags und Einstellungen; auf *Status* +wechselt man oben zwischen den Druckern, ein Tipp auf einen Slot zeigt Details und die Aktionen. Hell/Dunkel folgt +der Systemeinstellung. Offline-Modus und Push-Mitteilungen gibt es nicht (dafür bräuchte es HTTPS). + ### Umgebungsvariablen Siehe [`.env.example`](.env.example). `PRINTER_HOST`, `SSH_PORT`, `SSH_USER`, `CC2_URL`, `SPOOLMAN_URL`, diff --git a/app/bridge.py b/app/bridge.py index 3ee5146..a1f1586 100644 --- a/app/bridge.py +++ b/app/bridge.py @@ -198,6 +198,7 @@ class PrinterWorker: self.tray_status: dict[int, int] = {} self.record: dict | None = None self.cc2_data: dict | None = None + self.print_info: dict | None = None # CC2 Control /api/printer, only read while a job runs @property def id(self) -> str: @@ -250,6 +251,12 @@ class PrinterWorker: self._error("cc2", None) except CC2Error as e: self._error("cc2", str(e)) + self.print_info = None + if self.cc2_data is not None and (self.cc2_data.get("job") or {}).get("active"): + try: + self.print_info = self.cc2.printer() + except CC2Error: + pass # progress is only shown in the UI; the spool list above is what counts if self.record is not None: self._process_record(self.record) self._process_scans() @@ -693,9 +700,31 @@ class PrinterWorker: "cc2_enabled": None if cc2 is None else bool(cc2.get("enabled")), "job_active": None if cc2 is None else bool((cc2.get("job") or {}).get("active")), "host_key": self.bridge.keys.host_key(self.id) is not None, + "job": self._job_summary(), "slots": slots, } + def _job_summary(self) -> dict | None: + job = (self.cc2_data or {}).get("job") or {} + if not job.get("active"): + return None + used = [s for s in job.get("slots") or [] if isinstance(s, dict)] + info = self.print_info or {} + pr, machine = info.get("print") or {}, info.get("machine") or {} + progress = machine.get("progress") + return { + "file": str(job.get("file") or pr.get("filename") or "").rsplit("/", 1)[-1], + "started": job.get("started"), + "grams": round(sum(_num(s.get("grams")) for s in used), 2), + "slots": [{"slot": i, "grams": round(_num(s.get("grams")), 2)} for i, s in enumerate(used) + if _num(s.get("grams")) > 0], + "progress": progress if isinstance(progress, (int, float)) else None, + "layer": pr.get("current_layer"), + "layers": pr.get("total_layers"), + "remaining": pr.get("remaining"), + "state": pr.get("state"), + } + class Bridge: def __init__(self, data_dir: Path, settings: SettingsStore, keys: KeyStore, *, diff --git a/app/static/icon-180.png b/app/static/icon-180.png new file mode 100644 index 0000000..0835714 Binary files /dev/null and b/app/static/icon-180.png differ diff --git a/app/static/icon-192.png b/app/static/icon-192.png new file mode 100644 index 0000000..c540ee9 Binary files /dev/null and b/app/static/icon-192.png differ diff --git a/app/static/icon-512.png b/app/static/icon-512.png new file mode 100644 index 0000000..3d8b215 Binary files /dev/null and b/app/static/icon-512.png differ diff --git a/app/static/icon.svg b/app/static/icon.svg new file mode 100644 index 0000000..51ed50d --- /dev/null +++ b/app/static/icon.svg @@ -0,0 +1 @@ + diff --git a/app/templates/base.html b/app/templates/base.html index ab8e2cf..6e04714 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -2,98 +2,223 @@ - + {% block title %}CC2 Bridge{% endblock %} + + + + + + + + + + + + + +{% block head %}{% endblock %} -
-

CC2 ↔ Spoolman

-