## HAAC Plotter — Quick Start

This quick start is aimed at people who want to run the plotter **from scratch** (Pico firmware + browser demo + optional backend API).

### What you need

- **Hardware**
  - Raspberry Pi Pico (RP2040)
  - 2x step/dir drivers (e.g. TMC2208)
  - A pen-lift servo on `GP27`
- **Software**
  - Chrome or Edge (required for WebSerial demo)
  - Optional: Node.js (if you want to run the backend API)

### 1) Flash firmware to Pico

1. Install MicroPython on the Pico (UF2 method).
2. Copy the firmware file to the Pico as `main.py`.

Firmware source in this repo:

- `pico/main.py`

### 2) Test over serial (optional)

If you want to test using `mpremote`:

```bash
python3 -m venv .venv-mp
source .venv-mp/bin/activate
pip install mpremote
mpremote connect /dev/ttyACM0 repl
```

Then run:

- `PENUP`
- `PENDOWN`
- `X200`
- `Y200`
- `MOVE X200 Y200`
- `SPEED 1200`

### 3) Browser demo (recommended)

Open the demo page and click **CONNECT**.

Important notes:

- Browsers **cannot auto-connect** to USB devices. You must click CONNECT and select the Pico.
- WebSerial works in Chromium-based browsers (Chrome/Edge).

Demo page:

- `docs/plotter/basic-control.html`

### 4) Backend API (optional, for localhost development)

The backend can forward commands to the Pico over serial.

1. Configure env:
   - Copy `backend/.env.example` → `backend/.env`
   - Ensure `PLOTTER_SERIAL_PORT=/dev/ttyACM0`
2. Start backend:

```bash
cd backend
npm install
npm run dev
```

Endpoints:

- `POST /api/plotter/command`
- `POST /api/plotter/job`

Example requests are in `docs/plotter/examples/`.

