docs: align readme and driver api with tcp/wifi
Made-with: Cursor
This commit is contained in:
44
README.md
44
README.md
@@ -1,36 +1,52 @@
|
|||||||
# LED Driver - MicroPython
|
# LED Driver — MicroPython
|
||||||
|
|
||||||
MicroPython-based LED driver application for ESP32 microcontrollers.
|
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
|
## Prerequisites
|
||||||
|
|
||||||
- MicroPython firmware installed on ESP32
|
- MicroPython firmware on the ESP32
|
||||||
- USB cable for programming
|
- USB cable for programming
|
||||||
- Python 3 with pipenv
|
- Python 3 with pipenv (on the host, for `dev.py` / tests)
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
1. Install dependencies:
|
1. Install dependencies:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pipenv install
|
pipenv install
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Deploy to device:
|
2. Deploy to the device:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pipenv run dev
|
pipenv run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
## Project Structure
|
## Project layout
|
||||||
|
|
||||||
```
|
```
|
||||||
led-driver/
|
led-driver/
|
||||||
├── src/
|
├── src/
|
||||||
│ ├── main.py # Main application code
|
│ ├── main.py # Entry: Wi-Fi/TCP or ESP-NOW path, process_data(), manifest OTA
|
||||||
│ ├── presets.py # LED pattern implementations (includes Preset and Presets classes)
|
│ ├── presets.py # Preset runtime + Presets class
|
||||||
│ ├── settings.py # Settings management
|
│ ├── preset.py # Single preset helpers
|
||||||
│ └── p2p.py # Peer-to-peer communication
|
│ ├── settings.py # settings.json
|
||||||
├── test/ # Pattern tests
|
│ ├── hello.py # UDP discovery (port 8766) / hello payloads
|
||||||
├── web_app.py # Web interface
|
│ ├── http_poll.py # Optional HTTP polling helper
|
||||||
├── dev.py # Development tools
|
│ ├── utils.py # Colour conversion / ordering
|
||||||
└── Pipfile # Python dependencies
|
│ ├── 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.
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# LED Driver ESPNow API Documentation
|
# LED Driver API (message format)
|
||||||
|
|
||||||
This document describes the ESPNow message format for controlling LED driver devices.
|
This document describes the **JSON message format** for controlling LED driver devices. The same object is accepted from **ESP-NOW** (when that transport is enabled) and as **one JSON value per line** over **TCP** in **Wi-Fi** mode (see `src/main.py` on the device).
|
||||||
|
|
||||||
## Message Format
|
## Message Format
|
||||||
|
|
||||||
All messages are JSON objects sent via ESPNow with the following structure:
|
All messages are JSON objects with the following structure:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user