| 172 | } |
| 173 | |
| 174 | inline void showPixelsGammaBitShift(PixelController<RGB_ORDER> & pixels) { |
| 175 | static constexpr fl::u16 kBatchSize = 8; |
| 176 | const fl::u16 n = static_cast<fl::u16>(pixels.size()); |
| 177 | |
| 178 | // Extract uniform color scale and brightness (constant across all pixels) |
| 179 | fl::u8 scale_r, scale_g, scale_b, global_brightness; |
| 180 | #if FASTLED_HD_COLOR_MIXING |
| 181 | pixels.loadRGBScaleAndBrightness(&scale_r, &scale_g, &scale_b, &global_brightness); |
| 182 | #else |
| 183 | pixels.loadAndScaleRGB(&scale_r, &scale_g, &scale_b); |
| 184 | global_brightness = 255; |
| 185 | #endif |
| 186 | const CRGB colors_scale(scale_r, scale_g, scale_b); |
| 187 | |
| 188 | // RGB reorder indices (compile-time constant from RGB_ORDER template param) |
| 189 | const fl::u8 b0_index = (static_cast<int>(RGB_ORDER) >> 6) & 0x3; |
| 190 | const fl::u8 b1_index = (static_cast<int>(RGB_ORDER) >> 3) & 0x3; |
| 191 | const fl::u8 b2_index = static_cast<int>(RGB_ORDER) & 0x3; |
| 192 | |
| 193 | mSPI.select(); |
| 194 | startBoundary(); |
| 195 | |
| 196 | // Process pixels in batches of 8 using stack-allocated buffers |
| 197 | fl::u16 remaining = n; |
| 198 | while (remaining > 0) { |
| 199 | const fl::u16 batch = (remaining < kBatchSize) ? remaining : kBatchSize; |
| 200 | CRGB input_buf[kBatchSize]; |
| 201 | fl::CRGBA5 gamma_buf[kBatchSize]; |
| 202 | |
| 203 | // Copy raw pixel bytes into CRGB input buffer |
| 204 | for (fl::u16 i = 0; i < batch; ++i) { |
| 205 | const fl::u8* raw = pixels.getRawPixelData(); |
| 206 | input_buf[i] = CRGB(raw[0], raw[1], raw[2]); |
| 207 | pixels.advanceData(); |
| 208 | } |
| 209 | |
| 210 | fl::five_bit_hd_gamma_bitshift( |
| 211 | fl::span<const CRGB>(input_buf, batch), colors_scale, global_brightness, |
| 212 | fl::span<fl::CRGBA5>(gamma_buf, batch)); |
| 213 | |
| 214 | for (fl::u16 i = 0; i < batch; ++i) { |
| 215 | const CRGB& rgb = gamma_buf[i].color; |
| 216 | writeLed(gamma_buf[i].brightness_5bit, |
| 217 | rgb.raw[b0_index], rgb.raw[b1_index], rgb.raw[b2_index]); |
| 218 | } |
| 219 | |
| 220 | remaining -= batch; |
| 221 | } |
| 222 | |
| 223 | endBoundary(n); |
| 224 | mSPI.endTransaction(); |
| 225 | mSPI.finalizeTransmission(); |
| 226 | } |
| 227 | |
| 228 | public: |
| 229 | /// Get the protocol-safe padding byte for APA102 |
nothing calls this directly
no test coverage detected