- 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>
69 lines
2.9 KiB
C++
69 lines
2.9 KiB
C++
/*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
|
|
#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]
|
|
};
|
|
|
|
/** @brief Start the LED strip and the pattern task, with the strip settings. */
|
|
void patterns_start(const struct hw_cfg_t &hw);
|
|
|
|
/** @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 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 Select a preset: always restarts the pattern, crossfading from the frame on the strip. */
|
|
void patterns_select(const preset_t &p);
|
|
|
|
/** @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 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);
|