- Wi-Fi access point led-XXXXXX plus a client network, configurable mDNS name and static client address - Preset tiles with an editor, drag to reorder, default presets, global brightness, Run and Edit modes, collapsible menu on phones - 35 patterns ported from led-driver, up to 512 LEDs, colour order, max brightness and data pin settings - Over-the-air updates (POST /ota) with rollback, and a CLI in tools/ota.py - DDP receiver on UDP 4048 with tools/ddp_test.py - LED refresh every 10 ms; lwIP sockets raised to 16 so mDNS, HTTP and DDP can run together Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
58 lines
1.9 KiB
C
58 lines
1.9 KiB
C
/*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
#pragma once
|
|
|
|
#include <cstddef>
|
|
|
|
#include "cJSON.h"
|
|
#include "esp_err.h"
|
|
#include "patterns.h"
|
|
|
|
#define PRESETS_MAX 32
|
|
|
|
/** @brief Load the saved presets and the startup name from NVS. Call after NVS is initialised. */
|
|
esp_err_t presets_init(void);
|
|
|
|
/** @brief Add the default presets whose names are not in the list yet. Returns how many were added. */
|
|
int presets_add_defaults(void);
|
|
|
|
/** @brief Number of presets. */
|
|
size_t presets_count(void);
|
|
|
|
/** @brief Preset at index i (0 <= i < presets_count()). */
|
|
const preset_t *presets_at(size_t i);
|
|
|
|
/** @brief Create a preset, or update the one with the same name. ESP_ERR_NO_MEM when full. */
|
|
esp_err_t presets_save(const preset_t *preset);
|
|
|
|
/** @brief Put the presets in this order. Names not given keep their place at the end. */
|
|
esp_err_t presets_set_order(const char *const *names, size_t n);
|
|
|
|
/** @brief Delete a preset by name. Clears the startup name if it was that preset. */
|
|
esp_err_t presets_delete(const char *name);
|
|
|
|
/** @brief Select a preset: crossfades in and restarts its pattern. ESP_ERR_NOT_FOUND if no such name. */
|
|
esp_err_t presets_select(const char *name);
|
|
|
|
/** @brief Name of the last preset selected since boot, or "". */
|
|
const char *presets_selected(void);
|
|
|
|
/** @brief Set the preset applied at boot. An empty name clears it. */
|
|
esp_err_t presets_set_startup(const char *name);
|
|
|
|
/** @brief Name of the startup preset, or "". */
|
|
const char *presets_startup(void);
|
|
|
|
/** @brief Apply the startup preset, if one is set and still exists. */
|
|
void presets_apply_startup(void);
|
|
|
|
/** @brief A preset as JSON, with the MicroPython field names. The caller frees it with cJSON_Delete. */
|
|
cJSON *preset_to_json(const preset_t *p);
|
|
|
|
/**
|
|
* @brief Apply the fields present in JSON onto p; missing fields keep their value.
|
|
* @return false if a field is malformed (an unknown pattern name, for example).
|
|
*/
|
|
bool preset_from_json(const cJSON *o, preset_t *p);
|