Generate the web UI headers from c/web/ via scripts/embed_file.py (minify + gzip) and serve them with Content-Encoding, replacing the checked-in web_*.h blobs. Move the LED driver/presets into lib/leds, and parse preset edits into a typed cmd_preset_t on core0 instead of passing raw JSON to core1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <array>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
#include "leds/preset.hpp"
|
|
#include "leds/ws2812.hpp"
|
|
|
|
class Pattern;
|
|
|
|
class Presets {
|
|
public:
|
|
static constexpr size_t kStripCount = 8;
|
|
Presets();
|
|
~Presets();
|
|
|
|
bool select(const std::string& name, int step = -1);
|
|
bool edit(const std::string& name, const Preset& preset);
|
|
bool remove(const std::string& name);
|
|
void tick();
|
|
void fill(RGB color);
|
|
void fill_n(RGB color, int first, int last);
|
|
bool set(size_t strip, int reference_index, RGB color);
|
|
RGB apply_brightness(RGB color, int local = 255) const;
|
|
void show_all();
|
|
void show_all_parallel();
|
|
void off();
|
|
void on(Preset* preset);
|
|
uint16_t strip_length(size_t strip) const;
|
|
|
|
std::array<std::unique_ptr<WS2812B>, kStripCount> strips;
|
|
std::array<uint16_t, kStripCount> strip_midpoints{};
|
|
std::array<std::vector<uint16_t>, kStripCount> scale_map;
|
|
std::unordered_map<std::string, Preset> presets;
|
|
std::unique_ptr<Pattern> current;
|
|
std::string selected;
|
|
int step = 0;
|
|
int last_roll_head = 0;
|
|
uint8_t b = 255;
|
|
|
|
private:
|
|
std::unique_ptr<Pattern> make_pattern(const std::string& name) const;
|
|
};
|