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

Method writeBits

src/platforms/esp/8266/clockless_esp8266.h:75–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73#define _ESP_ADJ2 (0)
74
75 template<int BITS> __attribute__ ((always_inline)) inline static bool writeBits(FASTLED_REGISTER u32 & last_mark, FASTLED_REGISTER u32 b) FL_NOEXCEPT {
76 b <<= 24; b = ~b;
77 for(FASTLED_REGISTER u32 i = BITS; i > 0; --i) {
78 while((__clock_cycles() - last_mark) < (T1+T2+T3)) {
79 ;
80 }
81 last_mark = __clock_cycles();
82 FastPin<DATA_PIN>::hi();
83
84 while((__clock_cycles() - last_mark) < T1) {
85 ;
86 }
87 if(b & 0x80000000L) { FastPin<DATA_PIN>::lo(); }
88 b <<= 1;
89
90 while((__clock_cycles() - last_mark) < (T1+T2)) {
91 ;
92 }
93 FastPin<DATA_PIN>::lo();
94
95 // even with interrupts disabled, the NMI interupt seems to cause
96 // timing issues here. abort the frame if one bit took to long. if the
97 // last of the 24 bits has been sent already, it is too late
98 // this fixes the flickering first pixel that started to occur with
99 // framework version 3.0.0
100 if ((__clock_cycles() - last_mark) >= (T1 + T2 + T3 - 5)) {
101 return true;
102 }
103 }
104 return false;
105 }
106
107
108 static u32 FL_IRAM showRGBInternal(PixelController<RGB_ORDER> pixels) FL_NOEXCEPT {

Callers

nothing calls this directly

Calls 3

__clock_cyclesFunction · 0.70
hiFunction · 0.50
loFunction · 0.50

Tested by

no test coverage detected