| 33 | /// @note LPD6803 uses RGB wire order: pixel[0]=Red, pixel[1]=Green, pixel[2]=Blue |
| 34 | template <typename InputIterator, typename OutputIterator> |
| 35 | void encodeLPD6803(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT { |
| 36 | // Start boundary: 4 bytes of 0x00 |
| 37 | *out++ = 0x00; |
| 38 | *out++ = 0x00; |
| 39 | *out++ = 0x00; |
| 40 | *out++ = 0x00; |
| 41 | |
| 42 | // LED data: 16-bit format (1bbbbbgggggrrrrr, count as we go) |
| 43 | size_t num_leds = 0; |
| 44 | while (first != last) { |
| 45 | const fl::array<u8, BYTES_PER_PIXEL_RGB>& pixel = *first; |
| 46 | |
| 47 | // RGB order: 0=R, 1=G, 2=B |
| 48 | u16 command = lpd6803EncodeRGB(pixel[0], pixel[1], pixel[2]); |
| 49 | |
| 50 | *out++ = static_cast<u8>(command >> 8); // MSB |
| 51 | *out++ = static_cast<u8>(command & 0xFF); // LSB |
| 52 | |
| 53 | ++first; |
| 54 | ++num_leds; |
| 55 | } |
| 56 | |
| 57 | // End boundary: (num_leds / 32) DWords of 0xFF000000 |
| 58 | size_t end_dwords = (num_leds / 32); |
| 59 | for (size_t i = 0; i < end_dwords; i++) { |
| 60 | *out++ = 0xFF; |
| 61 | *out++ = 0x00; |
| 62 | *out++ = 0x00; |
| 63 | *out++ = 0x00; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | } // namespace fl |
no test coverage detected