# Lego Ladder

Ladder logic programming interface for Lego Technic Powered Up hubs.

## What's Done (Phase 1)

**Engine** (`src/engine/`)
- Full type system: contacts, coils, timers, counters, gates, rungs, I/O model
- `LadderEngine` class with scan cycle, rung evaluation, all element types
- 25/25 tests passing (`npm test`)

**UI** (`public/index.html`, `src/ui/app.ts`)
- Dark-themed ladder canvas with power rails
- Toolbar with all element types
- Live I/O panel (inputs/outputs)
- Run/pause/stop controls, save/load program as JSON
- Hub connection button (BLE stub)

## Remaining

**Phase 2 — Editor Features**
- Element configuration dialogs (click to edit address, values, thresholds)
- Drag-and-drop element placement in rungs
- Rung reordering and deletion
- Visual state updates during execution

**Phase 3 — BLE Integration**
- Powered Up BLE protocol implementation
- Device abstraction: motors (B/C/D), sensors (distance, tilt, color), hub buttons/LED
- Live sensor polling → engine inputs

**Phase 4 — Real Hardware**
- Integration testing with Powered Up hub
- Motor speed control via numeric coil values
- Connection status, error handling

## Run

```bash
cd ~/projects/lego-ladder
npm install
npm test        # run tests
npm run dev     # start dev server
```