MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / ledTask

Function ledTask

ESP32_AP-Flasher/src/leds.cpp:205–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203volatile uint16_t monoIdlePeriod = 900;
204
205void ledTask(void* parameter) {
206#ifdef HAS_RGB_LED
207 FastLED.addLeds<WS2812B, FLASHER_RGB_LED, GRB>(leds, 1); // GRB ordering is typical
208 leds[0] = CRGB::Blue;
209 showRGB();
210 rgbLedQueue = xQueueCreate(30, sizeof(struct ledInstructionRGB*));
211
212 struct ledInstructionRGB* rgb = nullptr;
213 // open with a nice RGB crossfade
214 addFadeColor(CRGB::Red);
215 addFadeColor(CRGB::Green);
216 addFadeColor(CRGB::Blue);
217 CRGB oldColor = CRGB::Black;
218 uint16_t rgbInstructionFadeTime = 0;
219#endif
220
221 ledQueue = xQueueCreate(30, sizeof(struct ledInstruction*));
222
223 if (FLASHER_LED != -1) {
224#if ESP_ARDUINO_VERSION_MAJOR == 2
225 ledcSetup(7, 5000, 8);
226 ledcAttachPin(FLASHER_LED, 7);
227#else
228 ledcAttachChannel(FLASHER_LED, 1000, 8, 7);
229#endif
230 }
231
232 struct ledInstruction* monoled = nullptr;
233
234 addFadeMono(0);
235#ifdef HAS_TFT
236 addFadeMono(255);
237#else
238 addFadeMono(maxledbrightness);
239#endif
240 addFadeMono(0);
241
242 uint8_t oldBrightness = 0;
243
244 uint16_t monoInstructionFadeTime = 0;
245
246 while (1) {
247#ifdef HAS_RGB_LED
248 // handle RGB led instructions
249 if (rgb == nullptr) {
250 // fetch a led instruction
251 BaseType_t q = xQueueReceive(rgbLedQueue, &rgb, 1);
252 if (q == pdTRUE) {
253 if (rgb->reQueue && !rgbQueueFlush) {
254 // requeue this instruction at the end of the queue, caveman style.
255 struct ledInstructionRGB* requeue = new ledInstructionRGB;
256 requeue->fadeTime = rgb->fadeTime;
257 requeue->ledColor = rgb->ledColor;
258 requeue->length = rgb->length;
259 addToRGBQueue(requeue, true);
260 }
261
262 if (rgbQueueFlush) {

Callers

nothing calls this directly

Calls 6

showRGBFunction · 0.70
addFadeColorFunction · 0.70
addFadeMonoFunction · 0.70
addToRGBQueueFunction · 0.70
rgbIdleStepFunction · 0.70
showMonoFunction · 0.70

Tested by

no test coverage detected