@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
| 63 | /// Each byte produces 8 x 4 = 32 bits of output. |
| 64 | /// MSB is transmitted first (standard WS2812 protocol). |
| 65 | static 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 |