Phase 7: EC11 encoder, life counter views, WS2812B RMT + LEDC buzzer feedback, E2E UI state machine; document build/hardware notes

This commit is contained in:
2026-09-09 18:36:17 +02:00
parent 8a95e1735a
commit 01c24d17b6
14 changed files with 914 additions and 29 deletions

View File

@@ -63,6 +63,8 @@ State transitions must be managed cleanly using FreeRTOS Event Groups or Queue m
Do NOT assume an SD card is attached. All local database operations use standard C file I/O (`fopen`, `fread`, `fwrite`) over LittleFS.
Contents are pre-seeded from the repo `storage/` folder via `littlefs_create_partition_image(storage storage FLASH_IN_PROJECT)` at build time.
* `/spiffs/mappings.json` — Maps scanned UIDs to Card Names:
```json
{
@@ -81,6 +83,8 @@ Do NOT assume an SD card is attached. All local database operations use standard
"price_usd": "1.25"
}
/spiffs/cards/[UID].jpg — Cached Scryfall cover art (streamed via tjpgd).
6. Coding Standards & Conventions
When generating or editing code for this repository:
@@ -128,4 +132,28 @@ Build Commands
When modifying hardware code: Cross-check the shared SPI bus configurations to prevent SPI2_HOST bus conflicts between ST7789 and MFRC522.
When implementing network code: Use non-blocking esp_http_client requests running on a dedicated FreeRTOS task to keep screen rendering smooth.
When implementing network code: Use non-blocking esp_http_client requests running on a dedicated FreeRTOS task to keep screen rendering smooth.
9. Module Map (main/)
| File | Responsibility | Task / Core |
| :--- | :--- | :--- |
| `main.c` | Boot orchestration | app_main |
| `hw_pins.h` | GPIO assignments | - |
| `spi_bus_manager.c` | Shared SPI2_HOST bus init | - |
| `storage_manager.c` | LittleFS mount + JSON mapping/card helpers | - |
| `rfid_manager.c` | MFRC522, UID hex, Core-0 pinning | rc522_polling_task / 0 |
| `display_manager.c` | ST7789 240x320 primitives, 5x7 text, big digits, tjpgd stream | ui_task / 1 |
| `ui_task.c` | State machine + all screens | ui_task / 1 |
| `wifi_manager.c` | STA auto-connect + reconnect | event loop |
| `scryfall_client.c` | Scryfall HTTPS, cJSON cache, prefetch | net_task / 0 |
| `web_server.c` | SoftAP MTG-Companion 192.168.4.1 + pairing SPA | httpd task |
| `encoder.c` | EC11 ISR decode + button | ISR |
| `led_manager.c` | WS2812B RMT | ISR + ui_task |
| `buzzer.c` | LEDC PWM tones | ui_task |
| `app_state.c` | STATE_* + life counter values | all |
Build & runtime notes:
- `idf.py menuconfig` -> "MTG RFID Companion" sets `MTG_WIFI_SSID` / `MTG_WIFI_PASS`; leave empty to skip STA (SoftAP web pairing always runs).
- Flash: `idf.py -p COMx flash monitor`. The `storage/` folder is baked into the LittleFS partition image.
- The ST7789 is driven in RGB565 big-endian wire order; if colors appear inverted on a given panel variant, toggle `esp_lcd_panel_invert_color()` / `LCD_RGB_ELEMENT_ORDER_*` in `display_manager.c`.