Files
led-driver/main/patterns.h
T
jimmyandClaude Haiku 5.5 89f996096c Add LED web UI with AP, Wi-Fi client, mDNS and patterns
Brings the led_strip example into the cpp app, targeting the ESP32-C3:
- Access point led-XXXXXX (open) plus a Wi-Fi client configured from the
  web Settings tab, with credentials stored in NVS and reconnect backoff
- mDNS as led.local with an HTTP service on port 80
- HTTP server with an embedded web UI and a JSON API for patterns and Wi-Fi
- Pattern runner for solid, rainbow, chase, breathe, blink, pulse,
  transition and circle on a 119-LED WS2812 strip (GPIO 10)

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-11 00:02:49 +13:00

43 lines
1.1 KiB
C++

/*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#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,
};
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. */
void patterns_start(void);
/** @brief Replace the running pattern. Values are clamped to valid ranges. */
void patterns_set(const pattern_params_t &p);
/** @brief Copy of the running pattern. */
pattern_params_t patterns_get(void);
/** @brief Name of a mode, e.g. "rainbow". */
const char *patterns_mode_name(pattern_mode_t m);
/** @brief Mode for a name, or PM_COUNT if unknown. */
pattern_mode_t patterns_mode_from_name(const char *name);