MCPcopy Create free account
hub / github.com/FastLED/FastLED / writeHex

Function writeHex

src/fl/wdt/watchdog.cpp.hpp:35–46  ·  view source on GitHub ↗

Write `value` as a lowercase hex string into `out`, prefixed with "0x". Returns bytes written (always <= 10, since u32 max is 0xFFFFFFFF = 8 hex digits + 2 prefix chars). Does not write a NUL. Truncates if out is small.

Source from the content-addressed store, hash-verified

33// Returns bytes written (always <= 10, since u32 max is 0xFFFFFFFF = 8 hex
34// digits + 2 prefix chars). Does not write a NUL. Truncates if out is small.
35inline fl::size writeHex(fl::span<char> out, fl::u32 value) FL_NOEXCEPT {
36 char tmp[10];
37 tmp[0] = '0';
38 tmp[1] = 'x';
39 static const char hex[] = "0123456789abcdef";
40 for (int i = 7; i >= 0; --i) {
41 tmp[2 + (7 - i)] = hex[(value >> (i * 4)) & 0xFu];
42 }
43 fl::size n = (out.size() < 10) ? out.size() : 10;
44 for (fl::size i = 0; i < n; ++i) out[i] = tmp[i];
45 return n;
46}
47
48// Copy a string_view into out[]. Returns bytes copied, truncated to out.size().
49inline fl::size writeView(fl::span<char> out, fl::string_view sv) FL_NOEXCEPT {

Callers 1

describeMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected