FastLED 3.10.6
Loading...
Searching...
No Matches
builder.h
Go to the documentation of this file.
1#pragma once
2
3// fl::fled::FledBuilder - imperative builder that assembles a v1 .fled
4// byte buffer from header bytes + optional JSON sections + an optional
5// frame payload, then parses the result through the canonical
6// fl::Fled::loadFromVector() path. The returned Fled is byte-equivalent
7// to one loaded from disk.
8//
9// Lives in fl::fled (not fl::) per the subsystem rule: only the public
10// Fled type itself stays at top-level fl::; every auxiliary moves to
11// the fl::fled namespace.
12
13#include "fl/fled/color.h"
14#include "fl/stl/int.h"
15#include "fl/stl/noexcept.h"
16#include "fl/stl/span.h"
17#include "fl/stl/string.h"
18#include "fl/stl/vector.h"
19
20namespace fl {
21
22class Fled; // fl/fled/fled.h
23
24namespace fled {
25
27 public:
28 // Header is obligatory. version defaults to 1 (the only v1 we ship);
29 // pixel format defaults to 0 (rgb8).
31
34
35 // Optional JSON sections. Each is merged into the envelope under
36 // its canonical top-level key ("map", "channels"). Pass a JSON
37 // object string (not a primitive); the builder copies the bytes.
40
41 // Declare the source color tuple, emitted as `video.color` with the
42 // spelling FLED_FORMAT.md defines. This is the producer half of the
43 // contract the parser enforces: a payload whose numbers are not the
44 // default tuple has to say so, and hand-written JSON is the only other
45 // way to say it.
46 //
47 // The tuple is written out in full -- all four keys, never a partial
48 // object -- because inheritance of missing keys applies only to pixel
49 // formats that define a default tuple, and a producer should not have to
50 // reason about which those are. `declared` is ignored: calling this is
51 // the declaration.
53
54 // Optional frame payload (raw bytes appended after the envelope).
55 // The builder copies the bytes.
57
58 // Assemble: serializes the envelope, prepends the 12-byte header,
59 // appends the payload, then parses the whole thing through the
60 // canonical Fled::loadFromVector() path so the returned Fled is
61 // indistinguishable from one loaded from disk.
63
64 private:
71};
72
73} // namespace fled
74} // namespace fl
fl::string mScreenMapJson
Definition builder.h:67
FledBuilder & setPixelFormat(fl::u8 fmt) FL_NO_EXCEPT
FledBuilder() FL_NO_EXCEPT
FledBuilder & setVideoColor(const VideoColor &color) FL_NO_EXCEPT
FledBuilder & setChannelsJson(const char *json) FL_NO_EXCEPT
fl::string mVideoColorJson
Definition builder.h:69
fl::vector< fl::u8 > mPayload
Definition builder.h:70
fl::Fled build() const FL_NO_EXCEPT
fl::string mChannelsJson
Definition builder.h:68
FledBuilder & setVersion(fl::u8 v) FL_NO_EXCEPT
FledBuilder & setPayload(fl::span< const fl::u8 > bytes) FL_NO_EXCEPT
FledBuilder & setScreenMapJson(const char *json) FL_NO_EXCEPT
unsigned char u8
Definition stdint.h:131
InputGamut g FL_NO_EXCEPT
Definition rgbw.h:121
Base definition for an LED controller.
Definition crgb.hpp:179