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

Function verifyPixels16bitRGBW

tests/fl/chipsets/ucs7604.cpp:259–287  ·  view source on GitHub ↗

Helper to verify pixel data (RGBW 16-bit mode) Verifies that the byte stream contains the expected RGBW pixel data Note: UCS7604 pads data BEFORE LED values, so padding comes right after preamble

Source from the content-addressed store, hash-verified

257/// Verifies that the byte stream contains the expected RGBW pixel data
258/// Note: UCS7604 pads data BEFORE LED values, so padding comes right after preamble
259void verifyPixels16bitRGBW(fl::span<const uint8_t> bytes, fl::span<const RGBW16> pixels, size_t expected_padding) {
260 const size_t PREAMBLE_SIZE = 15;
261 const size_t BYTES_PER_PIXEL = 8; // RGBW 16-bit
262
263 // Verify padding bytes are 0x00 (padding comes after preamble, before LED data)
264 for (size_t i = 0; i < expected_padding; i++) {
265 FL_CHECK_EQ(bytes[PREAMBLE_SIZE + i], 0x00);
266 }
267
268 // Verify pixel data (starts after preamble + padding)
269 for (size_t i = 0; i < pixels.size(); i++) {
270 size_t byte_offset = PREAMBLE_SIZE + expected_padding + (i * BYTES_PER_PIXEL);
271
272 uint16_t r16 = pixels[i].r;
273 uint16_t g16 = pixels[i].g;
274 uint16_t b16 = pixels[i].b;
275 uint16_t w16 = pixels[i].w;
276
277 // Verify big-endian 16-bit values
278 FL_CHECK_EQ(bytes[byte_offset + 0], r16 >> 8); // R high
279 FL_CHECK_EQ(bytes[byte_offset + 1], r16 & 0xFF); // R low
280 FL_CHECK_EQ(bytes[byte_offset + 2], g16 >> 8); // G high
281 FL_CHECK_EQ(bytes[byte_offset + 3], g16 & 0xFF); // G low
282 FL_CHECK_EQ(bytes[byte_offset + 4], b16 >> 8); // B high
283 FL_CHECK_EQ(bytes[byte_offset + 5], b16 & 0xFF); // B low
284 FL_CHECK_EQ(bytes[byte_offset + 6], w16 >> 8); // W high
285 FL_CHECK_EQ(bytes[byte_offset + 7], w16 & 0xFF); // W low
286 }
287}
288
289/// Generic test function for UCS7604 controllers
290/// Tests preamble, color order conversion, and pixel data

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected