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

Function rgbToHex

src/fl/control/wled/json_helpers.cpp.hpp:47–64  ·  view source on GitHub ↗

Helper function to convert RGB to hex string

Source from the content-addressed store, hash-verified

45
46// Helper function to convert RGB to hex string
47fl::string rgbToHex(u8 r, u8 g, u8 b) {
48 fl::string hex;
49 hex.reserve(6);
50
51 auto byteToHex = [](u8 val) -> fl::string {
52 const char hexChars[] = "0123456789ABCDEF";
53 fl::string result;
54 result.push_back(hexChars[val >> 4]);
55 result.push_back(hexChars[val & 0x0F]);
56 return result;
57 };
58
59 hex += byteToHex(r);
60 hex += byteToHex(g);
61 hex += byteToHex(b);
62
63 return hex;
64}
65
66// Helper function to parse segment fields
67void parseSegmentFields(const fl::json& segJson, WLEDSegment& seg) {

Callers 1

getStateMethod · 0.85

Calls 2

reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected