30 #if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
38 const uint16_t c_dmaBytesPerPixelBytes = 4;
40 class NeoEsp32I2sSpeedWs2812x
43 const static uint32_t I2sSampleRate = 100000;
44 const static uint16_t ByteSendTimeUs = 10;
45 const static uint16_t ResetTimeUs = 300;
48 class NeoEsp32I2sSpeedSk6812
51 const static uint32_t I2sSampleRate = 100000;
52 const static uint16_t ByteSendTimeUs = 10;
53 const static uint16_t ResetTimeUs = 80;
56 class NeoEsp32I2sSpeedTm1814
59 const static uint32_t I2sSampleRate = 100000;
60 const static uint16_t ByteSendTimeUs = 10;
61 const static uint16_t ResetTimeUs = 200;
64 class NeoEsp32I2sSpeedTm1914
67 const static uint32_t I2sSampleRate = 100000;
68 const static uint16_t ByteSendTimeUs = 10;
69 const static uint16_t ResetTimeUs = 200;
72 class NeoEsp32I2sSpeedTm1829
75 const static uint32_t I2sSampleRate = 100000;
76 const static uint16_t ByteSendTimeUs = 10;
77 const static uint16_t ResetTimeUs = 200;
80 class NeoEsp32I2sSpeed800Kbps
83 const static uint32_t I2sSampleRate = 100000;
84 const static uint16_t ByteSendTimeUs = 10;
85 const static uint16_t ResetTimeUs = 50;
88 class NeoEsp32I2sSpeed400Kbps
91 const static uint32_t I2sSampleRate = 50000;
92 const static uint16_t ByteSendTimeUs = 20;
93 const static uint16_t ResetTimeUs = 50;
96 class NeoEsp32I2sSpeedApa106
99 const static uint32_t I2sSampleRate = 76000;
100 const static uint16_t ByteSendTimeUs = 14;
101 const static uint16_t ResetTimeUs = 50;
104 class NeoEsp32I2sBusZero
107 NeoEsp32I2sBusZero() {};
109 const static uint8_t I2sBusNumber = 0;
112 class NeoEsp32I2sBusOne
115 NeoEsp32I2sBusOne() {};
117 const static uint8_t I2sBusNumber = 1;
121 class NeoEsp32I2sBusN
125 I2sBusNumber(static_cast<uint8_t>(channel))
128 NeoEsp32I2sBusN() =
delete;
130 const uint8_t I2sBusNumber;
133 class NeoEsp32I2sNotInverted
136 const static bool Inverted =
false;
139 class NeoEsp32I2sInverted
142 const static bool Inverted =
true;
145 template<
typename T_SPEED,
typename T_BUS,
typename T_INVERT>
class NeoEsp32I2sMethodBase
150 NeoEsp32I2sMethodBase(uint8_t pin, uint16_t pixelCount,
size_t elementSize,
size_t settingsSize) :
151 _sizeData(pixelCount * elementSize + settingsSize),
154 construct(pixelCount, elementSize, settingsSize);
157 NeoEsp32I2sMethodBase(uint8_t pin, uint16_t pixelCount,
size_t elementSize,
size_t settingsSize,
NeoBusChannel channel) :
158 _sizeData(pixelCount * elementSize + settingsSize),
162 construct(pixelCount, elementSize, settingsSize);
165 ~NeoEsp32I2sMethodBase()
167 while (!IsReadyToUpdate())
172 i2sDeinit(_bus.I2sBusNumber);
174 gpio_matrix_out(_pin, 0x100,
false,
false);
175 pinMode(_pin, INPUT);
178 heap_caps_free(_i2sBuffer);
181 bool IsReadyToUpdate()
const
183 return (i2sWriteDone(_bus.I2sBusNumber));
188 size_t dmaBlockCount = (_i2sBufferSize + I2S_DMA_MAX_DATA_LEN - 1) / I2S_DMA_MAX_DATA_LEN;
190 i2sInit(_bus.I2sBusNumber,
193 T_SPEED::I2sSampleRate,
199 i2sSetPins(_bus.I2sBusNumber, _pin, -1, -1, T_INVERT::Inverted);
205 while (!IsReadyToUpdate())
212 i2sWrite(_bus.I2sBusNumber);
221 uint8_t* getData()
const
226 size_t getDataSize()
const
231 void applySettings([[maybe_unused]]
const SettingsObject& settings)
236 const size_t _sizeData;
242 size_t _i2sBufferSize;
245 void construct(uint16_t pixelCount,
size_t elementSize,
size_t settingsSize)
253 uint16_t dmaSettingsSize = c_dmaBytesPerPixelBytes * settingsSize;
254 uint16_t dmaPixelSize = c_dmaBytesPerPixelBytes * elementSize;
255 uint16_t resetSize = c_dmaBytesPerPixelBytes * T_SPEED::ResetTimeUs / T_SPEED::ByteSendTimeUs;
257 _i2sBufferSize = pixelCount * dmaPixelSize + dmaSettingsSize + resetSize;
260 uint32_t alignment = _i2sBufferSize % 4;
263 _i2sBufferSize += 4 - alignment;
266 _data =
static_cast<uint8_t*
>(malloc(_sizeData));
269 _i2sBuffer =
static_cast<uint8_t*
>(heap_caps_malloc(_i2sBufferSize, MALLOC_CAP_DMA));
272 memset(_i2sBuffer, 0x00, _i2sBufferSize);
277 const uint16_t bitpatterns[16] =
279 0b1000100010001000, 0b1000100010001110, 0b1000100011101000, 0b1000100011101110,
280 0b1000111010001000, 0b1000111010001110, 0b1000111011101000, 0b1000111011101110,
281 0b1110100010001000, 0b1110100010001110, 0b1110100011101000, 0b1110100011101110,
282 0b1110111010001000, 0b1110111010001110, 0b1110111011101000, 0b1110111011101110,
285 uint16_t* pDma =
reinterpret_cast<uint16_t*
>(_i2sBuffer);
286 uint8_t* pEnd = _data + _sizeData;
287 for (uint8_t* pPixel = _data; pPixel < pEnd; pPixel++)
289 *(pDma++) = bitpatterns[((*pPixel) & 0x0f)];
290 *(pDma++) = bitpatterns[((*pPixel) >> 4) & 0x0f];
295 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedWs2812x, NeoEsp32I2sBusZero, NeoEsp32I2sNotInverted> NeoEsp32I2s0Ws2812xMethod;
296 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedSk6812, NeoEsp32I2sBusZero, NeoEsp32I2sNotInverted> NeoEsp32I2s0Sk6812Method;
297 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1814, NeoEsp32I2sBusZero, NeoEsp32I2sInverted> NeoEsp32I2s0Tm1814Method;
298 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1829, NeoEsp32I2sBusZero, NeoEsp32I2sInverted> NeoEsp32I2s0Tm1829Method;
299 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1914, NeoEsp32I2sBusZero, NeoEsp32I2sInverted> NeoEsp32I2s0Tm1914Method;
300 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed800Kbps, NeoEsp32I2sBusZero, NeoEsp32I2sNotInverted> NeoEsp32I2s0800KbpsMethod;
301 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed400Kbps, NeoEsp32I2sBusZero, NeoEsp32I2sNotInverted> NeoEsp32I2s0400KbpsMethod;
302 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedApa106, NeoEsp32I2sBusZero, NeoEsp32I2sNotInverted> NeoEsp32I2s0Apa106Method;
305 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedWs2812x, NeoEsp32I2sBusZero, NeoEsp32I2sInverted> NeoEsp32I2s0Ws2812xInvertedMethod;
306 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedSk6812, NeoEsp32I2sBusZero, NeoEsp32I2sInverted> NeoEsp32I2s0Sk6812InvertedMethod;
307 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1814, NeoEsp32I2sBusZero, NeoEsp32I2sNotInverted> NeoEsp32I2s0Tm1814InvertedMethod;
308 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1914, NeoEsp32I2sBusZero, NeoEsp32I2sNotInverted> NeoEsp32I2s0Tm1914InvertedMethod;
309 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1829, NeoEsp32I2sBusZero, NeoEsp32I2sNotInverted> NeoEsp32I2s0Tm1829InvertedMethod;
310 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed800Kbps, NeoEsp32I2sBusZero, NeoEsp32I2sInverted> NeoEsp32I2s0800KbpsInvertedMethod;
311 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed400Kbps, NeoEsp32I2sBusZero, NeoEsp32I2sInverted> NeoEsp32I2s0400KbpsInvertedMethod;
312 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedApa106, NeoEsp32I2sBusZero, NeoEsp32I2sInverted> NeoEsp32I2s0Apa106InvertedMethod;
314 #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
317 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedWs2812x, NeoEsp32I2sBusOne, NeoEsp32I2sNotInverted> NeoEsp32I2s1Ws2812xMethod;
318 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedSk6812, NeoEsp32I2sBusOne, NeoEsp32I2sNotInverted> NeoEsp32I2s1Sk6812Method;
319 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1814, NeoEsp32I2sBusOne, NeoEsp32I2sInverted> NeoEsp32I2s1Tm1814Method;
320 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1829, NeoEsp32I2sBusOne, NeoEsp32I2sInverted> NeoEsp32I2s1Tm1829Method;
321 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1914, NeoEsp32I2sBusOne, NeoEsp32I2sInverted> NeoEsp32I2s1Tm1914Method;
322 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed800Kbps, NeoEsp32I2sBusOne, NeoEsp32I2sNotInverted> NeoEsp32I2s1800KbpsMethod;
323 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed400Kbps, NeoEsp32I2sBusOne, NeoEsp32I2sNotInverted> NeoEsp32I2s1400KbpsMethod;
324 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedApa106, NeoEsp32I2sBusOne, NeoEsp32I2sNotInverted> NeoEsp32I2s1Apa106Method;
326 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedWs2812x, NeoEsp32I2sBusOne, NeoEsp32I2sInverted> NeoEsp32I2s1Ws2812xInvertedMethod;
327 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedSk6812, NeoEsp32I2sBusOne, NeoEsp32I2sInverted> NeoEsp32I2s1Sk6812InvertedMethod;
328 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1814, NeoEsp32I2sBusOne, NeoEsp32I2sNotInverted> NeoEsp32I2s1Tm1814InvertedMethod;
329 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1829, NeoEsp32I2sBusOne, NeoEsp32I2sNotInverted> NeoEsp32I2s1Tm1829InvertedMethod;
330 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1914, NeoEsp32I2sBusOne, NeoEsp32I2sNotInverted> NeoEsp32I2s1Tm1914InvertedMethod;
331 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed800Kbps, NeoEsp32I2sBusOne, NeoEsp32I2sInverted> NeoEsp32I2s1800KbpsInvertedMethod;
332 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed400Kbps, NeoEsp32I2sBusOne, NeoEsp32I2sInverted> NeoEsp32I2s1400KbpsInvertedMethod;
333 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedApa106, NeoEsp32I2sBusOne, NeoEsp32I2sInverted> NeoEsp32I2s1Apa106InvertedMethod;
336 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedWs2812x, NeoEsp32I2sBusN, NeoEsp32I2sNotInverted> NeoEsp32I2sNWs2812xMethod;
337 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedSk6812, NeoEsp32I2sBusN, NeoEsp32I2sNotInverted> NeoEsp32I2sNSk6812Method;
338 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1814, NeoEsp32I2sBusN, NeoEsp32I2sInverted> NeoEsp32I2sNTm1814Method;
339 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1829, NeoEsp32I2sBusN, NeoEsp32I2sInverted> NeoEsp32I2sNTm1829Method;
340 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1914, NeoEsp32I2sBusN, NeoEsp32I2sInverted> NeoEsp32I2sNTm1914Method;
341 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed800Kbps, NeoEsp32I2sBusN, NeoEsp32I2sNotInverted> NeoEsp32I2sN800KbpsMethod;
342 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed400Kbps, NeoEsp32I2sBusN, NeoEsp32I2sNotInverted> NeoEsp32I2sN400KbpsMethod;
343 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedApa106, NeoEsp32I2sBusN, NeoEsp32I2sNotInverted> NeoEsp32I2sNApa106Method;
345 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedWs2812x, NeoEsp32I2sBusN, NeoEsp32I2sInverted> NeoEsp32I2sNWs2812xInvertedMethod;
346 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedSk6812, NeoEsp32I2sBusN, NeoEsp32I2sInverted> NeoEsp32I2sNSk6812InvertedMethod;
347 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1814, NeoEsp32I2sBusN, NeoEsp32I2sNotInverted> NeoEsp32I2sNTm1814InvertedMethod;
348 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1829, NeoEsp32I2sBusN, NeoEsp32I2sNotInverted> NeoEsp32I2sNTm1829InvertedMethod;
349 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedTm1914, NeoEsp32I2sBusN, NeoEsp32I2sNotInverted> NeoEsp32I2sNTm1914InvertedMethod;
350 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed800Kbps, NeoEsp32I2sBusN, NeoEsp32I2sInverted> NeoEsp32I2sN800KbpsInvertedMethod;
351 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed400Kbps, NeoEsp32I2sBusN, NeoEsp32I2sInverted> NeoEsp32I2sN400KbpsInvertedMethod;
352 typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedApa106, NeoEsp32I2sBusN, NeoEsp32I2sInverted> NeoEsp32I2sNApa106InvertedMethod;
356 #if !defined(LUMITRONIX_IFLEX_ESP32_RMT_DEFAULT) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
360 typedef NeoEsp32I2s1Ws2812xMethod NeoWs2813Method;
361 typedef NeoEsp32I2s1Ws2812xMethod NeoWs2812xMethod;
362 typedef NeoEsp32I2s1800KbpsMethod NeoWs2812Method;
363 typedef NeoEsp32I2s1Ws2812xMethod NeoWs2811Method;
364 typedef NeoEsp32I2s1Ws2812xMethod NeoWs2816Method;
365 typedef NeoEsp32I2s1Sk6812Method NeoSk6812Method;
366 typedef NeoEsp32I2s1Tm1814Method NeoTm1814Method;
367 typedef NeoEsp32I2s1Tm1829Method NeoTm1829Method;
368 typedef NeoEsp32I2s1Tm1914Method NeoTm1914Method;
369 typedef NeoEsp32I2s1Sk6812Method NeoLc8812Method;
370 typedef NeoEsp32I2s1Apa106Method NeoApa106Method;
372 typedef NeoEsp32I2s1Ws2812xMethod Neo800KbpsMethod;
373 typedef NeoEsp32I2s1400KbpsMethod Neo400KbpsMethod;
375 typedef NeoEsp32I2s1Ws2812xInvertedMethod NeoWs2813InvertedMethod;
376 typedef NeoEsp32I2s1Ws2812xInvertedMethod NeoWs2812xInvertedMethod;
377 typedef NeoEsp32I2s1Ws2812xInvertedMethod NeoWs2811InvertedMethod;
378 typedef NeoEsp32I2s1Ws2812xInvertedMethod NeoWs2816InvertedMethod;
379 typedef NeoEsp32I2s1800KbpsInvertedMethod NeoWs2812InvertedMethod;
380 typedef NeoEsp32I2s1Sk6812InvertedMethod NeoSk6812InvertedMethod;
381 typedef NeoEsp32I2s1Tm1814InvertedMethod NeoTm1814InvertedMethod;
382 typedef NeoEsp32I2s1Tm1829InvertedMethod NeoTm1829InvertedMethod;
383 typedef NeoEsp32I2s1Tm1914InvertedMethod NeoTm1914InvertedMethod;
384 typedef NeoEsp32I2s1Sk6812InvertedMethod NeoLc8812InvertedMethod;
385 typedef NeoEsp32I2s1Apa106InvertedMethod NeoApa106InvertedMethod;
387 typedef NeoEsp32I2s1Ws2812xInvertedMethod Neo800KbpsInvertedMethod;
388 typedef NeoEsp32I2s1400KbpsInvertedMethod Neo400KbpsInvertedMethod;
NeoBusChannel
Definition: NeoBusChannel.h:12
Definition: NeoSettings.h:29