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

Function encodeLedByte

tests/platforms/esp/32/drivers/parlio/parlio_driver.cpp:65–84  ·  view source on GitHub ↗

@brief Encode a single LED byte (0x00-0xFF) into 32-bit PARLIO waveform @param byte LED color byte to encode (R, G, or B value) @return 32-bit waveform for PARLIO transmission WS2812 timing with PARLIO 4-tick encoding: - Bit 0: 0b1000 (312.5ns high, 937.5ns low) - Bit 1: 0b1110 (937.5ns high, 312.5ns low) Each byte produces 8 x 4 = 32 bits of output. MSB is transmitted first (standard WS2812 pro

Source from the content-addressed store, hash-verified

63/// Each byte produces 8 x 4 = 32 bits of output.
64/// MSB is transmitted first (standard WS2812 protocol).
65static uint32_t encodeLedByte(uint8_t byte) {
66 uint32_t result = 0;
67
68 // Process each bit (MSB first)
69 for (int i = 7; i >= 0; i--) {
70 // Shift result to make room for 4 new bits
71 result <<= 4;
72
73 // Check bit value
74 if (byte & (1 << i)) {
75 // Bit is 1: encode as 0b1110 (hex: 0xE)
76 result |= 0xE;
77 } else {
78 // Bit is 0: encode as 0b1000 (hex: 0x8)
79 result |= 0x8;
80 }
81 }
82
83 return result;
84}
85
86} // anonymous namespace
87

Callers 1

FL_TEST_FILEFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected