feat: pattern gallery as a preset editor; chase steps; sim split with the preset editor
- Pattern gallery shows the controller's presets, one at a time, with a dropdown, Save, Add preset, and the controller's field labels, delay limits and colour counts. Edits show in the preview; Save writes to the controller only. - Presets are always timed in ms (beat_time is no longer sent to drivers); beats stay in sequences. - Chase steps of 0 hold still; the marquee style is removed from the controller, the gallery and the driver (submodule commit 12a8e22). - The rig's split pane opens the preset editor too (Rig / Presets switch and a Preset editor menu entry). - Sequence editor, room layout and simulator controls from earlier work are included. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8c783ab926
commit
cb51a726bc
79 files changed
+5183
-934
No files matched your search
@@ -15,7 +15,7 @@
|
||||
* POST /sim/api/rooms {name, width, depth, copy_from?}: a new room
|
||||
* GET|PUT|DELETE /sim/api/rooms/<name>
|
||||
* POST /sim/api/room {name}: switch the rig to that room
|
||||
* GET /sim/api/next-mac?taken= a MAC no room uses
|
||||
* POST /sim/api/next-mac {taken: [mac, ...]}: a MAC no room or the page uses
|
||||
*
|
||||
* Rooms follow the stage maps of the qlcplus simulator: one JSON file per room in <db>/sim/rooms/, a size in
|
||||
* metres, strip types ("definitions") and "fixtures" keyed by id, each one LED bar: x, y (metres) is pixel 0,
|
||||
@@ -780,7 +780,8 @@ static esp_err_t flash_get(httpd_req_t *req, const char *mac_in)
|
||||
return api_json(req, "200 OK", nvs, true);
|
||||
}
|
||||
|
||||
static void next_mac(const char *taken, char out[18])
|
||||
// taken: the page's MACs (a JSON array of strings, may be NULL), not yet saved in any room
|
||||
static void next_mac(const cJSON *taken, char out[18])
|
||||
{
|
||||
cJSON *names = room_names(), *n;
|
||||
char err[160];
|
||||
@@ -801,9 +802,21 @@ static void next_mac(const char *taken, char out[18])
|
||||
cJSON_Delete(room);
|
||||
}
|
||||
cJSON_Delete(names);
|
||||
const cJSON *t;
|
||||
cJSON_ArrayForEach(t, taken)
|
||||
{
|
||||
if (all && cJSON_IsString(t) && len + 20 < cap) {
|
||||
len += (size_t)snprintf(all + len, cap - len, "%s,", t->valuestring);
|
||||
}
|
||||
}
|
||||
if (all) {
|
||||
for (char *c = all; *c; c++) { // MACs compare in lower case
|
||||
*c = (char)tolower((unsigned char)*c);
|
||||
}
|
||||
}
|
||||
for (int i = 1; i < 0xFFFF; i++) {
|
||||
snprintf(out, 18, MAC_PREFIX ":00:%02x:%02x", i >> 8, i & 0xFF);
|
||||
if ((!all || !strstr(all, out)) && (!taken || !strstr(taken, out))) {
|
||||
if (!all || !strstr(all, out)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -844,25 +857,19 @@ static esp_err_t api_handler(httpd_req_t *req)
|
||||
} else if (!strcmp(a, "flash") && b[0] && m == HTTP_GET) {
|
||||
xSemaphoreGive(s_mu); // flash_get takes it for the write
|
||||
return flash_get(req, b);
|
||||
} else if (!strcmp(a, "next-mac") && m == HTTP_GET) {
|
||||
char q[600] = "", taken[600] = "", mac[18];
|
||||
if (httpd_req_get_url_query_str(req, q, sizeof(q)) == ESP_OK) {
|
||||
httpd_query_key_value(q, "taken", taken, sizeof(taken));
|
||||
} else if (!strcmp(a, "next-mac") && m == HTTP_POST) {
|
||||
// {taken: [mac, ...]} in the body: a long list in the query would pass the URI limit (512 bytes)
|
||||
cJSON *body = api_body(req);
|
||||
if (!body) {
|
||||
ret = ESP_OK;
|
||||
} else {
|
||||
char mac[18];
|
||||
next_mac(cJSON_GetObjectItem(body, "taken"), mac);
|
||||
cJSON_Delete(body);
|
||||
cJSON *o = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(o, "mac", mac);
|
||||
ret = api_json(req, "200 OK", o, true);
|
||||
}
|
||||
for (char *c = taken; *c; c++) { // %3A and %2C from encodeURIComponent; MACs compare in lower case
|
||||
*c = (char)tolower((unsigned char)*c);
|
||||
if (c[0] == '%' && c[1] == '3' && (c[2] == 'A' || c[2] == 'a')) {
|
||||
c[0] = ':';
|
||||
memmove(c + 1, c + 3, strlen(c + 3) + 1);
|
||||
} else if (c[0] == '%' && c[1] == '2' && (c[2] == 'C' || c[2] == 'c')) {
|
||||
c[0] = ',';
|
||||
memmove(c + 1, c + 3, strlen(c + 3) + 1);
|
||||
}
|
||||
}
|
||||
next_mac(taken, mac);
|
||||
cJSON *o = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(o, "mac", mac);
|
||||
ret = api_json(req, "200 OK", o, true);
|
||||
} else if (!strcmp(a, "rooms") && !b[0] && m == HTTP_GET) {
|
||||
ret = rooms_info(req);
|
||||
} else if (!strcmp(a, "rooms") && !b[0] && m == HTTP_POST) {
|
||||
|
||||
Reference in new issue
Block a user