Files
jimmyandClaude Haiku 5.5 a1c8ce853b feat: sequence window, finer timeline, zone brightness to Wi-Fi drivers
- A sequence's length is a fixed window (window_beats / window_seconds), not its presets.
  The timeline is exactly the window long; clips past it are cut on save.
- The ruler adds finer ticks when zoomed in; Snap has Auto (follows the zoom), 0.25 s and 0.05 s.
  Steps and the window go down to 50 ms.
- Ctrl+wheel zooms around the pointer; the zoom buttons zoom around the last pointer position.
- Sequence start and the zone brightness slider reach Wi-Fi drivers (matched by hostname or MAC).
- A preset select with brightness also sends the brightness to Wi-Fi drivers, as ESP-NOW does.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-16 21:22:17 +13:00

51 lines
2.6 KiB
C

#pragma once
#include <stdbool.h>
#include "cJSON.h"
#include "esp_err.h"
// Zone play/stop and preset push/send. Drivers run the patterns themselves; this builds preset +
// select frames and hands them to ESP-NOW. Sequences are played by seqplay.c.
// Hook driver announce and resync replies
esp_err_t engine_init(void);
#define GROUP_ID_MAX 20
#define ZONE_TARGETS_MAX 12
// Group ids a zone plays to: its group_ids, plus "z<zone id>" when it names drivers directly (zones
// from before groups). -1 when the zone does not exist. Call with the store locked.
int engine_zone_targets(const char *zone_id, char out[][GROUP_ID_MAX], int max);
// A preset ready to send: palette colours and background resolved, mode as n6. Caller owns it;
// NULL when there is no such preset. Call with the store locked.
cJSON *engine_preset_payload(const char *preset_id);
// Drivers in group gid (a group id, "z<zone>" or a driver's own "d<mac>"), as 12-hex MACs from the
// device list. Call with the store locked.
int engine_group_macs(const char *gid, char out[][13], int max);
// Wi-Fi drivers (listed by hostname) in the zone's groups. Call with the store locked.
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);
// 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);
// Select a preset on every driver in the zone's groups (broadcast, sent twice)
esp_err_t engine_play(const char *zone_id, const char *preset_id);
// Turn the zone's drivers off
esp_err_t engine_stop(const char *zone_id);
// POST /presets/push: v1 messages for targets (MAC strings), or broadcast when targets is NULL
esp_err_t engine_push(const cJSON *messages, const cJSON *targets);
// POST /presets/send: presets from the current profile by id
esp_err_t engine_send_presets(const cJSON *ids, bool save, const char *def, const cJSON *targets, int *sent);
// A Wi-Fi driver reported its MAC (hex, no separators): record it, and merge an ESP-NOW record for the same
// board into the Wi-Fi device. Call without the store lock held.
void engine_wifi_mac(const char *host, const char *mac);
// Zones or devices changed: re-send group membership to every registered ESP-NOW driver
void engine_groups_changed(void);
// POST /devices/groups: send every ESP-NOW driver its groups, including silent ones, and wait for the
// acks. Call without the store lock held.
void engine_groups_push_all(int *total, int *sent, int *failed);