29 #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
31 #if defined(ARDUINO_ARCH_ESP8266)
32 #include <eagle_soc.h>
34 #if defined(CONFIG_IDF_TARGET_ESP32C3)
35 #define CYCLES_LOOPTEST (1)
36 #elif defined(CONFIG_IDF_TARGET_ESP32S3)
37 #define CYCLES_LOOPTEST (2)
39 #define CYCLES_LOOPTEST (4)
42 extern void neoEspBitBangWriteSpacingPixels(
const uint8_t* pixels,
53 class NeoEspNotInverted
56 const static uint8_t IdleLevel = LOW;
62 const static uint8_t IdleLevel = HIGH;
65 class NeoEspBitBangSpeedWs2811
68 const static uint32_t T0H = (F_CPU / 3333333 - CYCLES_LOOPTEST);
69 const static uint32_t T1H = (F_CPU / 1052632 - CYCLES_LOOPTEST);
70 const static uint32_t Period = (F_CPU / 800000 - CYCLES_LOOPTEST);
72 static const uint32_t ResetTimeUs = 300;
73 const static uint32_t TInterPixel = 0;
76 class NeoEspBitBangSpeedWs2812x
79 const static uint32_t T0H = (F_CPU / 2500000 - CYCLES_LOOPTEST);
80 const static uint32_t T1H = (F_CPU / 1250000 - CYCLES_LOOPTEST);
81 const static uint32_t Period = (F_CPU / 800000 - CYCLES_LOOPTEST);
83 static const uint32_t ResetTimeUs = 300;
84 const static uint32_t TInterPixel = 0;
87 class NeoEspBitBangSpeedSk6812
90 const static uint32_t T0H = (F_CPU / 2500000 - CYCLES_LOOPTEST);
91 const static uint32_t T1H = (F_CPU / 1250000 - CYCLES_LOOPTEST);
92 const static uint32_t Period = (F_CPU / 800000 - CYCLES_LOOPTEST);
94 static const uint32_t ResetTimeUs = 80;
95 const static uint32_t TInterPixel = 0;
99 class NeoEspBitBangSpeedTm1814
102 const static uint32_t T0H = (F_CPU / 2916666 - CYCLES_LOOPTEST);
103 const static uint32_t T1H = (F_CPU / 1666666 - CYCLES_LOOPTEST);
104 const static uint32_t Period = (F_CPU / 800000 - CYCLES_LOOPTEST);
106 static const uint32_t ResetTimeUs = 200;
107 const static uint32_t TInterPixel = 0;
111 class NeoEspBitBangSpeedTm1829
114 const static uint32_t T0H = (F_CPU / 3333333 - CYCLES_LOOPTEST);
115 const static uint32_t T1H = (F_CPU / 1250000 - CYCLES_LOOPTEST);
116 const static uint32_t Period = (F_CPU / 800000 - CYCLES_LOOPTEST);
118 static const uint32_t ResetTimeUs = 200;
119 const static uint32_t TInterPixel = 0;
122 class NeoEspBitBangSpeed800Kbps
125 const static uint32_t T0H = (F_CPU / 2500000 - CYCLES_LOOPTEST);
126 const static uint32_t T1H = (F_CPU / 1250000 - CYCLES_LOOPTEST);
127 const static uint32_t Period = (F_CPU / 800000 - CYCLES_LOOPTEST);
129 static const uint32_t ResetTimeUs = 50;
130 const static uint32_t TInterPixel = 0;
133 class NeoEspBitBangSpeed400Kbps
136 const static uint32_t T0H = (F_CPU / 2000000 - CYCLES_LOOPTEST);
137 const static uint32_t T1H = (F_CPU / 833333 - CYCLES_LOOPTEST);
138 const static uint32_t Period = (F_CPU / 400000 - CYCLES_LOOPTEST);
140 static const uint32_t ResetTimeUs = 50;
141 const static uint32_t TInterPixel = 0;
144 class NeoEspBitBangSpeedApa106
147 const static uint32_t T0H = (F_CPU / 2857143 - CYCLES_LOOPTEST);
148 const static uint32_t T1H = (F_CPU / 740741 - CYCLES_LOOPTEST);
149 const static uint32_t Period = (F_CPU / 606061 - CYCLES_LOOPTEST);
151 static const uint32_t ResetTimeUs = 50;
152 const static uint32_t TInterPixel = 0;
155 class NeoEspBitBangSpeedIntertek
158 const static uint32_t T0H = (F_CPU / 2500000 - CYCLES_LOOPTEST);
159 const static uint32_t T1H = (F_CPU / 1250000 - CYCLES_LOOPTEST);
160 const static uint32_t Period = (F_CPU / 800000 - CYCLES_LOOPTEST);
162 const static uint32_t ResetTimeUs = 12470;
163 const static uint32_t TInterPixel = (F_CPU / 50000);
167 template<
typename T_SPEED,
typename T_INVERTED>
class NeoEspBitBangEncode :
public T_SPEED,
public T_INVERTED
170 static void WritePixels(uint8_t pin,
175 neoEspBitBangWriteSpacingPixels(data,
182 T_SPEED::TInterPixel,
183 T_INVERTED::IdleLevel);
187 template<
typename T_ENCODER>
class NeoEspBitBangMethodBase
192 NeoEspBitBangMethodBase(uint8_t pin, uint16_t pixelCount,
size_t elementSize,
size_t settingsSize) :
193 _sizePixel(elementSize),
194 _sizeData(pixelCount * elementSize + settingsSize),
197 pinMode(pin, OUTPUT);
199 _data =
static_cast<uint8_t*
>(malloc(_sizeData));
203 ~NeoEspBitBangMethodBase()
205 pinMode(_pin, INPUT);
210 bool IsReadyToUpdate()
const
212 uint32_t delta = micros() - _endTime;
214 return (delta >= T_ENCODER::ResetTimeUs);
219 digitalWrite(_pin, T_ENCODER::IdleLevel);
232 while (!IsReadyToUpdate())
238 #if defined(ARDUINO_ARCH_ESP32)
240 portMUX_TYPE updateMux = portMUX_INITIALIZER_UNLOCKED;
242 portENTER_CRITICAL(&updateMux);
247 T_ENCODER::WritePixels(_pin,
252 #if defined(ARDUINO_ARCH_ESP32)
253 portEXIT_CRITICAL(&updateMux);
268 uint8_t* getData()
const
273 size_t getDataSize()
const
278 void applySettings([[maybe_unused]]
const SettingsObject& settings)
283 const size_t _sizePixel;
284 const size_t _sizeData;
292 #if defined(ARDUINO_ARCH_ESP32)
294 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedWs2811, NeoEspNotInverted>> NeoEsp32BitBangWs2811Method;
295 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedWs2812x, NeoEspNotInverted>> NeoEsp32BitBangWs2812xMethod;
296 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedSk6812, NeoEspNotInverted>> NeoEsp32BitBangSk6812Method;
297 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedTm1814, NeoEspInverted>> NeoEsp32BitBangTm1814Method;
298 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedTm1829, NeoEspInverted>> NeoEsp32BitBangTm1829Method;
299 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeed800Kbps, NeoEspNotInverted>> NeoEsp32BitBang800KbpsMethod;
300 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeed400Kbps, NeoEspNotInverted>> NeoEsp32BitBang400KbpsMethod;
301 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedApa106, NeoEspNotInverted>> NeoEsp32BitBangApa106Method;
302 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedIntertek, NeoEspNotInverted>> NeoEsp32BitBangIntertekMethod;
304 typedef NeoEsp32BitBangWs2812xMethod NeoEsp32BitBangWs2813Method;
305 typedef NeoEsp32BitBang800KbpsMethod NeoEsp32BitBangWs2812Method;
306 typedef NeoEsp32BitBangWs2812xMethod NeoEsp32BitBangWs2816Method;
307 typedef NeoEsp32BitBangTm1814Method NeoEsp32BitBangTm1914Method;
308 typedef NeoEsp32BitBangSk6812Method NeoEsp32BitBangLc8812Method;
310 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedWs2811, NeoEspInverted>> NeoEsp32BitBangWs2811InvertedMethod;
311 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedWs2812x, NeoEspInverted>> NeoEsp32BitBangWs2812xInvertedMethod;
312 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedSk6812, NeoEspInverted>> NeoEsp32BitBangSk6812InvertedMethod;
313 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedTm1814, NeoEspNotInverted>> NeoEsp32BitBangTm1814InvertedMethod;
314 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedTm1829, NeoEspNotInverted>> NeoEsp32BitBangTm1829InvertedMethod;
315 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeed800Kbps, NeoEspInverted>> NeoEsp32BitBang800KbpsInvertedMethod;
316 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeed400Kbps, NeoEspInverted>> NeoEsp32BitBang400KbpsInvertedMethod;
317 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedApa106, NeoEspInverted>> NeoEsp32BitBangApa106InvertedMethod;
318 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedIntertek, NeoEspInverted>> NeoEsp32BitBangIntertekInvertedMethod;
320 typedef NeoEsp32BitBangWs2812xInvertedMethod NeoEsp32BitBangWs2813InvertedMethod;
321 typedef NeoEsp32BitBang800KbpsInvertedMethod NeoEsp32BitBangWs2812InvertedMethod;
322 typedef NeoEsp32BitBangWs2812xInvertedMethod NeoEsp32BitBangWs2816InvertedMethod;
323 typedef NeoEsp32BitBangTm1814InvertedMethod NeoEsp32BitBangTm1914InvertedMethod;
324 typedef NeoEsp32BitBangSk6812InvertedMethod NeoEsp32BitBangLc8812InvertedMethod;
328 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedWs2811, NeoEspNotInverted>> NeoEsp8266BitBangWs2811Method;
329 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedWs2812x, NeoEspNotInverted>> NeoEsp8266BitBangWs2812xMethod;
330 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedSk6812, NeoEspNotInverted>> NeoEsp8266BitBangSk6812Method;
331 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedTm1814, NeoEspInverted>> NeoEsp8266BitBangTm1814Method;
332 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedTm1829, NeoEspInverted>> NeoEsp8266BitBangTm1829Method;
333 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeed800Kbps, NeoEspNotInverted>> NeoEsp8266BitBang800KbpsMethod;
334 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeed400Kbps, NeoEspNotInverted>> NeoEsp8266BitBang400KbpsMethod;
335 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedApa106, NeoEspNotInverted>> NeoEsp8266BitBangApa106Method;
336 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedIntertek, NeoEspNotInverted>> NeoEsp8266BitBangIntertekMethod;
338 typedef NeoEsp8266BitBangWs2812xMethod NeoEsp8266BitBangWs2813Method;
339 typedef NeoEsp8266BitBang800KbpsMethod NeoEsp8266BitBangWs2812Method;
340 typedef NeoEsp8266BitBangWs2812xMethod NeoEsp8266BitBangWs2816Method;
341 typedef NeoEsp8266BitBangTm1814Method NeoEsp8266BitBangTm1914Method;
342 typedef NeoEsp8266BitBangSk6812Method NeoEsp8266BitBangLc8812Method;
344 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedWs2811, NeoEspInverted>> NeoEsp8266BitBangWs2811InvertedMethod;
345 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedWs2812x, NeoEspInverted>> NeoEsp8266BitBangWs2812xInvertedMethod;
346 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedSk6812, NeoEspInverted>> NeoEsp8266BitBangSk6812InvertedMethod;
347 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedTm1814, NeoEspNotInverted>> NeoEsp8266BitBangTm1814InvertedMethod;
348 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedTm1829, NeoEspNotInverted>> NeoEsp8266BitBangTm1829InvertedMethod;
349 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeed800Kbps, NeoEspInverted>> NeoEsp8266BitBang800KbpsInvertedMethod;
350 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeed400Kbps, NeoEspInverted>> NeoEsp8266BitBang400KbpsInvertedMethod;
351 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedApa106, NeoEspInverted>> NeoEsp8266BitBangApa106InvertedMethod;
352 typedef NeoEspBitBangMethodBase<NeoEspBitBangEncode<NeoEspBitBangSpeedIntertek, NeoEspInverted>> NeoEsp8266BitBangIntertekInvertedMethod;
354 typedef NeoEsp8266BitBangWs2812xInvertedMethod NeoEsp8266BitBangWs2813InvertedMethod;
355 typedef NeoEsp8266BitBang800KbpsInvertedMethod NeoEsp8266BitBangWs2812InvertedMethod;
356 typedef NeoEsp8266BitBangWs2812xInvertedMethod NeoEsp8266BitBangWs2816InvertedMethod;
357 typedef NeoEsp8266BitBangTm1814InvertedMethod NeoEsp8266BitBangTm1914InvertedMethod;
358 typedef NeoEsp8266BitBangSk6812InvertedMethod NeoEsp8266BitBangLc8812InvertedMethod;
Definition: NeoSettings.h:29