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:
jimmyandClaude Haiku 5.5 committed 2026-11-17 07:16:51 +13:00
1 parent 8c783ab926
commit cb51a726bc
79 files changed
+5183 -934

No files matched your search

+15 -3
View File
@@ -293,7 +293,9 @@ static bool wifi_in_group(const cJSON *dev, const char *id, const char *gid)
return cJSON_IsString(name) && names && name_seen(names, cJSON_GetArraySize(names), name->valuestring);
}
if (gid[0] == 'd') {
return false; // a driver's own group is an ESP-NOW MAC
// a driver's own group: d<mac>, the MAC in its record (a Wi-Fi driver's record has one too)
const cJSON *mac = cJSON_GetObjectItem(dev, "mac");
return cJSON_IsString(mac) && !strcmp(mac->valuestring, gid + 1);
}
const cJSON *group = cJSON_GetObjectItem(store_coll("group"), gid);
const cJSON *list = group ? cJSON_GetObjectItem(group, "devices") : NULL, *it;
@@ -737,9 +739,10 @@ static const char *const TOP_SHORT[][2] = {
};
static const char *const PRESET_SHORT[][2] = {
{ "pattern", "p" }, { "colors", "c" }, { "delay", "d" }, { "brightness", "b" }, { "auto", "a" }, { "background", "bg" },
{ "fade", "f" }, { "beat_time", "tb" },
{ "fade", "f" },
};
static const char *const PRESET_KEYS[] = { "p", "c", "d", "b", "a", "bg", "n1", "n2", "n3", "n4", "n5", "n6", "f", "tb" };
// Presets are always timed in ms; beats belong to sequences (seqplay.c), so no tb goes to drivers
static const char *const PRESET_KEYS[] = { "p", "c", "d", "b", "a", "bg", "n1", "n2", "n3", "n4", "n5", "n6", "f" };
static const char *short_key(const char *const map[][2], size_t n, const char *k)
{
@@ -1403,3 +1406,12 @@ esp_err_t engine_init(void)
rel_set_announce_cb(on_announce);
return ESP_OK;
}
bool engine_mac_in_zone(const char *hex12, const char *zone_id)
{
uint8_t mac[6];
if (!hex_mac(hex12, mac)) {
return false;
}
return driver_in_zone(mac, device_name_for(mac), zone_id);
}
+2
View File
@@ -26,6 +26,8 @@ int engine_group_macs(const char *gid, char out[][13], int max);
int engine_zone_wifi_ids(const char *zone_id, char out[][GROUP_ID_MAX], int max);
// The preset a zone last played (engine_play / engine_stop), or NULL. Call with the store locked.
const char *engine_zone_current(const char *zone_id);
// Is the driver with this MAC (12 hex digits) in one of the zone's groups? Call with the store locked.
bool engine_mac_in_zone(const char *hex12, const char *zone_id);
// Record preset_id as what zone_id plays, when the UI has sent it to the drivers itself
void engine_zone_note(const char *zone_id, const char *preset_id);
+1 -1
View File
@@ -157,7 +157,7 @@ static const struct {
{ "bar_graph", "{\"n1\":\"Level (0-100 %)\",\"min_delay\":10,\"max_delay\":60000,\"max_colors\":10}" },
{ "blizzard", "{\"n1\":\"Flake density (0-255)\",\"n2\":\"Speed\",\"n3\":\"Wind (128 still, below/above blows one way/other)\",\"min_delay\":10,\"max_delay\":60000,\"max_colors\":10}" },
{ "candle_glow", "{\"n1\":\"Candles\",\"n2\":\"Candle width (LEDs)\",\"n3\":\"Flicker (0-255)\",\"min_delay\":10,\"max_delay\":60000,\"max_colors\":10}" },
{ "chase", "{\"n1\":\"Segment on (LEDs)\",\"n2\":\"Segment off (LEDs)\",\"n3\":\"Step (LEDs, negative = backwards)\",\"n4\":\"Step B, chase only (negative = backwards)\",\"n6\":\"Style: 0 chase, 1 marquee\",\"min_delay\":10,\"max_delay\":60000,\"max_colors\":10}" },
{ "chase", "{\"n1\":\"Segment on (LEDs)\",\"n2\":\"Segment off (LEDs)\",\"n3\":\"Step (LEDs, negative = backwards)\",\"n4\":\"Step B, chase only (negative = backwards)\",\"min_delay\":10,\"max_delay\":60000,\"max_colors\":10}" },
{ "circle", "{\"n1\":\"Head speed (LEDs/s)\",\"n2\":\"Max length (LEDs)\",\"n3\":\"Tail speed (LEDs/s)\",\"n4\":\"Min length (LEDs)\",\"min_delay\":10,\"max_delay\":60000,\"max_colors\":10}" },
{ "clock_sweep", "{\"n1\":\"Hand width (LEDs)\",\"n2\":\"Marker every (LEDs, 0 = none)\",\"min_delay\":10,\"max_delay\":60000,\"max_colors\":10}" },
{ "colour_cycle", "{\"n1\":\"Step\",\"n6\":\"Style: 0 colours, 1 rainbow wheel\",\"min_delay\":10,\"max_delay\":60000,\"max_colors\":10}" },
+21 -12
View File
@@ -770,27 +770,36 @@ static void restore(const macs_t *drivers, const char *zone)
send_lane(&s_base, i);
}
} else {
// The zone's last preset, on these drivers only (a pseudo player with one target)
static target_t t;
player_t one = { .target = &t, .ntargets = 1 };
t.n = 0;
char z[ZONE_TARGETS_MAX][GROUP_ID_MAX];
int n = engine_zone_targets(zone, z, ZONE_TARGETS_MAX);
for (int i = 0; i < n && t.n < TGROUPS_MAX; i++) {
snprintf(t.g[t.n++], GROUP_ID_MAX, "%s", z[i]);
// The drivers the one-shot lit go back to their background: the zone's last preset if the driver is in
// the zone, else off (a driver outside the zone has no background). One target each, by its own group
// (d<mac>). Wi-Fi drivers (hostname ids) are not handled here
static target_t tin[MACS_MAX], tout[MACS_MAX];
int nin = 0, nout = 0;
for (int i = 0; i < drivers->n; i++) {
if (strlen(drivers->m[i]) != 12) {
continue;
}
target_t *tt = engine_mac_in_zone(drivers->m[i], zone) ? &tin[nin++] : &tout[nout++];
tt->n = 1;
snprintf(tt->g[0], GROUP_ID_MAX, "d%s", drivers->m[i]);
}
player_t pin = { .target = tin, .ntargets = nin };
player_t pout = { .target = tout, .ntargets = nout };
uint32_t allin = nin >= 32 ? 0xffffffffu : (1u << nin) - 1;
uint32_t allout = nout >= 32 ? 0xffffffffu : (1u << nout) - 1;
const char *cur = engine_zone_current(zone);
if (cur && strcmp(cur, "off")) {
if (nin && cur && strcmp(cur, "off")) {
cJSON *presets = cJSON_CreateObject();
cJSON *pl = engine_preset_payload(cur);
if (pl) {
cJSON_AddItemToObject(presets, cur, pl);
}
upload(&one, 1, presets);
select_on(&one, 1, cur);
upload(&pin, allin, presets);
select_on(&pin, allin, cur);
} else {
select_on(&one, 1, "off");
select_on(&pin, allin, "off");
}
select_on(&pout, allout, "off");
}
s_restoring = false;
s_restore.n = 0;