FastLED 3.9.15
Loading...
Searching...
No Matches
strstream.cpp.hpp
Go to the documentation of this file.
1#include "fl/stl/strstream.h"
2#include "crgb.h"
3#include "fl/gfx/tile2x2.h"
4#include "fl/audio/fft/fft.h"
5#include "fl/stl/string.h"
6#include "fl/stl/ios.h"
7#include "fl/stl/charconv.h"
8
9namespace fl {
10
11
13 mStr.append("Tile2x2_u8(");
14 mStr.append(subpixel.bounds());
15 mStr.append(" => ");
16 mStr.append(subpixel.at(0, 0));
17 mStr.append(",");
18 mStr.append(subpixel.at(0, 1));
19 mStr.append(",");
20 mStr.append(subpixel.at(1, 0));
21 mStr.append(",");
22 mStr.append(subpixel.at(1, 1));
23 mStr.append(")");
24 return *this;
25}
26
27// Bins support - show both raw and db bins
29 mStr.append("Bins(bands=");
30 mStr.append(bins.bands());
31 mStr.append(", raw=");
32 (*this) << bins.raw();
33 mStr.append(", db=");
34 (*this) << bins.db();
35 mStr.append(")");
36 return *this;
37}
38
39// Tile2x2_u8_wrap support - delegates to fl::string::append which already knows how to format it
41 mStr.append(tile);
42 return *this;
43}
44
45// Manipulator operator implementations (declared as friends in sstream)
47 ss.mBase = 16;
48 return ss;
49}
50
52 ss.mBase = 10;
53 return ss;
54}
55
57 ss.mBase = 8;
58 return ss;
59}
60
61// Helper method implementations for formatted integer output
63 appendFormatted(fl::i16(val));
64}
65
66void sstream::appendFormatted(fl::i16 val) {
67 appendFormatted(fl::i32(val));
68}
69
70void sstream::appendFormatted(fl::i32 val) {
71 char buf[64] = {0};
72 int len = fl::itoa(val, buf, mBase);
73 mStr.append(buf, len);
74}
75
77 char buf[64] = {0};
78 int len;
79 if (mBase == 16 || mBase == 8) {
80 // For hex/oct, treat as unsigned bit pattern
81 len = fl::utoa64(static_cast<u64>(val), buf, mBase);
82 } else {
83 // For decimal, handle negative sign manually
84 if (val < 0) {
85 mStr.append("-", 1);
86 len = fl::utoa64(static_cast<u64>(-val), buf, mBase);
87 } else {
88 len = fl::utoa64(static_cast<u64>(val), buf, mBase);
89 }
90 }
91 mStr.append(buf, len);
92}
93
94void sstream::appendFormatted(fl::u16 val) {
95 appendFormatted(fl::u32(val));
96}
97
98void sstream::appendFormatted(fl::u32 val) {
99 char buf[64] = {0};
100 int len = fl::utoa32(val, buf, mBase);
101 mStr.append(buf, len);
102}
103
105 char buf[64] = {0};
106 int len = fl::utoa64(val, buf, mBase);
107 mStr.append(buf, len);
108}
109
110} // namespace fl
u8 & at(int x, int y)
Definition tile2x2.h:34
rect< u16 > bounds() const
bounds => [begin_x, end_x) (where end_x is exclusive)
fl::span< const float > db() const FL_NOEXCEPT
Definition fft.cpp.hpp:65
fl::span< const float > raw() const FL_NOEXCEPT
Definition fft.cpp.hpp:63
fl::size bands() const FL_NOEXCEPT
Definition fft.cpp.hpp:61
string mStr
Definition strstream.h:369
void appendFormatted(fl::i8 val) FL_NOEXCEPT
sstream & operator<<(const CRGB &rgb) FL_NOEXCEPT
Definition strstream.h:46
sstream() FL_NOEXCEPT=default
signed char i8
Definition s16x16x4.h:131
int itoa(i32 value, char *sp, int radix)
Convert signed 32-bit integer to string buffer in given radix.
int utoa64(u64 value, char *sp, int radix)
Convert unsigned 64-bit integer to string buffer in given radix.
ostream & operator<<(ostream &os, const hex_t &) FL_NOEXCEPT
int utoa32(u32 value, char *sp, int radix)
Convert unsigned 32-bit integer to string buffer in given radix.
fl::i64 i64
Definition s16x16x4.h:222
fl::u64 u64
Definition s16x16x4.h:221
Base definition for an LED controller.
Definition crgb.hpp:179