Files
led-driver/README.md
2026-04-12 00:13:49 +12:00

53 lines
2.0 KiB
Markdown

# LED Driver — MicroPython
MicroPython LED driver for ESP32: presets, patterns, **Wi-Fi** (TCP + UDP discovery) or **ESP-NOW** transport, optional HTTP polling, and dynamic pattern modules under `src/patterns/`.
## Prerequisites
- MicroPython firmware on the ESP32
- USB cable for programming
- Python 3 with pipenv (on the host, for `dev.py` / tests)
## Setup
1. Install dependencies:
```bash
pipenv install
```
2. Deploy to the device:
```bash
pipenv run dev
```
## Project layout
```
led-driver/
├── src/
│ ├── main.py # Entry: Wi-Fi/TCP or ESP-NOW path, process_data(), manifest OTA
│ ├── presets.py # Preset runtime + Presets class
│ ├── preset.py # Single preset helpers
│ ├── settings.py # settings.json
│ ├── hello.py # UDP discovery (port 8766) / hello payloads
│ ├── http_poll.py # Optional HTTP polling helper
│ ├── utils.py # Colour conversion / ordering
│ ├── presets.json # Default preset file (on device)
│ └── patterns/ # Pattern modules (.py), loaded dynamically
├── tests/ # Host-side helpers (e.g. udp_client.py, test_mdns.py)
├── test/ # On-device style pattern tests (all.py, patterns/)
├── dev.py # Deploy / sync to serial device
├── docs/API.md # Wire format (long keys); Pi app docs short keys
├── msg.json # Sample message
├── Pipfile
└── LICENSE
```
**Transport:** `settings.json` **`transport_type`** is typically **`wifi`** (TCP to the Pi on port **8765**, discovery on **8766**) or **`espnow`**. ESP-NOW code paths are loaded only when needed so a Wi-Fi-only image stays smaller.
## Further reading
- **`docs/API.md`** — JSON message fields as used in examples (`pattern`, `colors`, …). The Pi app may send **short keys** (`p`, `c`, …); behaviour matches once normalised on device.