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

Function fillBuffer

src/platforms/esp/32/drivers/i2s/clockless_i2s_esp32.h:227–268  ·  view source on GitHub ↗

Fill DMA buffer * * This is where the real work happens: take a row of pixels (one * from each strip), transpose and encode the bits, and store * them in the DMA buffer for the I2S peripheral to read. */

Source from the content-addressed store, hash-verified

225 * them in the DMA buffer for the I2S peripheral to read.
226 */
227 static void fillBuffer() FL_NOEXCEPT {
228 // -- Alternate between buffers
229 volatile u32 *buf = (u32 *)dmaBuffers[gCurBuffer]->buffer;
230 gCurBuffer = (gCurBuffer + 1) % NUM_DMA_BUFFERS;
231
232 // -- Get the requested pixel from each controller. Store the
233 // data for each color channel in a separate array.
234 u32 has_data_mask = 0;
235 for (int i = 0; i < gNumControllers; ++i) {
236 // -- Store the pixels in reverse controller order starting at index
237 // 23
238 // This causes the bits to come out in the right position after
239 // we transpose them.
240 int bit_index = 23 - i;
241 ClocklessI2S *pController =
242 static_cast<ClocklessI2S *>(gControllers[i]);
243 if (pController->mPixels->has(1)) {
244 gPixelRow[0][bit_index] = pController->mPixels->loadAndScale0();
245 gPixelRow[1][bit_index] = pController->mPixels->loadAndScale1();
246 gPixelRow[2][bit_index] = pController->mPixels->loadAndScale2();
247 pController->mPixels->advanceData();
248 pController->mPixels->stepDithering();
249
250 // -- Record that this controller still has data to send
251 has_data_mask |= (1 << (i + 8));
252 }
253 }
254
255 // -- None of the strips has data? We are done.
256 if (has_data_mask == 0) {
257 gDoneFilling = true;
258 return;
259 }
260#if FASTLED_ESP32_I2S_NUM_DMA_BUFFERS > 2
261 gCntBuffer++;
262#endif
263 // -- Transpose and encode the pixel data for the DMA buffer
264 // int buf_index = 0;
265 for (int channel = 0; channel < NUM_COLOR_CHANNELS; ++channel) {
266 i2s_transpose_and_encode(channel, has_data_mask, buf);
267 }
268 }
269
270 // -- Show pixels
271 // This is the main entry point for the controller.

Callers 2

decodeNextFrameMethod · 0.85
showPixelsFunction · 0.85

Calls 4

i2s_transpose_and_encodeFunction · 0.85
hasMethod · 0.45
advanceDataMethod · 0.45
stepDitheringMethod · 0.45

Tested by

no test coverage detected