FastLED 3.9.15
Loading...
Searching...
No Matches
bitset.cpp.hpp
Go to the documentation of this file.
1#include "fl/stl/bitset.h"
3
4#include "fl/stl/string.h"
5
6namespace fl {
7
8namespace detail {
9void to_string(const fl::u16 *bit_data, fl::u32 bit_count, string* dst) {
10 fl::string& result = *dst;
11 constexpr fl::u32 bits_per_block = 8 * sizeof(fl::u16); // 16 bits per block
12
13 for (fl::u32 i = 0; i < bit_count; ++i) {
14 const fl::u32 block_idx = i / bits_per_block;
15 const fl::u32 bit_offset = i % bits_per_block;
16
17 // Extract the bit from the block
18 bool bit_value = (bit_data[block_idx] >> bit_offset) & 1;
19 result.append(bit_value ? "1" : "0");
20 }
21}
22} // namespace detail
23
24// Implementation for bitset_dynamic::to_string
25void bitset_dynamic::to_string(string* dst) const {
26 detail::to_string(_blocks.get(), _size, dst);
27}
28
29} // namespace fl
fl::unique_ptr< block_type[]> _blocks
FL_DISABLE_WARNING_POP void to_string(string *dst) const FL_NOEXCEPT
void to_string(const fl::u16 *bit_data, fl::u32 bit_count, string *dst)
Definition bitset.cpp.hpp:9
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_traits.h:48
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
Base definition for an LED controller.
Definition crgb.hpp:179