feat: sequences v2, bridges, and sim-controller
Rework sequences (engine, seqplay, envelope, API, web UI), add bridge support, add the host sim-controller and rig simulation tests, and update docs, presets and project tooling config. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d664026ee5
commit
2543673bd8
68 files changed
+5761
-460
No files matched your search
+22
-8
@@ -12,6 +12,20 @@
|
||||
|
||||
static const char *TAG = "store";
|
||||
|
||||
// Where the collections live: the littlefs partition, or on the host build a directory
|
||||
#if CONFIG_IDF_TARGET_LINUX
|
||||
#include <stdlib.h>
|
||||
static const char *db_root(void)
|
||||
{
|
||||
const char *d = getenv("LED_SIM_DB");
|
||||
return d && d[0] ? d : "/db";
|
||||
}
|
||||
#define PATH_LEN 256
|
||||
#else
|
||||
#define db_root() "/db"
|
||||
#define PATH_LEN 48
|
||||
#endif
|
||||
|
||||
static const char *const NAMES[] = {
|
||||
"device", "zone", "preset", "profile", "palette", "pattern",
|
||||
"sequence", "scene", "group", "output", "settings",
|
||||
@@ -44,13 +58,13 @@ static esp_err_t mount(const char *label, const char *base)
|
||||
|
||||
static cJSON *load_file(const char *name)
|
||||
{
|
||||
char path[48];
|
||||
snprintf(path, sizeof(path), "/db/%s.json", name);
|
||||
char path[PATH_LEN];
|
||||
snprintf(path, sizeof(path), "%s/%s.json", db_root(), name);
|
||||
FILE *f = fopen(path, "rb");
|
||||
if (!f) {
|
||||
// store_save removes the old file before renaming the finished .tmp, so a restart between the two leaves only .tmp
|
||||
char tmp[48];
|
||||
snprintf(tmp, sizeof(tmp), "/db/%s.tmp", name);
|
||||
char tmp[PATH_LEN];
|
||||
snprintf(tmp, sizeof(tmp), "%s/%s.tmp", db_root(), name);
|
||||
if (rename(tmp, path) == 0) {
|
||||
ESP_LOGW(TAG, "%s: recovered from %s", path, tmp);
|
||||
f = fopen(path, "rb");
|
||||
@@ -92,7 +106,7 @@ esp_err_t store_init(void)
|
||||
cJSON_InitHooks(&hooks);
|
||||
s_lock = xSemaphoreCreateRecursiveMutex();
|
||||
ESP_RETURN_ON_FALSE(s_lock, ESP_ERR_NO_MEM, TAG, "mutex");
|
||||
ESP_RETURN_ON_ERROR(mount("db", "/db"), TAG, "mount db");
|
||||
ESP_RETURN_ON_ERROR(mount("db", db_root()), TAG, "mount db");
|
||||
for (size_t i = 0; i < N_COLL; i++) {
|
||||
s_coll[i] = load_file(NAMES[i]);
|
||||
ESP_LOGI(TAG, "%s: %d records", NAMES[i], cJSON_GetArraySize(s_coll[i]));
|
||||
@@ -118,9 +132,9 @@ esp_err_t store_save(const char *name)
|
||||
char *json = cJSON_PrintUnformatted(s_coll[i]);
|
||||
ESP_RETURN_ON_FALSE(json, ESP_ERR_NO_MEM, TAG, "print");
|
||||
|
||||
char tmp[48], path[48];
|
||||
snprintf(tmp, sizeof(tmp), "/db/%s.tmp", name);
|
||||
snprintf(path, sizeof(path), "/db/%s.json", name);
|
||||
char tmp[PATH_LEN], path[PATH_LEN];
|
||||
snprintf(tmp, sizeof(tmp), "%s/%s.tmp", db_root(), name);
|
||||
snprintf(path, sizeof(path), "%s/%s.json", db_root(), name);
|
||||
FILE *f = fopen(tmp, "wb");
|
||||
esp_err_t ret = ESP_FAIL;
|
||||
if (f) {
|
||||
|
||||
Reference in new issue
Block a user