{"id":51017229,"url":"https://github.com/lostbean/blau_drill","last_synced_at":"2026-06-21T12:01:55.544Z","repository":{"id":365814254,"uuid":"1273893855","full_name":"lostbean/blau_drill","owner":"lostbean","description":"Phoenix LiveView app that drives a modified 3D printer to drill PCBs — fits a board→machine affine transform from fiducials, then streams Marlin G-code dry-run-first, with the safety invariants enforced in types and a state machine.","archived":false,"fork":false,"pushed_at":"2026-06-19T02:08:36.000Z","size":1966,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-19T03:15:38.282Z","etag":null,"topics":["cnc","elixir","gcode","liveview","marlin","pcb","phoenix","svelte"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lostbean.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-19T01:28:07.000Z","updated_at":"2026-06-19T02:08:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lostbean/blau_drill","commit_stats":null,"previous_names":["lostbean/blau_drill"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/lostbean/blau_drill","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostbean%2Fblau_drill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostbean%2Fblau_drill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostbean%2Fblau_drill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostbean%2Fblau_drill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lostbean","download_url":"https://codeload.github.com/lostbean/blau_drill/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostbean%2Fblau_drill/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34608902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cnc","elixir","gcode","liveview","marlin","pcb","phoenix","svelte"],"created_at":"2026-06-21T12:01:54.329Z","updated_at":"2026-06-21T12:01:55.504Z","avatar_url":"https://github.com/lostbean.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# blau-drill (pure-browser app)\n\n**blau-drill** controls a modified 3D printer for precision **PCB drilling** via a\nstrictly linear five-stage workflow — **Load \u0026 Connect → Physical Alignment →\nDry-run → Active Drilling → Completion** — with safety gates that lock motion and\ndrilling behind explicit toggles.\n\nThis is the **pure-browser rewrite**: a [Lustre](https://lustre.build) SPA\ncompiled from **Gleam → JavaScript** that talks to the printer **directly over\nthe Web Serial API**. There is **no backend server** and no install — the\noperator just opens a URL (or serves the static build) in Chrome/Edge.\n\n## Architecture (three layers)\n\n- **`src/blau_drill/domain/`** — pure domain: `board_model` (`.drl` + Edge.Cuts\n  parse), `alignment` (least-squares fit), `gcode_program` (Marlin generation +\n  safety invariants), `job` (the session FSM), `transform2d`, `config`,\n  `correspondence`, `pending_alignment`.\n- **`src/blau_drill/control/`** — the serial control state machine:\n  `controller` (effectful shell), `printer` (pure core), `transport`\n  (`web_serial()` and `simulator()` backends), `protocol` (Marlin framing).\n- **`src/blau_drill/ui/`** — the Lustre views (`shell`, `stages`,\n  `board_canvas`), the flat `model` (model + `Msg`), the `bridge`\n  (domain/control ↔ UI translation), `storage` (localStorage persistence),\n  `sample` (a built-in board), and the FFI shims (`*_ffi.mjs`).\n- **`src/blau_drill/app.gleam`** — the orchestrator (`lustre.application`): wires\n  the UI `Msg` vocabulary onto controller commands + domain calls, threading\n  effects, and bridges controller events back into the update loop.\n\n## Hard requirements\n\n- **Chromium-only browser**: Chrome / Edge / Opera **89+** (Web Serial is not in\n  Firefox or Safari). The simulator path works in any modern browser; only the\n  real-hardware path needs Web Serial.\n- **Secure context**: Web Serial is only available over **HTTPS**, **localhost**,\n  or a **`file://`** page. (The dev server and a localhost static server both\n  qualify.)\n- **User gesture to connect**: `navigator.serial.requestPort()` must be called\n  from a user gesture, so connecting to a real device only works from the\n  **Connect** button click (it cannot be auto-connected).\n\n## Develop\n\nGleam lives in the Nix dev shell. Enter it (or let direnv load it):\n\n```sh\nnix develop          # from the repo root\ncd web/app\n```\n\nThen, inside the shell:\n\n```sh\ngleam build          # compile (JS target)\ngleam test           # run the test suite (domain + control + integration)\ngleam run -m lustre/dev start   # watch + serve on http://localhost:1234\n```\n\n\u003e The dev server does **not** hot-rebuild hand-written `.mjs` FFI files. After\n\u003e editing a `*_ffi.mjs`, rebuild and **hard-reload** (ES modules cache\n\u003e aggressively).\n\n## Build (static, self-contained)\n\n```sh\ngleam run -m lustre/dev build\n```\n\nThis emits three self-contained files into **`web/app/dist/`**:\n\n- `index.html`\n- `blau_drill.js` (the whole app + all FFI, ~380 KB)\n- `styles.css`\n\nServe the `dist/` directory from **any static host** (or a local static server):\n\n```sh\ncd dist \u0026\u0026 python3 -m http.server 8000   # then open http://localhost:8000\n```\n\n\u003e **Opening directly via `file://`**: the generated `index.html` references\n\u003e `/blau_drill.js` and `/styles.css` with **absolute** paths, which resolve to\n\u003e the filesystem root under `file://`. To open the build as a local file, either\n\u003e serve `dist/` over `http://localhost` (recommended), or rewrite those two\n\u003e `href`/`src` paths to be relative (`./blau_drill.js`, `./styles.css`). Web\n\u003e Serial itself is available under `file://`.\n\n## Running against the simulator vs real hardware\n\nThe transport is chosen in the sidebar **Connection** card:\n\n- **Simulator** (default) — an in-browser Marlin stand-in (`sim_ffi.mjs`). It\n  connects instantly, acks streamed lines incrementally so progress animates, and\n  answers `M114` with its integrated position. The **entire flow runs with no\n  hardware** — load a board, connect, align, dry-run, drill, complete.\n- **Web Serial (CNC)** — the real port (`serial_ffi.mjs`). Selecting it and\n  clicking **Connect** opens `navigator.serial.requestPort()` (the browser shows\n  its device picker). Requires a Chromium browser + a secure context + the user\n  gesture above.\n\nA built-in **\"Load sample board (segby_v1)\"** button on Stage 1 parses the\nbundled sample so you can drive the flow without a file dialog. The real **file\npickers** (the dropzone for `.drl`, and the optional Edge.Cuts `.svg` row) open a\nnative file dialog and read the chosen file as text.\n\n## Persistence (localStorage)\n\nThe operator **Config** (the settings screen) and the **selected backend** are\npersisted to `localStorage` and restored on load:\n\n- `blau_drill.config` — all settings fields (port, baud, motion limits, spindle\n  G-code commands, PWM, and the generator tunables: zdrill/zsafe/zchange/feed/\n  hover). Saved when you click **Apply Configuration**. Restored at startup,\n  falling back to safe defaults for any missing field.\n- `blau_drill.backend` — `sim` or `real`, saved when you change the device\n  picker.\n\nOn a run, the generator tunables are coerced + validated into a\n`domain/config.GcodeConfig` and applied as an **immutable snapshot** (taken when\nalignment begins / on Apply) — so mid-run settings edits never change the\nprogram being streamed. Machine-specific\nfields (port, baud, motion limits, spindle G-code, PWM) are operator/hardware\nsettings, never hardcoded product defaults.\n\n## Safety gates (enforced end-to-end)\n\n- **Energize-before-jog** — jog/move/spindle do nothing until motors are\n  energized; the pure control core refuses motion outside `Jogging` and writes\n  nothing.\n- **Retract-before-XY** and **spindle-before-plunge** — structural invariants in\n  `gcode_program`; the app streams its output **unmodified**.\n- **Linear flow** — drilling is reachable only via dry-run → confirm (the `job`\n  FSM has no Aligned → Drilling edge); the e-stop/abort is reachable from every\n  motion stage; a fault is loud (banner) with an explicit reconnect.\n- **M112 abort** — always reachable during streaming.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostbean%2Fblau_drill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flostbean%2Fblau_drill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostbean%2Fblau_drill/lists"}