Files
kvida-os/components/drivers/README.md
Ronny Eia 967fecbf69 Add persistent script storage + hot-reload, verified live
lua_runtime now loads the running script from a new LittleFS-backed
drivers::storage (joltwallet/littlefs, the project's fifth external
managed component -- mounts the "storage" partition already reserved
in partitions.csv), falling back to the compiled-in default script
only on first boot. transport exposes GET/POST /api/script -- raw Lua
text, not JSON, since json_helpers.h can't round-trip scripts safely
-- relayed to lua_runtime via the same callback-registration pattern
already used for LedColorHandler, keeping transport free of a
dependency on lua_runtime. lua_runtime_reload() persists and hot-swaps
to a fresh Lua state immediately, no reboot.

Verified on real ESP32-C6 hardware: script loads via kvida-sdk, an
edited script hot-reloads within one tick, and the edit survives a
power cycle (proving LittleFS persistence, not just an in-RAM change).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-12 10:27:00 +02:00

8 lines
1.0 KiB
Markdown

# drivers
Hardware abstraction: wraps ESP32-C6 peripherals (GPIO, ADC, I2C) behind a board-independent interface used by `sensors`. No dependency on other Kvida components.
- `chip_temperature.h`/`.cpp` -- wraps ESP-IDF's built-in `temperature_sensor` driver (die temperature; there's no external ambient temperature sensor on the ESP32-C6-DevKitC-1).
- `rgb_led.h`/`.cpp` -- wraps the DevKitC-1's onboard WS2812 addressable RGB LED (GPIO8) via the `espressif/led_strip` managed component (`idf_component.yml`).
- `storage.h`/`.cpp` -- mounts the `storage` LittleFS partition (see `partitions.csv`) at `/storage` via `joltwallet/littlefs` (verified against the component's actual header, not guessed -- the real mount function is `esp_vfs_littlefs_register()`, not `esp_vfs_littlefs_mount()` despite what some docs summaries say), then exposes plain whole-file `storage_read_file()`/`storage_write_file()` helpers over the standard `fopen`/`fread`/`fwrite` VFS calls. Used by `lua_runtime` to persist the running script (`components/lua_runtime/README.md`).