feat: web UI with AP, Wi-Fi client, mDNS, presets, OTA and DDP
- 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>
This commit is contained in:
1 parent
89f996096c
commit
9a04d28ecf
32 files changed
+6210
-398
No files matched your search
+54
-28
@@ -3,40 +3,66 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
// Pattern names (also the strings the web UI uses). Order matters: the index is the mode id.
|
||||
enum pattern_mode_t {
|
||||
PM_SOLID,
|
||||
PM_RAINBOW,
|
||||
PM_CHASE,
|
||||
PM_BREATHE,
|
||||
PM_BLINK,
|
||||
PM_PULSE,
|
||||
PM_TRANSITION,
|
||||
PM_CIRCLE,
|
||||
PM_COUNT,
|
||||
#include "esp_err.h"
|
||||
|
||||
#define PATTERN_MAX_COLOURS 8
|
||||
|
||||
// Preset fields follow the MicroPython presets: pattern, colours, background, delay (d), brightness (b),
|
||||
// auto (a), reverse, fade, beat_time (tb) and the pattern-specific numbers n1..n6 (n6 is the style).
|
||||
struct preset_t {
|
||||
char name[32]; // "" for the live settings
|
||||
int pattern; // index into the pattern table
|
||||
int ncol; // 0 uses each pattern's own default colours
|
||||
uint8_t col[PATTERN_MAX_COLOURS][3];
|
||||
uint8_t bg[3]; // background (d off colour)
|
||||
uint32_t delay; // d, ms
|
||||
uint8_t brightness; // b, 0-255
|
||||
bool autorun; // a: keep running; false runs one cycle and holds
|
||||
bool reverse; // run the other way along the strip
|
||||
uint32_t fade; // crossfade in from the previous frame, ms
|
||||
bool beat_time; // tb: durations are quarter beats (500 ms beat here)
|
||||
int n[7]; // n[1]..n[6]
|
||||
};
|
||||
|
||||
struct pattern_params_t {
|
||||
pattern_mode_t mode;
|
||||
uint8_t c1[3]; // main colour (ignored by rainbow and chase)
|
||||
uint8_t c2[3]; // background / second colour
|
||||
uint32_t speed_ms; // one step of the pattern, 10-10000 ms
|
||||
uint8_t brightness; // 0-255
|
||||
};
|
||||
/** @brief Start the LED strip and the pattern task, with the strip settings. */
|
||||
void patterns_start(const struct hw_cfg_t &hw);
|
||||
|
||||
/** @brief Start the LED strip and the pattern task. */
|
||||
void patterns_start(void);
|
||||
/** @brief Apply new strip settings (count, colour order, brightness ceiling) while running. */
|
||||
esp_err_t patterns_set_hardware(const struct hw_cfg_t &hw);
|
||||
|
||||
/** @brief Replace the running pattern. Values are clamped to valid ranges. */
|
||||
void patterns_set(const pattern_params_t &p);
|
||||
/** @brief Live update of the preset on the strip. A new pattern restarts; other changes keep its place. */
|
||||
void patterns_set(const preset_t &p);
|
||||
|
||||
/** @brief Copy of the running pattern. */
|
||||
pattern_params_t patterns_get(void);
|
||||
/** @brief Select a preset: always restarts the pattern, crossfading from the frame on the strip. */
|
||||
void patterns_select(const preset_t &p);
|
||||
|
||||
/** @brief Name of a mode, e.g. "rainbow". */
|
||||
const char *patterns_mode_name(pattern_mode_t m);
|
||||
/** @brief DDP pixel data for the strip: byte offset into the RGB buffer, data, length. Replaces the pattern. */
|
||||
void patterns_ddp_write(uint32_t offset, const uint8_t *data, size_t len, bool push);
|
||||
|
||||
/** @brief Mode for a name, or PM_COUNT if unknown. */
|
||||
pattern_mode_t patterns_mode_from_name(const char *name);
|
||||
/** @brief Whether DDP pixels are arriving, and how many packets have come in. */
|
||||
void patterns_ddp_status(bool *active, uint32_t *packets);
|
||||
|
||||
/** @brief The colour last shown on LED i, as RGB. */
|
||||
void patterns_shown_pixel(int i, uint8_t out[3]);
|
||||
|
||||
/** @brief Live brightness for every pattern, 0-255 (applied under the max brightness ceiling). */
|
||||
void patterns_set_global(uint8_t level);
|
||||
uint8_t patterns_get_global(void);
|
||||
|
||||
/** @brief Copy of the preset being shown. */
|
||||
void patterns_get(preset_t *out);
|
||||
|
||||
/** @brief Number of patterns. */
|
||||
int patterns_count(void);
|
||||
|
||||
/** @brief Name of pattern i, e.g. "chase". */
|
||||
const char *patterns_name(int i);
|
||||
|
||||
/** @brief Index for a pattern name, or -1 if unknown. */
|
||||
int patterns_index(const char *name);
|
||||
|
||||
/** @brief Fill a preset with the defaults for a pattern: colours and timing as the MicroPython presets. */
|
||||
void preset_defaults(preset_t *p, int pattern);
|
||||
Reference in new issue
Block a user